【发布时间】:2019-12-02 09:01:43
【问题描述】:
我正在尝试使用 curl 设置我的三个订阅,并确保值正确。尝试发出请求并获得响应,但我的 curl 无法正常运行。
https://developer.paypal.com/docs/api/subscriptions/v1/#plans_create
我的意图:
3 种计划可供选择:Elite(149 PHP/月)、Premium(349 PHP/月)、Luxury(549 PHP/月)
paypal 说 1 个月是 30 天
id 喜欢将其设置为每月自动续订,直到客户选择取消。
-
一次只有一个处于活动状态,如果用户在其中一个运行时选择了三个中的另一个,则他们将自动停止计费,并将使用所选的新的进行收费。 (如:目前为elite149,选择后订阅和续费将更改为549luxury)。
curl -v -X POST https://api.sandbox.paypal.com/v1/billing/plans \ -H "Content-Type: application/json" \ -H "Authorization: Basic account_clientid:account_secretcode" \ -H "PayPal-Request-Id: EPL-25012019-001" \ -d '{ "product_id": "MWC-2019EPL", "name": "My White Card Subscription Plans", "description": "MyWhiteCard Membership Levels", "status": "ACTIVE", "billing_cycles": [ { "frequency": { "interval_unit": "MONTH", "interval_count": 1 }, "tenure_type": "REGULAR", "sequence": 1, "total_cycles": 999, "pricing_scheme": { "fixed_price": { "value": "149", "currency_code": "PHP" } } }, { "frequency": { "interval_unit": "MONTH", "interval_count": 1 }, "tenure_type": "REGULAR", "sequence": 2, "total_cycles": 999, "pricing_scheme": { "fixed_price": { "value": "349", "currency_code": "PHP" } } }, { "frequency": { "interval_unit": "MONTH", "interval_count": 1 }, "tenure_type": "REGULAR", "sequence": 3, "total_cycles": 999, "pricing_scheme": { "fixed_price": { "value": "549", "currency_code": "PHP" } } } ], "payment_preferences": { "auto_bill_outstanding": true, "setup_fee": { "value": "0", "currency_code": "PHP" }, "setup_fee_failure_action": "CONTINUE", "payment_failure_threshold": 3 }, "taxes": { "percentage": "10", "inclusive": false } }' 我刚刚取出了我帐户的 client_id:secret
- 正在使用实时凭据
我的问题和疑虑:
- 在访问令牌中,是否需要输入“access_token$production$”,然后输入给定的代码?
- 我可以手动创建 Paypal 请求 ID 和产品 ID 吗?
- 计费周期是否都在同一个命令上,还是我必须触发 3 次?
- 如果客户订阅,安装费是否收费?我首先假设是这种情况并将其设置为 0。
- 我的目的是让每月订阅(30 天)自动续订,直到用户取消订阅。我将示例设置为 12,但
"total_cycles": NEVER会是正确的输入吗? - 我不确定税收部分是如何运作的,为什么我要修改它?
其他问题:
- 该文档没有显示链接
https://api.sandbox.paypal.com/v1/billing/plans的实时等效项,它只是简单的https://api.live.paypal.com/v1/billing/plans? - 我尝试使用 git bash 和 curl 添加上面的代码,但是当我运行它时它显示
1008{"error":"invalid_client","error_description":"Client credentials are missing"} - 我是否尝试在 Git bash 中运行 curl 代码而不更改我的目录?我只是在这里启动 git 并运行 curl:
任何帮助将不胜感激。我只是确保一切都是需要的,因为这三个订阅将进入一个实时网站。我必须确定一次只运行一个订阅。
更新:我尝试将其设为curl -v -X POST https://api.production.paypal.com/v1/billing/plans,但这个也不起作用。
更新:谁能展示一个有效的 curl 示例请求示例?
更新:-H "Authorization: Basic account_clientid:account_secretcode",为了清楚起见,我在那里拿出了我的 id 代码,因为我不能只在公共场合展示它。我放在那里的一个例子是
-H "Authorization: Basic JAKRc85nJy2eMLq3aIV:01PvLC934xMAwLHqU4JqA89as4N"
更新 到目前为止,我尝试在 git 中运行这个 curl,但不知何故,我仍然得到错误。我确保 api 在 api.paypal.com 中,并且客户端 ID 和机密 ID 是实时版本。
curl -v -X POST https://api.paypal.com/v1/billing/plans \
-H "Content-Type: application/json" \
-H "Authorization: Basic AR7nnwwotKOt4YdcGHZc0P2RVsRT67_Gf2hyrKyDl3ZgCKsikeKbXdQ9Fj-_21v4RulkXsgAASe7_VKv:EKwsdDo1ehtOOOSZCGMu1C9903qr4cQOOZI2rgFYhvugh2SO1V04q9MWY9SXwa352zBt1mGglLuWgR4D" \
-H "PayPal-Request-Id: MWC-2501E-001" \
-d '{
"product_id": "ELITE-2501149",
"name": "Elite Membership",
"description": "Elite Membership Monthly Plan",
"status": "ACTIVE",
"billing_cycles": [
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "REGULAR",
"sequence": 1,
"total_cycles": 999,
"pricing_scheme": {
"fixed_price": {
"value": "149",
"currency_code": "PHP"
}
}
}
],
"payment_preferences": {
"auto_bill_outstanding": true,
"setup_fee": {
"value": "0",
"currency_code": "PHP"
},
"setup_fee_failure_action": "CONTINUE",
"payment_failure_threshold": 3
},
"taxes": {
"percentage": "12",
"inclusive": false
}
}'
我得到这个错误:
100 921 100 159 100 762 99 478 0:00:01 0:00:01 --:--:-- 578{"name":"INTERNAL_SERVICE_ERROR","debug_id":"1975a4fe9232","links":[{"href":"https://developer.paypal.com/docs/api/overview/#error","rel":"information_link"}]}
更新
阅读所有链接并按照步骤操作,我认为这是剩下的唯一问题
{"name":"NOT_AUTHORIZED","message":"Authorization failed due to insufficient permissions.","debug_id":"484a9d7460069","details":[{"issue":"PERMISSION_DENIED","description":"You do not have permission to access or perform operations on this resource"}],"links":[{"href":"https://developer.paypal.com/docs/api/v1/billing/subscriptions#NOT_AUTHORIZED","rel":"information_link","method":"GET"}]}
我查看了 Paypal 帮助中心,似乎我需要 Paypal 本身的某个人来授权我的 REST。
【问题讨论】:
-
您能否添加更多有关您尝试集成的特定 PayPal 产品的信息?上面的脚本在什么时候崩溃了?
-
当我尝试在我的 git bash 中触发此脚本时,它是一个基于订阅的计划。 developer.paypal.com/docs/api/subscriptions/v1/#plans_create我已经在问题中解释过了。
-
它发生故障并在我的 bash 中出现错误
-
关于您的问题 #8 - 您可能忘记声明
account_clientid和account_secret -
我无法在公共场合准确地显示我的实际客户 ID 和机密 ID,所以我只是为了这篇文章而把它拿出来。