public class Authorize {
@Autowired
PayPalCheckoutTransactionService transactionService;
public void performAuthorization() {
CurrencyUnit currency = Monetary.getCurrency(currencyCode);
MonetaryAmount transactionTotal = Monetary.getDefaultAmountFactory().setCurrency(currency).setNumber(amount).create();
PaymentRequest paymentRequest = new PaymentRequest()
.paymentId(paymentId)
.transactionTotal(transactionTotal)
.orderSubtotal(transactionTotal)
.paymentOwnerType("BLC_CART")
.paymentOwnerId(cartId)
.additionalField(MessageConstants.PAYMENTID, "payPalPaymentId")
.additionalField(MessageConstants.PAYERID, "payer_id")
.transactionReferenceId(transactionReferenceId);
PaymentResponse paymentResponse = transactionService.authorize(paymentRequest);
paymentResponse.isSuccessful();
paymentResponse.getGatewayResponseCode(); //PayPa Response Code
paymentResponse.getFailureType(); // Failure type in case the transaction was not successful.
paymentResponse.getResponseMap().get(MessageConstants.AUTHORIZATIONID); // PayPal Authorization id
paymentResponse.getRawResponse(); // PayPal Raw response stored as a JSON object
}
}