【发布时间】:2021-05-23 09:27:10
【问题描述】:
我是使用 API 的新手,我目前正在建立一个网站,我想接受付款,我得到了文档,但我怎样才能以简单和菜鸟的方式做到这一点?比如我如何以及在哪里放置有效负载以及如何访问所述有效负载?提前谢谢大家
用法
import Paymongo from 'paymongo';
// Retrieve the secret key from your paymongo
// dashboard under developers tab.
const paymongo = new Paymongo(process.env.SECRET_KEY);
付款方式 - 创建
/**
* 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);
有效载荷
{
data: {
attributes: {
type: 'card' // The only available type for now is 'card'.
details: {
card_number: '000000000000',
exp_month: 02,
exp_year: 23,
cvc: '123',
}
}
}
}
【问题讨论】:
-
负载不是你收到的东西。但是你发送的东西。这是您的用户在付款时输入表单的信用卡数据。当支付提供商验证时,结果包含有关支付是否被接受的信息。不过,您最好的办法是使用 paymongo 文档。
标签: node.js