php - 完成当前周期后取消贝宝订阅
问题描述
function change_subscription_status( $profile_id, $action ) {
$api_username = 'xxxxxxxxxxxxxxxxxxxxxxxxx';
$api_password = 'xxxxxxxxxxxxxxxxxxx';
$api_signature = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$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, TRUE );
//curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, TRUE );
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 );
echo "<pre>";
print_r($parsed_response);
echo "</pre>";
//return $parsed_response;
}
change_subscription_status( 'I-ASLDBP8A3W1T', 'Cancel' );
此代码立即取消订阅,但我想在完成当前订阅周期后停止订阅。
解决方案
推荐阅读
- react-native - 从异步存储中删除项目不起作用
- admin-on-rest - 如何从自定义组件中获取数据?
- reactjs - 在 React rnd 中重新调整 Google 图表的大小
- javascript - 为什么在 Javascript (1,2) 中等于 2?
- jpa - 从 Spring JPA 中的方法名称创建查询
- javascript - 将现有 div 放入 DOM div?
- java - 得到这个错误 org.json.JSONException: Value at 0 of type java.lang.String cannot be convert to JSONObjecton parsing
- r - 在R中的数字序列中查找具有特定长度的所有子序列
- flutter - 对我的颤振代码中的路由代码有任何疑问吗?
- javascript - 在正则表达式中是否可以允许 0 到 2 之间的浮点数?