const stripeResponse = await stripe.createPaymentMethod({
type: 'card',
card: elements.getElement(CardNumberElement),
billing_details
});
const paymentMethod = stripeResponse.paymentMethod;
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. |