Library setup

We provide Java library to help you easily integrate your Java application with Pencepay.

Download JAR

Once you have the JAR, place it in your classpath and initialize the library.

You have to have GSON dependency on your classpath for the Pencepay Java library to work.

Initialize it

To access Pencepay platform from your Java application, you need to initialize the library first, by providing the access credentials to the constructor.

PencepayContext context = new PencepayContext(
    "yout-public-key",                 // Public Key
    "your-secret-key",                 // Secret Key
    Environment.PRODUCTION             // Gateway environment used

Use it

After you have PencepayContext, you can use it to access the various APIs available through the PencepayGateway.

PencepayGateway gateway = new PencepayGateway(context);

CustomerGateway customerGateway = gateway.customer();
AddressGateway addressGateway = gateway.address();
CreditCardGateway cardGateway = gateway.creditCard();
BankAccountGateway bankAccountGateway = gateway.bankAccount();
PaycodeGateway paycodeGateway = gateway.paycode();
SubscriptionGateway subscriptionGateway = gateway.subscription();
PlanGateway planGateway = gateway.plan();
TransactionGateway transactionGateway = gateway.transactions();
LogGateway logGateway = gateway.log();
EventGateway eventGateway = gateway.event();

You can now call any of the provided API methods, as this example shows.

Customer customer = gateway.customer().create(
    new CustomerRequest()
        .description("test customer")