Create transaction
To create a transaction, just provide an amount and an UID for the previously created payment method.
Simple card payment
If you have create a Card already, you can run a simple payment with just a few lines of code.
TransactionRequest request = new TransactionRequest()
.amount(new BigDecimal("10"), "EUR")
.creditCardUid("card_90SFG41GAS");
gateway.transaction().create(request);
Result
Handling a result depends on a payment method used, here is an example for card authorization request.
if (txn.getStatus() == Transaction.Status.AUTHORIZED) {
// Success
}
Create a card payment - full properties
This example shows the full use of our Transactions API.
By specifying saveInSafe setting option, separate objects will be created for certain fields in Pencepay platform (e.g. CreditCard, Customer, Address)
TransactionRequest request = new TransactionRequest()
.amount(new BigDecimal("10.99"), "EUR")
.orderId("123456")
.customer()
.firstName("John")
.lastName("Hancock")
.email("john.doe@server.com")
.done()
.billingAddress()
.addressLine1("some street 123")
.addressLine2("address line 2")
.city("Zagreb")
.postalCode("10000")
.countryIsoCode2("HR")
.done()
.creditCard()
.cardholderName("John Hancock")
.number("4350100010001002")
.cvv("313")
.expiryMonth(12)
.expiryYear(2016)
.done()
.customData("cust_field", "cust_val")
.settings()
.locale("hr-HR")
.reserveFundsOnly(true)
.saveInSafe(true)
.done();
gateway.transaction().create(request);
Create a bank transfer
In order to perform a bank transfer, provide a paymentMethod and bic properties.
TransactionRequest request = new TransactionRequest()
.paymentMethod(PaymentMethodType.BANK_TRANSFER)
.bic("NWBKGB2L");
.amount(new BigDecimal("10.99"), "EUR")
.orderId("123456")
.customer()
.firstName("John")
.lastName("Hancock")
.email("john.doe@server.com")
.done()
.billingAddress()
.addressLine1("some street 123")
.addressLine2("address line 2")
.city("Zagreb")
.postalCode("10000")
.countryIsoCode2("HR")
.done()
.customData("cust_field", "cust_val")
.settings()
.saveInSafe(true)
.done();
gateway.transaction().create(request);