当用户在我的网站上升级订阅时,我接触到IPN,然后我想使用PHP联系贝宝以取消任何现有的订阅他们可能有。我该怎么做呢?我只能找到如何使用用户必须点击的按钮。如何使用PHP自动取消订阅用户(当他们升级到不同的订阅时)
2
A
回答
1
这是最好的解决方案,我发现:
/**
* Performs an Express Checkout NVP API operation as passed in $action.
*
* Although the PayPal Standard API provides no facility for cancelling a subscription, the PayPal
* Express Checkout NVP API can be used.
*/
function change_subscription_status($profile_id, $action) {
$api_request = 'USER=' . urlencode('api_username')
. '&PWD=' . urlencode('api_password')
. '&SIGNATURE=' . urlencode('api_signature')
. '&VERSION=76.0'
. '&METHOD=ManageRecurringPaymentsProfileStatus'
. '&PROFILEID=' . urlencode($profile_id)
. '&ACTION=' . urlencode($action)
. '&NOTE=' . urlencode('Profile cancelled at store');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api-3t.sandbox.paypal.com/nvp'); // For live transactions, change to 'https://api-3t.paypal.com/nvp'
curl_setopt($ch, CURLOPT_VERBOSE, 1);
// Uncomment these to turn off server and peer verification
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
// curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
// Set the API parameters for this transaction
curl_setopt($ch, CURLOPT_POSTFIELDS, $api_request);
// Request response from PayPal
$response = curl_exec($ch);
// If no response was received from PayPal there is no point parsing the response
if(! $response)
die('Calling PayPal to change_subscription_status failed: ' . curl_error($ch) . '(' . curl_errno($ch) . ')');
curl_close($ch);
// An associative array is more usable than a parameter string
parse_str($response, $parsed_response);
return $parsed_response;
}
例子:
change_subscription_status('I-NARPL1C00000', 'Cancel');
我希望它能帮助
+0
很酷!我现在没有一个活跃的项目来测试,但很高兴知道现在有一个解决方案。你有没有做任何不同的事情使用NVP API,或者你可以使用标准的API,除了这个功能(来自没有NVP经验的人) – 2014-12-23 18:07:42
+1
@SabrinaGelbart真诚的,我还没有使用这个API的任何更多的东西。我只是在寻找解决方案,我很幸运地找到了这个博客。 在这里,你有所有的NVP可用的方法及其文档的API参考:https://developer.paypal.com/webapps/developer/docs/classic/api/ 希望得到这个帮助! – 2014-12-23 21:11:07
相关问题
- 1. 动态订阅/取消订阅活动
- 2. 如何升级/降级iOS自动续订订阅
- 3. 取消订阅普通类别的用户,如果他们在Simplenews取消订阅其他类别
- 4. 订阅取消订阅()
- 5. 如何取消订阅socket.io订阅?
- 6. 如何取消订阅Weak订阅MvvmCross
- 7. 如何取消订阅NServiceBus订阅?
- 8. Azure订阅升级
- 9. PayPal订阅升级
- 10. 取消订阅/订阅活动危险?
- 11. 订阅和取消订阅活动
- 12. 如何在用户订阅和取消订阅时获取Youtube API通知?
- 13. 用户升级时取消PayPal订购
- 14. 取消订阅socket.io中的订阅
- 15. 何时取消订阅
- 16. 如何知道频道何时订阅/取消订阅socket.io
- 17. 通过订阅和取消订阅用户循环
- 18. Ionic 2:呼叫事件同时订阅和取消订阅
- 19. 如何通过WooCommerce订阅获取特定用户的订阅?
- 20. RxJava:不会调用订阅的取消订阅()方法
- 21. nservicebus取消订阅我们希望订阅的内容
- 22. Rxjs - 重新订阅取消订阅Observable
- 23. 订阅/取消订阅VS Create/TakeUntil?
- 24. SerialPort.DataReceived重复订阅/取消订阅
- 25. iOS:如何订阅客户以进行自动更新订阅
- 26. GAE取消订阅用户的存在
- 27. Firebase如何取消订阅
- 28. 如何取消FirebaseObjectObservable订阅?
- 29. rxpy如何取消订阅
- 30. 在用户验证后使用spotify api管理spotify订阅(取消,升级)
网站付款标准版或专业版? – Yaniro 2012-04-22 10:15:39
网站付款标准 – 2012-04-22 14:38:26
那么,据我所知,你不能自动做到这一点,你只能将用户重定向到他/她的PayPal帐户,并让他/她手动取消订阅(不幸的是,这是我的现在就做吧......) – Yaniro 2012-04-22 14:40:25