Broadleaf Microservices
  • v1.0.0-latest-prod

Preparing a PaymentTransactionServices Payment for the Stripe

To execute the Stripe transactions via PaymentTransactionServices, we must first create a Payment in PaymentTransactionServices. These Payments are most commonly created during the payment stage of your checkout flow.

Before creating the Payment in PaymentTransactionServices, use Stripe.js to create the Stripe payment method. For example:

const stripeResponse = await stripe.createPaymentMethod({
        type: 'card',
        card: elements.getElement(CardNumberElement),
        billing_details
      });

const paymentMethod = stripeResponse.paymentMethod;

Then use the created payment method to provide the following properties in the request to create a Payment:

{
  ...
  gatewayType: "STRIPE",
  type: "CREDIT_CARD",
  paymentMethodProperties: {
    "PAYMENT_METHOD_ID": paymentMethod.id
  },
  isSingleUsePaymentMethod: true,
  ...
}
Note
Also see how to add a payment via the Commerce SDK.

Use the Existing Saved Payment Method from PaymentTransactionServices

Use the saved payment method to create a Payment:

{
  ...
  paymentName: savedPaymentMethod.name,
  savedPaymentMethodId: savedPaymentMethod.id,
  gatewayType: "STRIPE",
  type: "CREDIT_CARD"
  ...
}