- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
对于成功的 paypal 交易(没有 paypal-mock-response ),以下代码没有错误。
当我在 CURLOPT_HTTPHEADER
中添加 "PayPal-Mock-Response:{\"mock_application_codes\":\"MALFORMED_REQUEST\"}"
以测试 paypal 建议的不同场景时在https://developer.paypal.com/docs/api/request-headers/#test-api-error-handling-routinescurl_error()
返回 请求的 URL 返回错误:404 Not Found
问题必须是我在 CURLOPT_HTTPHEADER
中添加 "PayPal-Mock-Response:{\"mock_application_codes\":\"MALFORMED_REQUEST\"}"
的方式,但是我还没弄明白。
paypal_button.php
<?php
define("BASE_URL", "http://my_website.com/paypal_test/");
define("PayPal_CLIENT_ID", "my_paypal_client_id");
define("PayPal_BASE_URL", "https://api.sandbox.paypal.com/v1/");
?>
<div id="paypal-button-container"></div>
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<script>
paypal.Button.render(
{
env: 'sandbox',
client: {
sandbox: '<?php echo PayPal_CLIENT_ID; ?>'
},
commit: true,
style: {
layout: 'horizontal',
fundingicons: 'true'
},
// payment() is called when the button is clicked
payment: function(data, actions)
{
// Make a call to the REST api to create the payment
return actions.payment.create({
payment: {
transactions: [
{
amount: {
total: '200',
currency: 'EUR'
}
} ]
},
experience: {
input_fields: {
no_shipping: 1
}
}
});
},
// onAuthorize() is called when the buyer approves the payment
onAuthorize: function(data, actions)
{
// Make a call to the REST api to execute the payment
return actions.payment.execute().then(function()
{
console.log('Payment Complete!');
window.location = "<?php echo BASE_URL ?>process.php?paymentID="+data.paymentID+"&payerID="+data.payerID+"&token="+data.paymentToken
});
}
}, '#paypal-button-container');
</script>
process.php
<?php
define("BASE_URL", "http://my_website.com/paypal_test/");
define("PayPal_CLIENT_ID", "my_paypal_client_id");
define("PayPal_SECRET", "my_paypal_secret");
define("PayPal_BASE_URL", "https://api.sandbox.paypal.com/v1/");
try
{
function paypalCheck($paymentID, $payerID, $paymentToken)
{
// Request Access Token
$ch = curl_init();
$clientId = PayPal_CLIENT_ID;
$secret = PayPal_SECRET;
curl_setopt($ch, CURLOPT_URL, PayPal_BASE_URL.'oauth2/token');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $clientId . ":" . $secret);
curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
if( !($result = curl_exec($ch)) ) // If curl didn't succeed
{
echo '<pre>';
echo "curl error during access token recieval = " . curl_error($curl);
echo '</pre>';
curl_close($curl);
}
else // If curl succeed get access token from result
{
$json = json_decode($result);
$accessToken = $json->access_token;
echo "access token was recieved succesfully and it is = " . $accessToken;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, PayPal_BASE_URL.'payments/payment/' . $paymentID);
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer ' . $accessToken,
'Accept: application/json',
'Content-Type: application/json',
'PayPal-Mock-Response: {\"mock_application_codes\":\"MALFORMED_REQUEST\"}'
// If we remove PayPa-Mock-Response line it works
));
if( !($response = curl_exec($curl)) ) // If curl didn't succeed
{
// The requested URL returned error: 404 Not Found
echo '<pre>';
echo "curl error = " . curl_error($curl);
echo '</pre>';
//it's empty of course
$result = json_decode($response);
echo '<pre>';
echo "result with curl error = " . $result;
echo '</pre>';
curl_close($curl);
}
else // If curl succeeded
{
$result = json_decode($response);
echo '<pre>';
print_r($result);
echo '</pre>';
$state = $result->state;
curl_close($curl);
if($state == 'approved') return true;
else return false
}
}
return false;
}
if(!empty($_GET['paymentID']) && !empty($_GET['payerID']) && !empty($_GET['token']) )
{
$paymentID = $_GET['paymentID'];
$payerID = $_GET['payerID'];
$token = $_GET['token'];
$paypalCheck=paypalCheck($paymentID, $payerID, $token);
if($paypalCheck) echo "Success";
else echo "Failure";
}
else
{
echo "Some of the get parameters are missing or are empty";
}
}
catch(Exception $e)
{
echo $e->getMessage();
}
没有 PayPal-Mock-Response 的交易中的 print_r($result) 以防有帮助:
stdClass Object
(
[id] => PAY-8JU54317DF169510YLNYKGKI
[intent] => sale
[state] => approved
[cart] => 9E037228C8147091B
[payer] => stdClass Object
(
[payment_method] => paypal
[status] => VERIFIED
[payer_info] => stdClass Object
(
[email] => shashasha@gmail.com
[first_name] => panos
[last_name] => papepis
[payer_id] => PCVE6KXLWZWV2
[shipping_address] => stdClass Object
(
[recipient_name] => panos papepis
)
[phone] => 3063691955
[country_code] => GR
)
)
[transactions] => Array
(
[0] => stdClass Object
(
[amount] => stdClass Object
(
[total] => 200.00
[currency] => EUR
[details] => stdClass Object
(
[subtotal] => 200.00
)
)
[payee] => stdClass Object
(
[merchant_id] => WLYWH4ZE3BUTW
)
[soft_descriptor] => PAYPAL *TESTFACILIT
[item_list] => stdClass Object
(
[items] => Array
(
)
[shipping_address] => stdClass Object
(
[recipient_name] => panos papepis
)
)
[related_resources] => Array
(
[0] => stdClass Object
(
[sale] => stdClass Object
(
[id] => 9MM47166KB525480R
[state] => completed
[amount] => stdClass Object
(
[total] => 200.00
[currency] => EUR
[details] => stdClass Object
(
[subtotal] => 200.00
)
)
[payment_mode] => INSTANT_TRANSFER
[protection_eligibility] => ELIGIBLE
[protection_eligibility_type] => ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE
[transaction_fee] => stdClass Object
(
[value] => 7.15
[currency] => EUR
)
[parent_payment] => PAY-8JU54317DF169510YLNYKGKI
[create_time] => 2018-08-12T21:14:55Z
[update_time] => 2018-08-12T21:14:55Z
[links] => Array
(
[0] => stdClass Object
(
[href] => https://api.sandbox.paypal.com/v1/payments/sale/9MM47166KB525480R
[rel] => self
[method] => GET
)
[1] => stdClass Object
(
[href] => https://api.sandbox.paypal.com/v1/payments/sale/9MM47166KB525480R/refund
[rel] => refund
[method] => POST
)
[2] => stdClass Object
(
[href] => https://api.sandbox.paypal.com/v1/payments/payment/PAY-8JU54317DF169510YLNYKGKI
[rel] => parent_payment
[method] => GET
)
)
[soft_descriptor] => PAYPAL *TESTFACILIT
)
)
)
)
)
[create_time] => 2018-08-12T21:14:17Z
[links] => Array
(
[0] => stdClass Object
(
[href] => https://api.sandbox.paypal.com/v1/payments/payment/PAY-8JU54317DF169510YLNYKGKI
[rel] => self
[method] => GET
)
)
)
最佳答案
根据HTTP404
和官方documentation ...
curl_setopt($curl, CURLOPT_URL, PayPal_BASE_URL.'payments/payment/' . $paymentID. '/execute');
CURLOPT_URL
似乎缺少结尾的 /execute
,作为动词。
关于 HTTP400
...可能需要先 create付款(并记住 paymentId)然后到 execute该付款 - 同时传回相应的 paymentID。
关于php - 当我在 CURLOPT_HTTPHEADER 中添加 PayPal-Mock-Response 时出现 404 curl_error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51812242/
我创建了一个用户可以添加测试的字段。这一切运行顺利我只希望当用户点击(添加另一个测试)然后上一个(添加另一个测试)删除并且这个显示在新字段中。 所有运行良好的唯一问题是点击(添加另一个字段)之前添加另
String[] option = {"Adlawan", "Angeles", "Arreza", "Benenoso", "Bermas", "Brebant
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
我正在努力将 jQuery 滚动功能添加到 nav-tab (Bootstrap 3)。我希望用户能够选择他们想要的选项卡,并在选项卡内容中有一个可以平滑滚动到 anchor 的链接。这是我的代码,可
我正在尝试在用户登录后再添加 2 个 ui 选项卡。首先,我尝试做一个之后。 $('#slideshow').tabs('remove', '4'); $("#slideshow ul li:last
我有一个包含选择元素的表单,我想通过选择添加和删除其中一些元素。这是html代码(这里也有jsfiddle http://jsfiddle.net/txhajy2w/):
正在写这个: view.backgroundColor = UIColor.white.withAlphaComponent(0.9) 等同于: view.backgroundColor = UICo
好的,如果其中有任何信息,我想将这些列添加到一起。所以说我有 账户 1 2 3 . 有 4 个帐户空间,但只有 3 个帐户。我如何创建 java 脚本来添加它。 最佳答案 Live Example H
我想知道是否有一种有效的预制算法来确定一组数字的和/差是否可以等于不同的数字。示例: 5、8、10、2,使用 + 或 - 等于 9。5 - 8 = -3 + 10 = 7 + 2 = 9 如果有一个预
我似乎有一个卡住的 git repo。它卡在所有基本的添加、提交命令上,git push 返回所有内容为最新的。 从其他帖子我已经完成了 git gc 和 git fsck/ 我认为基本的调试步骤是
我的 Oracle SQL 查询如下- Q1- select hca.account_number, hca.attribute3, SUM(rcl.extended_amou
我正在阅读 http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingG
我正在尝试添加一个“加载更多”按钮并限制下面的结果,这样投资组合页面中就不会同时加载 1000 个内容,如下所示:http://typesetdesign.com/portfolio/ 我对 PHP
我遇到这个问题,我添加了 8 个文本框,它工作正常,但是当我添加更多文本框(如 16 个文本框)时,它不会添加最后一个文本框。有人遇到过这个问题吗?提前致谢。 Live Link: JAVASCRIP
add/remove clone first row default not delete 添加/删除克隆第一行默认不删除&并获取正确的SrNo(例如:添加3行并在看到问题后删除SrNo.2)
我编码this ,但删除按钮不起作用。我在控制台中没有任何错误.. var counter = 0; var dataList = document.getElementById('materi
我有一个类似数组的对象: [1:数组[10]、2:数组[2]、3:数组[2]、4:数组[2]、5:数组[3]、6:数组[1]] 我正在尝试删除前两个元素,执行一些操作,然后将它们再次插入到同一位置。
使用的 Delphi 版本:2007 你好, 我有一个 Tecord 数组 TInfo = Record Name : String; Price : Integer; end; var Info
我使用了基本的 gridster 代码,然后我声明了通过按钮添加和删除小部件的函数它工作正常但是当我将调整大小功能添加到上面的代码中时,它都不起作用(我的意思是调整大小,添加和删除小部件) 我的js代
title 323 323 323 title 323 323 323 title 323 323 323 JS $(document).keydown(function(e){
我是一名优秀的程序员,十分优秀!