@RequiredArgsConstructor
public class Authorize {
private final MyFatoorahTransactionService myFatoorahTransactionService;
public void performAuthorization() {
CurrencyUnit currency = Monetary.getCurrency(currencyCode);
MonetaryAmount transactionTotal = Monetary.getDefaultAmountFactory().setCurrency(currency).setNumber(amount).create();
PaymentRequest paymentRequest = new PaymentRequest()
.transactionReferenceId(transactionReferenceId)
.transactionTotal(transactionTotal)
.additionalField("sessionId", sessionId); // The sessionId which we got from MyFatoorah init session endpoint.
PaymentResponse paymentResponse = myFatoorahTransactionService.authorize(paymentRequest);
paymentResponse.isSuccessful();
paymentResponse.getGatewayResponseCode(); // The MyFatoorah response code
paymentResponse.getFailureType(); // Failure type in case the transaction was not successful.
paymentResponse.getRawResponse(); // MyFatoorah raw response stored as a JSON object.
paymentResponse.getGatewayTransactionId(); // gatewayTransactionId from MyFatoorah.
paymentResponse.getGatewayTransactionType(); // gateway transaction type.
paymentResponse.getResponseMap().get("invoiceId"); // MyFatoorah invoiceId which will be used to execute subsequent reverse-authorize, capture, and/or refund transactions.
paymentResponse.getResponseMap().get("paymentId"); // MyFatoorah paymentId.
paymentResponse.getResponseMap().get("paymentGateway"); // MyFatoorah paymentGateway.
paymentResponse.getResponseMap().get("transactionId"); // MyFatoorah transactionId.
}
}