@RequiredArgsConstructor
public class Authorize {
private final TabbyTransactionService tabbyTransactionService;
public void performAuthorization() {
CurrencyUnit currency = Monetary.getCurrency(currencyCode);
MonetaryAmount transactionTotal = Monetary.getDefaultAmountFactory().setCurrency(currency).setNumber(amount).create();
PaymentRequest paymentRequest = new PaymentRequest()
.transactionTotal(transactionTotal)
.transactionReferenceId(transactionReferenceId)
.tenantId(tenantId)
.applicationId(applicationId)
.additionalField("bnpl_type", "PAY_IN_4") // (1)
.additionalField("payment", tabbyPaymentJsonString) // (2)
.additionalField("lang", "en")
.additionalField("merchant_urls", merchantUrlsJsonString) // (3)
.additionalField("merchant_code", merchantCode); // (4)
PaymentResponse paymentResponse = tabbyTransactionService.authorize(paymentRequest);
paymentResponse.isSuccessful();
paymentResponse.getFailureType(); // Failure type in case the transaction was not successful
paymentResponse.getRawResponse(); // Tabby raw response stored as a String
paymentResponse.getGatewayTransactionId(); // the gateway transaction id
paymentResponse.getResponseMap().get("payment_id"); // Tabby payment id
paymentResponse.getResponseMap().get("payment_status"); // Tabby payment status
paymentResponse.getResponseMap().get("checkout_session_id"); // Tabby checkout session id
paymentResponse.getResponseMap().get("checkout_session_status"); // Tabby checkout session status
paymentResponse.getNextAction(); // The next step required for the payment gateway to continue processing this payment
}
}