我正在使用Paypal PLus iframe,我想执行一项功能,当使用没有资金的卡付款或取消该卡时,除了付款外,不付款并重新加载iframe用户尝试使用另一张卡。
我拥有的代码如下:
Executepayment.php
$url = $host.'/v1/payments/payment/'.$paymentID.'/execute/';
$execute = '{"payer_id" : "'.$payerId.'"}';
$json_resp = make_post_call1($url, $execute);
$json_resp = stripslashes(json_format($json_resp));
Functions.php
//此功能进行POST调用
function make_post_call1($url, $postdata) {
global $access_token;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_SSL_CIPHER_LIST,'TLSv1');
curl_setopt($curl, 1, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer '.$access_token,
'PayPal-Mock-Response: {"mock_application_codes":"CREDIT_CARD_REFUSED"}',
'Content-Type: application/json'
));
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($curl, CURLOPT_VERBOSE, TRUE);
$response = curl_exec( $curl );
if (empty($response)) {
// some kind of an error happened
die(curl_error($curl));
curl_close($curl); // close cURL handler
} else {
$info = curl_getinfo($curl);
curl_close($curl); // close cURL handler
if($info['http_code'] != 200 && $info['http_code'] != 201 ) {
echo "Received error: " . $info['http_code']. "\n";
echo "Raw response:".$response."\n";
die();
}
}
// Convert the result from JSON format to a PHP array
$jsonResponse = json_decode($response, TRUE);
return $jsonResponse;
}
感谢您的贡献!