gpt4 book ai didi

php - 如何在paypal sdk php中支付失败

转载 作者:太空宇宙 更新时间:2023-11-03 15:49:47 25 4
gpt4 key购买 nike

我正在尝试在沙盒中进行付款,但会失败。

我在 paypal 文档上发现您可以在金额上输入错误代码,您将收到失败的付款。但不幸的是它不起作用。

我想对此进行测试,看看如果付款失败,我的应用程序会如何表现

如果付款不成功,我的应用程序将重定向到带有 session 的主页


if ($result->getState() == 'approved') {
//MY DB LOGIC

}
else{

return redirect('/home')->with('error','Payment failed');
}

我在 Laravel 中使用 paypal-php-sdk

知道这是否可以实现吗?

最佳答案

所以这里有几件事要检查:

  • 您是否在您的沙盒帐户 (as described here) 中启用了负面测试?
  • 您是否符合以下条件?

    Negative testing can be used with Classic PayPal API versions 2.4 and later. And also note that negative testing is only available for business accounts.

  • 您是否以正确的格式指定了预期的错误代码?

    To trigger an error condition on an amount-related field, specify a error code value as a number with two digits to the right of the decimal point. For example, specify a value of 107.55 to trigger the 10755 error.

关于php - 如何在paypal sdk php中支付失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57737509/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com