简体   繁体   English

PayPal Rest API-将订阅添加到计费协议

[英]PayPal Rest API - add subscription to billing agreement

Not sure if what I am trying is possible or not, so asking here. 不知道我在尝试什么是可能的,所以请在这里询问。

I have a monthly recurring service that will be launched within 1 - 2 months. 我有一个每月定期服务,将在1-2个月内启动。 I would like users to register for the service and connect their PayPal account, so we know they are serious about getting the service once launched. 我希望用户注册该服务并连接其PayPal帐户,因此我们知道他们一开始就认真获取服务。

I am trying to use the REST API to create a billing agreement and, once we launch the service, add the subscription to the billing agreement. 我正在尝试使用REST API创建计费协议,一旦启动服务,就将订阅添加到计费协议中。 So far I managed to create a billing agreement and charge $0.01 one time when created. 到目前为止,我设法创建了一个结算协议,并在创建时一次收取0.01美元的费用。

What I can't seem to do is to add a subscription plan later to this agreement, or manually collect payments. 我似乎无法做的是稍后在此协议中添加订阅计划,或手动收取款项。

When trying to add a subscription, I call 尝试添加订阅时,我打电话

PATCH /v1/payments/billing-agreements/I-HD5N7C15L8E0

with this payload: 与此有效载荷:

{
    "path": "/",
    "value": {
        "plan": {
            "id": "P-70R54842DB762764NJEVCS7Y"
        },
    },
    "op": "replace"
}

and receive 并收到

Incoming JSON request does not map to API request","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST

When trying to collect the amount, I call 尝试收取金额时,我打电话给

POST /v1/payments/billing-agreements/I-HD5N7C15L8E0/set-balance

with this payload 有了这个有效载荷

{
    "value": "50",
    "currency": "USD"
}

and receive 并收到

Outstanding balance must be > 0","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#RP_INVALID_OUTSTANDING_BALANCE

At this point, I am about to give up using the REST API and use instead Express Checkout and Reference Transactions, which I understand is an alternative method to collect these payments. 在这一点上,我将放弃使用REST API,而改用Express Checkout和Reference Transactions,据我所知,Express Checkout和Reference Transactions是收集这些付款的另一种方法。

Do you know if what I am trying to achieve works with the REST API? 您知道我要实现的目标是否可以与REST API一起使用吗?

Thanks 谢谢

For your first question, you cannot change the plan on an agreement after it has been created. 对于第一个问题,您无法在协议上更改计划。 To create an agreement with a new billing plan, you need to create a new billing agreement with the plan P-70R54842DB762764NJEVCS7Y and get user's consent. 要使用新的计费计划创建协议,您需要使用计划P-70R54842DB762764NJEVCS7Y创建新的计费协议并获得用户的同意。 For your second question, set balance is a way to reset the unpaid balance on an agreement, which you can collect by using bill-balance. 对于第二个问题,设置余额是一种重置协议中未付余额的方法,您可以使用帐单余额来收取该余额。 It seems that there was no outstanding balance remaining on that account, hence the API threw an error. 该帐户似乎没有未结余额,因此API引发了错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM