【问题标题】:How to create a required property and used it for an API?如何创建所需的属性并将其用于 API?
【发布时间】: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


【解决方案1】:

https://developers.paymongo.com/docs/accepting-cards 提供了关于如何在 Paymongo 上设置信用卡付款的非常好的指南。

简单地说,您必须从前端收集信用卡数据并创建付款方式和付款意图。 然后,将付款方式附加到付款意图,包括重定向 URL。您将收到一个 URL,然后您应该将用户重定向到该 URL。用户授权付款后,他将被重定向到您在将方法附加到付款意图时所包含的 URL。

您需要的所有端点都在这里https://developers.paymongo.com/reference

【讨论】:

    猜你喜欢
    • 2015-12-22
    • 2016-01-17
    • 1970-01-01
    • 1970-01-01
    • 2021-06-22
    • 1970-01-01
    • 2017-02-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多