Broadleaf Microservices
  • v1.0.0-latest-prod

Tabby Authorize Transaction

Prerequisites

Before performing an Authorize transaction with the Tabby gateway, you’ll first need to set up your environment as described in the Environment Setup Guide.

Executing an Authorize Transaction

Note
This transaction creates a Checkout session and Tabby Payment.

Use the following code snippet to perform an Authorize transaction:

@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
	}
}
  1. Optional. The Tabby payment type. Available values PAY_IN_4 and PAY_LATER. Version 1.0.0-GA supports only PAY_IN_4 which is used by default if not specified.

  2. The Tabby payment object serialized as a String.

  3. Used for redirecting the customer after the tabby HPP flow. Required for Web integration, optional for Mobile App integration.

  4. Collect Merchant codes from your Tabby Account manager. This value can be added in the configuration using broadleaf.tabby.merchant-code property if it can have only 1 value within 1 application. If it can be different for example, for different currencies, resolve the correct code and provide it via "merchant_code" attribute.

To set additional fields in the PaymentRequest, use method

PaymentRequest.additionalField(key, value)

To get values from responseMap, use

PaymentResponse.getResponseMap().get(key, value)

To get the transaction reference ID from response:

PaymentResponse.getTransactionReferenceId()

To get the Broadleaf Payment ID from the response:

PaymentResponse.getPaymentId()