The Payment JS SDK was introduced to make integrating with Payment Gateways easier from a JS frontend client. A number of hooks and utilities were moved out of this starter and into the new SDK so that other projects could make use of them. See the Payment JS SDK docs.
1.4.0 also saw the introduction of the PaymentTransactionService to manage payments and transactions securely and in a centralized location.
This means that payments no longer live on Carts and Orders but in a separate service.
Along with that, a PaymentClient
was added to the @broadleaf/commerce-cart
SDK, and, if you’re using React, you can interact with it through pre-made hooks in the new @broadleaf/payment-react
SDK: useResolvePayments
, useSubmitPaymentRequest
, useCreatePayment
, and useUpdatePayment
.
useSubmitPaymentRequest
combines useCreatePayment
, and useUpdatePayment
to automatically determine whether to update the current payment related to the cart or to create a new one.
We also added a PaymentsContext
to store the state of payments related to the current cart.
Made use of new fields on PaymentRequest
name
: A display name for the payment. This replaces uses of attributes
to store the same information.
subtotal
: The total, usually excluding adjustments, tax, and fulfillment, covered by this payment.
adjustmentsTotal
: The adjustments (a.k.a discounts) total, usually excluding fulfillment discounts, covered by this payment.
fulfillmentTotal
: The fulfillment cost covered by this payment.
taxTotal
: The tax covered by this payment.
isSingleUsePaymentMethod
: Whether the underlying payment method can only be used once.
In most cases the payment request is converted into a single-use token.
Therefore, we will need to archive the payment and create new one if the payment amount changes after a successful transaction like authorization.
paymentMethodProperties
replaces paymentGatewayProperties
displayAttributes
: Replaces using attributes
to store display information for the card during checkout if name is insufficient.