Skip to main content

Attach payment method to a payment intent

Attach a payment method resource to a payment intent resource.

This endpoint is normally used to charge a customer using their saved payment method. Please refer to this guide for more details.


Endpoint

POST /payment_intents/:id/attach

Sample code

const client = require('payrex-node')('insert your PayRex Secret API key.');

const paymentIntent = await client.paymentIntents.attach(
// Payment intent ID where the payment method will be attached to.
'<ID of a payment intent resource>',
{
payment_method_id: '<insert payment method id>',
}
)

Parameters

id REQUIRED

The id of the payment intent where the payment method id will be attached


payment_method_id REQUIRED

The payment method ID to be attached to the payment intent


Returns

Returns a Payment Intent resource.