你如何通过他们的api取消PayPal订阅?

Ant*_*ony 12 paypal-subscriptions

在此页面上:https: //cms.paypal.com/us/cgi-bin/?cmd = _render-content&content_ID = developer/e_howto_api_ECRecurringPayments

它说可以使用他们的API取消PayPal订阅.知道SubscriptionId可以有人给我一些代码示例如何做到这一点?

非常感谢.

Lou*_* LC 15

您是否设法找到一个简单的解决方案?我也在寻找这个.谢谢!

更新:搜索后,"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'})
Run Code Online (Sandbox Code Playgroud)

响应是一个如下所示的字符串:

TIMESTAMP = 2011%2D01%2d28T14%3a47%3a45Z&的correlationID = 148ebe1d25566&ACK =失败&VERSION = 54%2E0&BUILD = 1704252&L_ERRORCODE0 = 11552&L_SHORTMESSAGE0 =无效%20profile%20ID&L_LONGMESSAGE0 =该%20profile%20ID%图20是%20invalid&L_SEVERITYCODE0 =错误

"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&currency_code=EUR&no_note=1&no_shipping=1&lc=FR&custom=xxxxx&notify_url=https%3A%2F%2Fyournotifyurl.com%2Fipn&charset=utf-8&country=FR&a1=0&t1=D&p1=31" target="_blank">Subscribe</a>

请注意,我根本不使用"修改"标志.