我正在使用Braintree SDK在沙箱PayPal测试我的代码。我可以在客户端设置一个金额,例如 10 美元,客户可以继续进行结帐过程。
但是在服务器端,收到"nonce"代码后,我可以向客户端收取200美元,并且没有错误或验证。
如果开发商决定收取的费用高于结账时所说的费用,什么可以保护买家免于多付?
在客户端,我发送了"授权"的意图选项,但如果我愿意,我仍然可以向买家多收费用。
客户端代码
paypal.Button.render({
braintree: braintree,
client: {
sandbox: '{{$btClientToken}}'
},
env: 'sandbox',
commit: true,
payment: function (data, actions) {
return actions.braintree.create({
flow: 'checkout', // Required
intent:'authorize',
amount: '10', // Required
currency: 'USD', // Required
displayName: 'test dispaly name',
description: 'test description',
lineItems:[
{
quantity:'1',
unitAmount:'10',
totalAmount: '10',
name:'line item test',
description:'test description',
kind:'debit'
}
]
});
},
onAuthorize: function (payload) {
console.log(payload);
$.ajax({
method:'POST',
data:{
_token: '{{ csrf_token() }}',
payment_method_nonce: payload.nonce,
uid: '{{$uid}}',
order_id:payload.orderID,
payer_id:payload.payerID,
payment_token: payload.paymentToken
},
url:'{{url("cart/order/nonce")}}'
}).done((reply)=>{
console.log(reply);
});
},
}, '#paypal-pay');
服务器端代码
$result = $gateway->transaction()->sale([
'amount' => '200.00',
'paymentMethodNonce' => $nonce,
'descriptor' => [
'name' => 'company name*myurl.com'
],
'options' => [
'submitForSettlement' => True,
"paypal" => [
"description" => $order->title
],
],
'lineItems' => [
[
'description' => 'TEST DESCRIPTION',
'name' => 'TEST NAME',
'quantity' => '1',
'unitAmount' => '200.00',
'totalAmount' => '200.00',
'kind' => 'debit'
]
]
]);
我成功交易,卖家控制面板中收到 200 美元的金额。
大多数消费者保护法都允许消费者在你错误地向他们收取费用时向你追回他们的钱,如果你系统地这样做,贸易标准机构可能会对你采取行动。
PayPal本身还将通过买家保护保证提供保护,这意味着如果商家自己不退款,消费者可以直接从PayPal取回他们的钱。
编辑
@Grumpy很好地指出,PayPal很可能会在几笔交易后阻止或禁止您的帐户。