當用戶在我的網站上升級訂閱時,我接觸到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