Payments service wrapping Stripe PaymentIntents.
const payment = await stripe.payments.create({ amount: 1000, // $10.00 in cents currency: 'usd', paymentMethod: 'pm_card_visa', confirm: true,}); Copy
const payment = await stripe.payments.create({ amount: 1000, // $10.00 in cents currency: 'usd', paymentMethod: 'pm_card_visa', confirm: true,});
Cancel a payment.
PaymentIntent ID to cancel
The cancelled PaymentIntent
const payment = await stripe.payments.cancel('pi_123'); Copy
const payment = await stripe.payments.cancel('pi_123');
Capture a payment that was authorized with capture_method: manual.
capture_method: manual
PaymentIntent ID to capture
The captured PaymentIntent
const payment = await stripe.payments.capture('pi_123'); Copy
const payment = await stripe.payments.capture('pi_123');
Create a payment (PaymentIntent).
Payment creation options
Created PaymentIntent
When input validation fails
When the card is declined
const payment = await stripe.payments.create({ amount: 1000, currency: 'usd', customerId: 'cus_123', paymentMethod: 'pm_card_visa', confirm: true,}); Copy
const payment = await stripe.payments.create({ amount: 1000, currency: 'usd', customerId: 'cus_123', paymentMethod: 'pm_card_visa', confirm: true,});
Retrieve a payment by ID.
PaymentIntent ID
The PaymentIntent
const payment = await stripe.payments.get('pi_123'); Copy
const payment = await stripe.payments.get('pi_123');
List payments with cursor-based pagination.
Optional
List options
Payments and a cursor for the next page
const page1 = await stripe.payments.list({ limit: 20 });const page2 = await stripe.payments.list({ startingAfter: page1.nextCursor }); Copy
const page1 = await stripe.payments.list({ limit: 20 });const page2 = await stripe.payments.list({ startingAfter: page1.nextCursor });
Payments service wrapping Stripe PaymentIntents.
Example