Class DefaultPayPalCheckoutHostedService
java.lang.Object
com.broadleafcommerce.paypal.micro.gateway.service.DefaultPayPalCheckoutHostedService
- All Implemented Interfaces:
com.broadleafcommerce.paymentgateway.service.PaymentGatewayHostedService,com.broadleafcommerce.paymentgateway.service.PaymentGatewayTypeAware,PayPalCheckoutHostedService
public class DefaultPayPalCheckoutHostedService
extends Object
implements PayPalCheckoutHostedService
- Author:
- Nathan Moore
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultPayPalCheckoutHostedService(PayPalGatewayConfiguration configuration, com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService transactionService) -
Method Summary
Modifier and TypeMethodDescriptionprotected AmountWithBreakdownbuildAmountWithBreakdown(@NonNull com.broadleafcommerce.paymentgateway.domain.ExternalFulfillmentCallbackInfo callbackInfo) protected com.broadleafcommerce.paymentgateway.domain.PaymentRequestbuildOrderLookupPaymentRequest(@NonNull com.broadleafcommerce.paymentgateway.domain.ExternalFulfillmentCallbackDTO callbackDTO) protected List<PurchaseUnitInfo>buildPurchaseUnits(@NonNull com.broadleafcommerce.paymentgateway.domain.ExternalFulfillmentCallbackInfo callbackInfo) com.broadleafcommerce.paymentgateway.domain.ExternalFulfillmentCallbackTransformedResponsebuildShippingCallbackResponse(@NonNull com.broadleafcommerce.paymentgateway.domain.ExternalFulfillmentCallbackInfo callbackInfo) protected List<ShippingOption>buildShippingOptions(@NonNull List<com.broadleafcommerce.paymentgateway.domain.FulfillmentOption> fulfillmentOptions) protected StringconvertToGatewayFulfillmentType(String fulfillmentType) protected javax.money.MonetaryAmountconvertToMonetaryAmount(@NonNull Money amount) convertToMoney(javax.money.MonetaryAmount amount) protected voiddetermineAndBuildAddressToUse(@NonNull com.broadleafcommerce.paymentgateway.domain.ExternalGatewayFulfillmentUpdate fulfillmentUpdate, @NonNull ShippingCallbackRequest shippingCallbackRequest, @NonNull PurchaseUnit purchaseUnit, @NonNull Order updatedOrder) protected StringdetermineFulfillmentType(String shippingOptionType) protected AddressPortablefindAndValidateAddressToUse(@NonNull ShippingCallbackRequest shippingCallbackRequest, @NonNull PurchaseUnit purchaseUnit, @NonNull Order updatedOrder) protected PayPalGatewayConfigurationprotected com.fasterxml.jackson.databind.ObjectMapperprotected PayPalOrderServiceprotected com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionServiceprotected com.broadleafcommerce.common.extension.TypeFactorycom.broadleafcommerce.paymentgateway.domain.PaymentResponserequestHostedEndpoint(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest, boolean capture) voidsetObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper) voidsetPayPalOrderService(PayPalOrderService payPalOrderService) voidsetTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory) List<com.broadleafcommerce.paymentgateway.domain.ExternalGatewayFulfillmentUpdate>updateShippingCallback(@NonNull com.broadleafcommerce.paymentgateway.domain.ExternalFulfillmentCallbackDTO callbackDTO) protected booleanvalidateAddress(AddressPortable addressPortable) protected voidvalidateOrderStatus(Order updatedOrder) Validates the status of the PayPal Order during the shipping callback.protected voidvalidateShippingCallbackRequest(ShippingCallbackRequest shippingCallbackRequest, Order updatedOrder, String tokenParam, String tokenHmacKey) Entry point for validation of theShippingCallbackRequest.protected voidvalidateToken(String referenceId, String tokenParam, String tokenHmacKey) Validates the token received in the shipping callback URL params.
-
Constructor Details
-
DefaultPayPalCheckoutHostedService
public DefaultPayPalCheckoutHostedService(PayPalGatewayConfiguration configuration, com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService transactionService)
-
-
Method Details
-
updateShippingCallback
public List<com.broadleafcommerce.paymentgateway.domain.ExternalGatewayFulfillmentUpdate> updateShippingCallback(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.ExternalFulfillmentCallbackDTO callbackDTO) throws com.broadleafcommerce.paymentgateway.service.exception.PaymentException - Specified by:
updateShippingCallbackin interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayHostedService- Throws:
com.broadleafcommerce.paymentgateway.service.exception.PaymentException
-
buildShippingCallbackResponse
public com.broadleafcommerce.paymentgateway.domain.ExternalFulfillmentCallbackTransformedResponse buildShippingCallbackResponse(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.ExternalFulfillmentCallbackInfo callbackInfo) throws com.broadleafcommerce.paymentgateway.service.exception.PaymentException - Specified by:
buildShippingCallbackResponsein interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayHostedService- Throws:
com.broadleafcommerce.paymentgateway.service.exception.PaymentException
-
requestHostedEndpoint
public com.broadleafcommerce.paymentgateway.domain.PaymentResponse requestHostedEndpoint(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest, boolean capture) throws com.broadleafcommerce.paymentgateway.service.exception.PaymentException - Specified by:
requestHostedEndpointin interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayHostedService- Throws:
com.broadleafcommerce.paymentgateway.service.exception.PaymentException
-
buildOrderLookupPaymentRequest
protected com.broadleafcommerce.paymentgateway.domain.PaymentRequest buildOrderLookupPaymentRequest(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.ExternalFulfillmentCallbackDTO callbackDTO) -
determineAndBuildAddressToUse
protected void determineAndBuildAddressToUse(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.ExternalGatewayFulfillmentUpdate fulfillmentUpdate, @NonNull @NonNull ShippingCallbackRequest shippingCallbackRequest, @NonNull @NonNull PurchaseUnit purchaseUnit, @NonNull @NonNull Order updatedOrder) -
findAndValidateAddressToUse
protected AddressPortable findAndValidateAddressToUse(@NonNull @NonNull ShippingCallbackRequest shippingCallbackRequest, @NonNull @NonNull PurchaseUnit purchaseUnit, @NonNull @NonNull Order updatedOrder) -
validateAddress
-
determineFulfillmentType
-
buildPurchaseUnits
protected List<PurchaseUnitInfo> buildPurchaseUnits(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.ExternalFulfillmentCallbackInfo callbackInfo) -
buildAmountWithBreakdown
protected AmountWithBreakdown buildAmountWithBreakdown(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.ExternalFulfillmentCallbackInfo callbackInfo) -
convertToMoney
-
convertToMonetaryAmount
@Nullable protected javax.money.MonetaryAmount convertToMonetaryAmount(@NonNull @NonNull Money amount) -
buildShippingOptions
protected List<ShippingOption> buildShippingOptions(@NonNull @NonNull List<com.broadleafcommerce.paymentgateway.domain.FulfillmentOption> fulfillmentOptions) -
convertToGatewayFulfillmentType
-
validateShippingCallbackRequest
protected void validateShippingCallbackRequest(ShippingCallbackRequest shippingCallbackRequest, Order updatedOrder, String tokenParam, @Nullable String tokenHmacKey) throws SignatureException Entry point for validation of theShippingCallbackRequest.- Parameters:
shippingCallbackRequest- TheShippingCallbackRequestto validateupdatedOrder- The updated PayPal OrdertokenParam- The token received in the shipping callback URL paramstokenHmacKey- The private HMAC key used to generate the token- Throws:
SignatureException- if there was a failure to generate the HMAC signature
-
validateToken
protected void validateToken(String referenceId, String tokenParam, String tokenHmacKey) throws SignatureException, com.broadleafcommerce.paymentgateway.service.exception.ShippingCallbackValidationException Validates the token received in the shipping callback URL params. This is to ensure that the shipping callback is valid and initiated from PayPal, since we pass this token during PayPal Order creation.- Parameters:
referenceId- The reference ID for the PayPal ordertokenParam- The token received in the shipping callback URL paramstokenHmacKey- The private HMAC key used to generate the token- Throws:
SignatureException- if the key failed to generate an HMAC signaturecom.broadleafcommerce.paymentgateway.service.exception.ShippingCallbackValidationException- if the token is invalid
-
validateOrderStatus
Validates the status of the PayPal Order during the shipping callback.- Parameters:
updatedOrder- The current PayPal Order- Throws:
com.broadleafcommerce.paymentgateway.service.exception.ShippingCallbackValidationException- when the paypal order status is not valid
-
getGatewayType
- Specified by:
getGatewayTypein interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayTypeAware
-
getConfiguration
-
getTransactionService
protected com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService getTransactionService() -
getPayPalOrderService
-
setPayPalOrderService
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() -
setObjectMapper
@Autowired public void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
setTypeFactory
@Autowired public void setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-