No description, website, or topics provided.
Java
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
.travis.yml
CHANGELOG
LICENSE
README.md
RequestExample.md
VERSION
pom.xml

README.md

PAY.JP for Java

Build Status

Requirements

Java 1.6 and later.

Installation

Maven users

Add this dependency to your project's POM:

<dependency>
  <groupId>jp.pay</groupId>
  <artifactId>payjp-java</artifactId>
  <version>0.3.0</version>
</dependency>

Gradle users

Add this dependency to your project's build file:

compile "jp.pay:payjp-java:0.3.0"

Others

You'll need to manually install the following JARs:

ProGuard

If you're planning on using ProGuard, make sure that you exclude the Payjp bindings. You can do this by adding the following to your proguard.cfg file:

-keep class jp.pay.** { *; }

Usage

PayjpExample.java

import java.util.HashMap;
import java.util.Map;

import jp.pay.Payjp;
import jp.pay.exception.PayjpException;
import jp.pay.model.Charge;
import jp.pay.net.RequestOptions;

public class PayjpExample {

    public static void main(String[] args) {
        Payjp.apikey = "sk_test_c62fade9d045b54cd76d7036";
        Map<String, Object> chargeMap = new HashMap<String, Object>();
        chargeMap.put("amount", 3500);
        chargeMap.put("currency", "jpy");
        Map<String, Object> cardMap = new HashMap<String, Object>();
        cardMap.put("number", "4242424242424242");
        cardMap.put("exp_month", 12);
        cardMap.put("exp_year", 2020);
        chargeMap.put("card", cardMap);
        try {
            Charge charge = Charge.create(chargeMap
);
            System.out.println(charge);
        } catch (PayjpException e) {
            e.printStackTrace();
        }
    }
}

Testing

You must have Maven installed. To run the tests, simply run mvn test. You can run particular tests by passing -D test=Class#method -- for example, -D test=PayjpTest#testChargeCreate.