Class DefaultPayPalOrderService
- java.lang.Object
-
- com.broadleafcommerce.paypal.micro.service.DefaultPayPalOrderService
-
- All Implemented Interfaces:
PayPalOrderService
public class DefaultPayPalOrderService extends Object implements PayPalOrderService
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
ADD_OP_TYPE
protected static String
REPLACE_OP_TYPE
-
Constructor Summary
Constructors Constructor Description DefaultPayPalOrderService(PayPalCheckoutProvider checkoutProvider, PayPalClientProvider clientProvider, PayPalGatewayConfiguration gatewayConfiguration, PayPalCheckoutApiProperties properties)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected com.paypal.orders.AmountWithBreakdown
constructAmountWithBreakdown(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
protected List<com.paypal.orders.Item>
constructItems(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
protected com.paypal.orders.Payee
constructPayee(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
Constructions aPayee
to place on thePurchaseUnitRequest
when creating an order.protected com.paypal.orders.Payer
constructPayer(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
protected com.paypal.orders.ShippingDetail
constructShippingDetail(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
protected Optional<com.paypal.orders.Money>
convertToMoney(javax.money.MonetaryAmount amount)
protected com.paypal.orders.Order
createOrder(@NonNull com.paypal.orders.OrderRequest orderRequest, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
com.paypal.orders.Order
createPayPalOrder(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest, boolean performCheckoutOnReturn, boolean capture)
Creates a PayPalOrder
.protected PayPalCheckoutProvider
getCheckoutProvider()
protected PayPalClientProvider
getClientProvider()
protected PayPalGatewayConfiguration
getGatewayConfiguration()
String
getIntent(boolean performCheckoutOnReturn, boolean capture)
protected String
getPayerEmail(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
protected PayPalCheckoutApiProperties
getProperties()
protected String
getStateCode(@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 void
updateOrder(String orderId, List<com.paypal.orders.Patch> patches, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
void
updateOrderCustomId(@NonNull String orderId, @NonNull String customId, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
Updates the PayPalOrder
to include the provided custom ID value.void
updatePayPalOrderForFulfillment(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
Updates the PayPalOrder
to be in sync with the Broadleaf order.
-
-
-
Field Detail
-
ADD_OP_TYPE
protected static final String ADD_OP_TYPE
- See Also:
- Constant Field Values
-
REPLACE_OP_TYPE
protected static final String REPLACE_OP_TYPE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultPayPalOrderService
public DefaultPayPalOrderService(PayPalCheckoutProvider checkoutProvider, PayPalClientProvider clientProvider, PayPalGatewayConfiguration gatewayConfiguration, PayPalCheckoutApiProperties properties)
-
-
Method Detail
-
createPayPalOrder
public com.paypal.orders.Order createPayPalOrder(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest, boolean performCheckoutOnReturn, boolean capture)
Description copied from interface:PayPalOrderService
Creates a PayPalOrder
.- Specified by:
createPayPalOrder
in interfacePayPalOrderService
- Parameters:
paymentRequest
- The gatewayPaymentRequest
containing the information necessary to construct the orderperformCheckoutOnReturn
- Indicates if we should start checkout after the user has authorized the order- Returns:
- The new
Order
-
updatePayPalOrderForFulfillment
public void updatePayPalOrderForFulfillment(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
Description copied from interface:PayPalOrderService
Updates the PayPalOrder
to be in sync with the Broadleaf order. This method should be used when fulfillment or pricing information changes afterOrder
creation. For creating an order use#createPayPalOrder(PaymentRequest, boolean)
- Specified by:
updatePayPalOrderForFulfillment
in 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:PayPalOrderService
Updates the PayPalOrder
to include the provided custom ID value.- Specified by:
updateOrderCustomId
in interfacePayPalOrderService
- Parameters:
orderId
- the primary identifier of the PayPalOrder
customId
- the value that is to be stored on the PayPalOrder
objectpaymentRequest
- The originatingPaymentRequest
-
getIntent
public String getIntent(boolean performCheckoutOnReturn, boolean capture)
-
constructPayer
protected com.paypal.orders.Payer constructPayer(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
-
getPayerEmail
@Nullable protected String getPayerEmail(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
-
constructPayee
@Nullable protected com.paypal.orders.Payee constructPayee(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
Constructions aPayee
to place on thePurchaseUnitRequest
when creating an order. This is used only for PayPal's marketplace offering.- Parameters:
paymentRequest
- The gatewayPaymentRequest
with the payment info.- Returns:
- a
Payee
to place on thePurchaseUnitRequest
or null if noMessageConstants.PAYEE_MERCHANT_ID
onPaymentRequest.getAdditionalFields()
-
constructItems
protected List<com.paypal.orders.Item> constructItems(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
-
constructShippingDetail
@Nullable protected com.paypal.orders.ShippingDetail constructShippingDetail(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
-
convertToMoney
protected Optional<com.paypal.orders.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 com.paypal.orders.Order createOrder(@NonNull @NonNull com.paypal.orders.OrderRequest orderRequest, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
-
updateOrder
protected void updateOrder(String orderId, List<com.paypal.orders.Patch> patches, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
-
constructAmountWithBreakdown
protected com.paypal.orders.AmountWithBreakdown constructAmountWithBreakdown(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
-
getCheckoutProvider
protected PayPalCheckoutProvider getCheckoutProvider()
-
getClientProvider
protected PayPalClientProvider getClientProvider()
-
getGatewayConfiguration
protected PayPalGatewayConfiguration getGatewayConfiguration()
-
getProperties
protected PayPalCheckoutApiProperties getProperties()
-
-