它说可以使用他们的 API 取消 PayPal 订阅。知道 SubscriptionId 谁能给我一些代码示例如何做到这一点?
非常感谢。
它说可以使用他们的 API 取消 PayPal 订阅。知道 SubscriptionId 谁能给我一些代码示例如何做到这一点?
非常感谢。
您是否设法找到了一个简单的解决方案?我也在找这个。谢谢!
更新:搜索后,“ManageRecurringPaymentsProfileStatus”通过一个简单的 POST 请求非常易于使用。
确保您的用户、密码或签名不可见(换句话说,在您的服务器上执行此操作,而不是通过 javascript 或 html 帖子在您的客户端上执行此操作)。
下面是一个简单的 Python 工作示例。它有效,我现在每天都在使用它。
import urllib
from google.appengine.api import urlfetch
form_fields = {
"METHOD": "ManageRecurringPaymentsProfileStatus",
"PROFILEID": "xxx", # put your subscription ID here
"ACTION": "cancel",
"USER": "xxx", # Get USER, PWD, and SIGNATURE from your Paypal's account preferences
"PWD": "xxx",
"SIGNATURE": "xxx",
"VERSION": "54.0"
}
api_url = 'https://api-3t.sandbox.paypal.com/nvp' # remove the sandbox part for production
form_data = urllib.urlencode(form_fields)
result = urlfetch.fetch(url=api_url,
payload=form_data,
method=urlfetch.POST,
headers={'Content-Type': 'application/x-www-form-urlencoded'})
响应是一个如下所示的字符串:
TIMESTAMP=2011%2d01%2d28T14%3a47%3a45Z&CORRELATIONID=148ebe1d25566&ACK=Failure&VERSION=54%2e0&BUILD=1704252&L_ERRORCODE0=11552&L_SHORTMESSAGE0=Invalid%20profile%20ID&L_LONGMESSAGE0=The%20profile%20ID%20is%20invalid&L_SEVERITYCODE0=Error
“ACK”字段表示“失败”或“成功”。
在回答下面的评论时,请注意它确实使我能够取消通过动态创建的链接创建的订阅,例如:
<a href="https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick-subscriptions&business=llcpro_1295263400_biz%40jeregle.com&item_name=Abonnement%20mensuel&a3=41.86&t3=M&p3=1&src=1&sra=1¤cy_code=EUR&no_note=1&no_shipping=1&lc=FR&custom=xxxxx¬ify_url=https%3A%2F%2Fyournotifyurl.com%2Fipn&charset=utf-8&country=FR&a1=0&t1=D&p1=31" target="_blank">Subscribe</a>
请注意,我根本不使用“修改”标志。