A PaymentMethod resource describes which payment method was used to fulfill a payment. It is used with a PaymentIntent to collect payments.
Creating a Payment Method
/**
* These are the required properties
* @param {Object} data The payload.
* @param {Object} data.attributes Payload attributes.
* @param {string} data.attributes.type The type of payment method. The possible value is card for now.
* @param {string} data.attributes.details.card_number Credit/Debit Card number of the PaymentMethod.
* @param {number} data.attributes.details.exp_month Expiry month of the Credit/Debit Card.
* @param {number} data.attributes.details.exp_year Expiry year of the Credit/Debit Card.
* @param {string} data.attributes.details.cvc CVC of the Credit/Debit Card.
*/
const result = await paymongo.paymentMethods.create(data);
Payload
{
data: {
attributes: {
type: 'card', // The only available type for now is 'card'.
details: {
card_number: '4343434343434345',
exp_month: 02,
exp_year: 23,
cvc: '123',
}
}
}
}
Retrieving a Payment Method
/**
* @param {string} id The PaymentMethod id
*/
const result = await paymongo.paymentMethods.retrieve(id);