This library is the abstraction of Xendit API for access from applications written with Java.
- API Documentation
- Requirements
- Installation
- Usage
- Contributing
Please check Xendit API Reference.
JDK 1.7 or later.
Add these lines of code in your pom.xml
<dependency>
<groupId>com.xendit</groupId>
<artifactId>xendit-java-lib</artifactId>
<version>SELECTED_VERSION</version>
</dependency>
<repositories>
<repository>
<snapshots>
<enabled>
false
</enabled>
</snapshots>
<id>
bintray-xendit-android
</id>
<name>
bintray
</name>
<url>
https://dl.bintray.com/xendit/android
</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>
false
</enabled>
</snapshots>
<id>
bintray-xendit-android
</id>
<name>
bintray-plugins
</name>
<url>
https://dl.bintray.com/xendit/android
</url>
</pluginRepository>
</pluginRepositories>
Add these lines in your build.gradle
...
repositories {
maven {
url "https://dl.bintray.com/xendit/android"
}
}
...
compile 'com.xendit:xendit-java-lib:{SELECTED_VERSION}'
More information: https://bintray.com/xendit/android/xendit-java-lib
You need to use secret API key in order to use functionality in this library. The key can be obtained from your Xendit Dashboard.
import com.xendit.Xendit;
public class Example {
public static void main(String[] args) {
Xendit.apiKey = "PUT YOUR API KEY HERE";
}
}
Example: Create a disbursement
import com.xendit.Xendit;
import com.xendit.exception.XenditException;
import com.xendit.model.Disbursement;
import java.util.HashMap;
import java.util.Map;
public class ExampleCreateDisbursement {
public static void main(String[] args) {
Xendit.apiKey = "xnd_development_...";
try {
Map<String, Object> params = new HashMap<>();
params.put("external_id", "my_external_id");
params.put("bank_code", "BCA");
params.put("account_holder_name", "John Doe");
params.put("account_number", "123456789");
params.put("description", "My Description");
params.put("amount", "90000");
Disbursement disbursement = Disbursement.create(params);
} catch (XenditException e) {
e.printStackTrace();
}
}
}
There are some examples provided for you here.
You can choose whether want to put the attributes as parameters or to put in inside a Map object.
Disbursement.create( String externalId, String bankCode, String accountHolderName, String accountNumber, String description, BigInteger amount, String[] emailTo, String[] emailCc, String[] emailBcc ); |
Disbursement.create( Map<String, Object> params ); |
Map<String, Object> params = new HashMap<>();
params.put("external_id", "my_external_id");
params.put("bank_code", "BCA");
params.put("account_holder_name", "John Doe");
params.put("account_number", "123456789");
params.put("description", "My Description");
params.put("amount", "90000");
Disbursement disbursement = Disbursement.create(params);
AvailableBank[] banks = Disbursement.getAvailableBanks();
Disbursement disbursement = Disbursement.getByExternalId("EXAMPLE_ID");
Disbursement disbursement = Disbursement.getById("EXAMPLE_ID");
You can choose whether want to put the attributes as parameters or to put in inside a Map object.
Invoice.create( String externalId, Number amount, String payerEmail, String description ); |
Invoice.create( Map<String, Object> params ); |
Map<String, Object> params = new HashMap<>();
params.put("external_id", "my_external_id");
params.put("amount", 1800000);
params.put("payer_email", "[email protected]");
params.put("description", "Invoice Demo #123");
Invoice invoice = Invoice.create(params);
Invoice invoice = Invoice.getById("EXAMPLE_ID");
Map<String, Object> params = new HashMap<>();
params.put("limit", 3);
params.put("statuses", "[\"SETTLED\",\"EXPIRED\"]");
Invoice[] invoices = Invoice.getAll(params);
Invoice invoice = Invoice.expire("EXAMPLE_ID");
You can choose whether want to put the attributes as parameters or to put in inside a Map object.
FixedVirtualAccount.createClosed( String externalId, String bankCode, String name, Long expectedAmount, Map<String, Object> additionalParam ); |
FixedVirtualAccount.createClosed( Map<String, Object> params ); |
FixedVirtualAccount.createOpen( String externalId, String bankCode, String name, Map<String, Object> additionalParam ); |
FixedVirtualAccount.createOpen( Map<String, Object> params ); |
Map<String, Object> params = new HashMap<>();
params.put("external_id", "my_external_id");
params.put("bank_code", BankCode.BNI.getText());
params.put("name", "John Doe");
FixedVirtualAccount virtualAccount = FixedVirtualAccount.createOpen(params);
Map<String, Object> params = new HashMap<>();
params.put("is_single_use", true);
FixedVirtualAccount fixedVirtualAccount = FixedVirtualAccount.update("EXAMPLE_ID", params);
AvailableBank[] availableBanks = FixedVirtualAccount.getAvailableBanks();
FixedVirtualAccount fpa = FixedVirtualAccount.getFixedVA("EXAMPLE_ID");
FixedVirtualAccountPayment payment = FixedVirtualAccount.getPayment("EXAMPLE_PAYMENT_ID");
You can choose whether want to put the attributes as parameters or to put in inside a Map object.
RetailOutlet.createFixedPaymentCode( String externalId, String retailOutletName, String name, Number expectedAmount ); |
RetailOutlet.createFixedPaymentCode( Map<String, Object> params ); |
params.put("external_id", "test");
params.put("retail_outlet_name", "ALFAMART");
params.put("name", "Rika Sutanto");
params.put("expected_amount", 10000);
FixedPaymentCode fpc = RetailOutlet.createFixedPaymentCode(params);
FixedPaymentCode fpc = RetailOutlet.getFixedPaymentCode("EXAMPLE_ID");
You can choose whether want to put the attributes as parameters or to put in inside a Map object.
RetailOutlet.updateFixedPaymentCode( String id, String name, Number expectedAmount, String expirationDate ); |
RetailOutlet.updateFixedPaymentCode( String id, Map<String, Object> params ); |
Map<String, Object> params = new HashMap<>();
params.put("name", "Lorem Ipsum");
FixedPaymentCode fpc = RetailOutlet.updateFixedPaymentCode("EXAMPLE_ID", params);
You can choose whether want to put the attributes as parameters or to put in inside a Map object.
RecurringPayment.create( String externalId, String payerEmail, String interval, Number intervalCount, String description, Number amount ); |
RecurringPayment.create( Map<String, Object> params ); |
Map<String , Object> params = new HashMap<>();
params.put("external_id", "recurring_31451441");
params.put("payer_email", "[email protected]");
params.put("interval", "MONTH");
params.put("interval_count", 1);
params.put("description", "Test desc");
params.put("amount", 100000);
RecurringPayment recurringPayment = RecurringPayment.create(params);
RecurringPayment recurringPayment = RecurringPayment.get("5e2dd160f8a4d24146f5974c");
Map<String, Object> params = new HashMap<>();
params.put("amount", 987654);
params.put("interval", "WEEK");
RecurringPayment recurringPayment = RecurringPayment.edit("5e2dd55ef8a4d24146f59775", params);
RecurringPayment recurringPayment = RecurringPayment.stop("5e2dd160f8a4d24146f5974c");
RecurringPayment recurringPayment = RecurringPayment.pause("5e2dd55ef8a4d24146f59775");
RecurringPayment recurringPayment = RecurringPayment.resume("5e2dd55ef8a4d24146f59775");
Invoice[] invoices = RecurringPayment.getPaymentsById("5e2dd55ef8a4d24146f59775");
The accountType
parameter is optional.
Balance.get();
Balance.get(String accountType);
Balance balance = Balance.get("CASH");
You can choose whether want to put the attributes as parameters or to put in inside a Map object.
Payout.createPayout( String externalId, Number amount ); |
Payout.createPayout( Map<String, Object> params ); |
Map<String, Object> params = new HashMap<>();
params.put("external_id", "my_test_id");
params.put("amount", 100000);
Payout payout = Payout.createPayout(params);
Payout payout = Payout.getPayout("EXAMPLE_ID");
Payout payout = Payout.voidPayout("EXAMPLE_ID");
EWalletPayment.createLinkajaPayment(
String externalId,
Number amount,
String phone,
EWalletLinkajaItem[] items,
String callbackUrl,
String redirectUrl
);
EWalletPayment.createDanaPayment(
String externalId,
Number amount,
String phone,
String expirationDate,
String callbackUrl,
String redirectUrl
);
EWalletPayment.createOvoPayment(
String externalId,
Number amount,
String phone
);
EWalletPayment payment = EWalletPayment.getPaymentStatus("ovo-ewallet", EWalletPayment.EWalletType.OVO);
You can choose whether want to put the attributes as parameters or to put in inside a Map object.
CreditCardCharge.createAuthorization( String tokenId, String externalId, Number amount, String authenticationId, String cardCVN, Boolean capture ); |
CreditCardCharge.createAuthorization( Map<String, Object> params ); |
CreditCardCharge creditCardCharge = CreditCard.createAuthorization("...", "test_id", 75000, "...", "123", false);
You can choose whether want to put the attributes as parameters or to put in inside a Map object.
CreditCardCharge.createCharge( String tokenId, String externalId, Number amount, String authenticationId, String cardCVN, String descriptor ); |
CreditCardCharge.createCharge( Map<String, Object> params ); |
CreditCardCharge creditCardCharge = CreditCard.createCharge("...", "test_id", 75000, "...", "123", "lorem ipsum");
CreditCard.reverseAuthorization(String chargeId, String externalId);
CreditCardReverseAuth creditCardReverseAuth = CreditCard.reverseAuthorization("1234567", "external_id");
CreditCard.captureCharge(String chargeId, Number amount);
CreditCardCharge creditCardCharge = CreditCard.captureCharge("12345678", 55000);
CreditCardCharge creditCardCharge = CreditCard.getCharge("1234567");
CreditCard.createRefund(String id, Number amount, String externalId);
CreditCardRefund creditCardRefund = CreditCard.createRefund("1234567", 50000, "external_id");
BatchDisbursementItem item =
BatchDisbursementItem.builder()
.amount(10000)
.bankCode("ABC")
.bankAccountName("Lorem Ipsum")
.bankAccountNumber("1234567890")
.description("Lorem ipsum dolor sit amet")
.externalId("test_id")
.emailTo(["email1", "email2"])
.emailCC(["email1", "email2"])
.emailBcc(["email1", "email2"])
.build();
BatchDisbursement.create(
String reference,
BatchDisbursementItem[] disbursements
);
AvailableBank[] banks = BatchDisbursement.getAvailableBanks();
CardlessCreditItem item =
CardlessCreditItem.builder()
.id("123")
.name("Phone Case")
.price(200000)
.type("Smartphone")
.url("https://www.example.org")
.quantity(1)
.build();
CardlessCreditCustomer customer =
CardlessCreditCustomer.builder()
.firstName("Lorem")
.lastName("Ipsum")
.email("[email protected]")
.phone("08129748247684")
.build();
CardlessCreditShippingAddress address =
CardlessCreditShippingAddress.builder()
.firstName("Lorem")
.lastName("Ipsum")
.address("Jalan teknologi")
.city("Jakarta")
.postalCode("12345")
.countryCode("IDN")
.phone("08129748247684")
.build();
You can choose whether want to put the attributes as parameters or to put in inside a Map object.
CardlessCredit.create( String cardlessCreditType, String externalId, Number amount, String paymentType, CardlessCreditItem[] items, CardlessCreditCustomer customerDetails, CardlessCreditShippingAddress shippingAddress, String redirectUrl, String callbackUrl ); |
CardlessCredit.create( Map<String, Object> params ); |
CardlessCredit cardlessCredit = CardlessCredit.create(
"KREDIVO",
"external_id",
200000,
CardlessCredit.PaymentType.THREE_MONTHS.getVal(),
items,
customer,
address,
"www.example.com",
"www.example.com"
);
You can go to the contributing guidelines to learn on how to contribute this project.
Make sure the the code passes all tests.
./gradlew test
Before making any commits, please install pre-commit. To install pre-commit, follow the installation steps.
For any requests, bugs, or comments, please open an issue or submit a pull request.