Skip to content

Latest commit

 

History

History
94 lines (67 loc) · 2.7 KB

README.md

File metadata and controls

94 lines (67 loc) · 2.7 KB

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.8.0</version>
</dependency>

Gradle users

Add this dependency to your project's build file:

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

Others

You'll need to manually install the following JARs:

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

In advance, you need to get token by Checkout.

PayjpExample.java

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

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

public class PayjpExample {

    public static void main(String[] args) {
        Payjp.apiKey = "your_secret_key";
        Map<String, Object> chargeMap = new HashMap<String, Object>();
        chargeMap.put("amount", 3500);
        chargeMap.put("currency", "jpy");
        chargeMap.put("card", "<your_token_id>");
        try {
            Charge charge = Charge.create(chargeMap);
            System.out.println(charge);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Retry on HTTP Status Code 429

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.