什么是JSON支付paypal定义的简单,最小的例子?

时间:2017-09-29 11:22:32

标签: javascript json node.js paypal payment

我正在寻找一个付费的PayPal定义的简单JSON示例。这似乎没有在PayPal文档中涵盖。它需要一个简单的参数来指定付款的具体日期,并且可以选择每年在此日期重复出现。我尝试了以下方法,但它不允许付款日期或重复发生。需要添加什么?

var create_payment_json = {
    "intent": "sale",
    "payer": {
        "payment_method": "paypal"
    },
    "redirect_urls": {
        "return_url": "http://return.url",
        "cancel_url": "http://cancel.url"
    },
    "transactions": [{
        "item_list": {
            "items": [{
                "name": "item",
                "sku": "item",
                "price": "1.00",
                "currency": "USD",
                "quantity": 1
            }]
        },
        "amount": {
            "currency": "USD",
            "total": "1.00"
        },
        "description": "This is the payment description."
    }]
};

谢谢

2 个答案:

答案 0 :(得分:1)

没有此类参数可以控制付款是否经常发生,或者将来会以某种方式捕获或收取费用

为了实现 Stripe 中的可能性,你需要做不同的工作。

定期结算

适用于later capture

  • 创建类型授权付款
  • 存储响应中返回的捕获URL

    请注意捕获网址在一段时间内处于活动状态。如果在该段时间内未获得付款,则可以通过重新授权付款一次刷新此捕获网址

    可悲的是, Paypal 没有提供API来自动捕获付款,以后您可以指定 Stripe 这样做。您有责任确保这一点。

    但是,有一些服务集成可以扩展Paypal以提供此功能,请参阅Braintree Vault for Paypal )。

答案 1 :(得分:0)

您可以在Paypal official documentation中找到与Json一起的体面示例。

以下是基于官方PayPal payment page的示例。

curl -v -X POST https://api.sandbox.paypal.com/v1/payments/payment \
-H "Content-Type:application/json" \
-H "Authorization: Bearer Access-Token" \
-d '{
  "intent": "sale",
  "payer": {
    "payment_method": "paypal"
  },
  "transactions": [
    {
      "amount": {
        "total": "30.11",
        "currency": "USD",
        "details": {
          "subtotal": "30.00",
          "tax": "0.07",
          "shipping": "0.03",
          "handling_fee": "1.00",
          "shipping_discount": "-1.00",
          "insurance": "0.01"
        }
      },
      "description": "This is the payment transaction description.",
      "custom": "EBAY_EMS_SOMENUMBER",
      "invoice_number": "INV000001",
      "payment_options": {
        "allowed_payment_method": "INSTANT_FUNDING_SOURCE"
      },
      "soft_descriptor": "ECHI5786786",
      "item_list": {
        "items": [
          {
            "name": "dontation",
            "description": "dontation",
            "quantity": "1",
            "price": "10",
            "tax": "0.00",
            "sku": "1",
            "currency": "USD"
          }
        ]
      }
    }
  ],
  "note_to_payer": "Thankyour for your donation.",
  "redirect_urls": {
    "return_url": "https://example.com",
    "cancel_url": "https://example.com"
  }
}