Class DefaultPayPalOrderService
- java.lang.Object
-
- com.broadleafcommerce.paypal.micro.service.DefaultPayPalOrderService
-
- All Implemented Interfaces:
PayPalOrderService
public class DefaultPayPalOrderService extends Object implements PayPalOrderService
-
-
Constructor Summary
Constructors Constructor Description DefaultPayPalOrderService(PayPalCheckoutProvider checkoutProvider, PayPalApiProvider apiProvider, PayPalGatewayConfiguration gatewayConfiguration, PayPalCheckoutApiProperties properties)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected AmountWithBreakdownconstructAmountWithBreakdown(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)protected List<Item>constructItems(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)protected PayeeconstructPayee(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)Constructions aPayeeto place on thePurchaseUnitwhen creating an order.protected PaymentSourceconstructPaymentSource(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)protected ShippingDetailconstructShippingDetail(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)protected Optional<Money>convertToMoney(javax.money.MonetaryAmount amount)protected OrdercreateOrder(@NonNull OrderRequest orderRequest, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)OrdercreatePayPalOrder(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest, boolean performCheckoutOnReturn, boolean capture)Creates a PayPalOrder.protected PayPalCheckoutProvidergetCheckoutProvider()protected PayPalGatewayConfigurationgetGatewayConfiguration()StringgetIntent(boolean performCheckoutOnReturn, boolean capture)protected StringgetPayerEmail(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)protected PayPalCheckoutApiPropertiesgetProperties()protected StringgetStateCode(@NonNull com.broadleafcommerce.paymentgateway.domain.Address<com.broadleafcommerce.paymentgateway.domain.PaymentRequest> address)PayPal supports only the State code with a short form, e.g.protected voidupdateOrder(String orderId, List<Patch> patches, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)voidupdateOrderCustomId(@NonNull String orderId, @NonNull String customId, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)Updates the PayPalOrderto include the provided custom ID value.voidupdatePayPalOrder(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)Updates the PayPalOrderto be in sync with the Broadleaf order.
-
-
-
Constructor Detail
-
DefaultPayPalOrderService
public DefaultPayPalOrderService(PayPalCheckoutProvider checkoutProvider, PayPalApiProvider apiProvider, PayPalGatewayConfiguration gatewayConfiguration, PayPalCheckoutApiProperties properties)
-
-
Method Detail
-
createPayPalOrder
public Order createPayPalOrder(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest, boolean performCheckoutOnReturn, boolean capture)
Description copied from interface:PayPalOrderServiceCreates a PayPalOrder.- Specified by:
createPayPalOrderin interfacePayPalOrderService- Parameters:
paymentRequest- The gatewayPaymentRequestcontaining the information necessary to construct the orderperformCheckoutOnReturn- Indicates if we should start checkout after the user has authorized the order- Returns:
- The new
Order
-
updatePayPalOrder
public void updatePayPalOrder(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)Description copied from interface:PayPalOrderServiceUpdates the PayPalOrderto be in sync with the Broadleaf order.Our default implementation of this method updates the pricing information in the PayPal order after
Ordercreation to keep both order representations in sync. For creating an order usePayPalOrderService.createPayPalOrder(PaymentRequest, boolean, boolean).- Specified by:
updatePayPalOrderin interfacePayPalOrderService- Parameters:
paymentRequest- The gatewayPaymentRequest
-
updateOrderCustomId
public void updateOrderCustomId(@NonNull @NonNull String orderId, @NonNull @NonNull String customId, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)Description copied from interface:PayPalOrderServiceUpdates the PayPalOrderto include the provided custom ID value.- Specified by:
updateOrderCustomIdin interfacePayPalOrderService- Parameters:
orderId- the primary identifier of the PayPalOrdercustomId- the value that is to be stored on the PayPalOrderobjectpaymentRequest- The originatingPaymentRequest
-
getIntent
public String getIntent(boolean performCheckoutOnReturn, boolean capture)
-
constructPaymentSource
protected PaymentSource constructPaymentSource(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
-
getPayerEmail
@Nullable protected String getPayerEmail(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
-
constructPayee
@Nullable protected Payee constructPayee(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
Constructions aPayeeto place on thePurchaseUnitwhen creating an order. This is used only for PayPal's marketplace offering.- Parameters:
paymentRequest- The gatewayPaymentRequestwith the payment info.- Returns:
- a
Payeeto place on thePurchaseUnitor null if noMessageConstants.PAYEE_MERCHANT_IDonPaymentRequest.getAdditionalFields()
-
constructItems
protected List<Item> constructItems(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
-
constructShippingDetail
@Nullable protected ShippingDetail constructShippingDetail(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
-
convertToMoney
protected Optional<Money> convertToMoney(@Nullable javax.money.MonetaryAmount amount)
-
getStateCode
@Nullable protected String getStateCode(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.Address<com.broadleafcommerce.paymentgateway.domain.PaymentRequest> address)
PayPal supports only the State code with a short form, e.g. "AL" instead of "US-AL".
-
createOrder
protected Order createOrder(@NonNull @NonNull OrderRequest orderRequest, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
-
updateOrder
protected void updateOrder(String orderId, List<Patch> patches, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
-
constructAmountWithBreakdown
protected AmountWithBreakdown constructAmountWithBreakdown(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
-
getCheckoutProvider
protected PayPalCheckoutProvider getCheckoutProvider()
-
getGatewayConfiguration
protected PayPalGatewayConfiguration getGatewayConfiguration()
-
getProperties
protected PayPalCheckoutApiProperties getProperties()
-
-