如何解决在 php 中使用 Mollie API 付款时出错
我在 PHP 中使用 mollie API 进行付款。但它给了我一些错误。我已经发布了我的代码和错误截图。
这是我的代码:
<?PHP
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(E_ALL);
try {
require_once "vendor/autoload.PHP";
$mollie = new \Mollie\Api\Mollieapiclient();
$mollie->setApiKey("test_XXXX");
$orderId = time();
$amount = $_POST['amount'];
$payment = $mollie->payments->create([
"amount" => [
"currency" => "EUR","value" => "$amount",// You must send the correct number of decimals,thus we enforce the use of strings
],"description" => "Order #{$orderId}","redirectUrl" => "https://example.com/Mollie/return/".$orderId."/","webhookUrl" => "https://example.com/Mollie/webhook/","Metadata" => [
"order_id" => $orderId,],]);
print_r($payment);
$payment_data = array(
'payment_id' => $payment->id,'user_id' => $_POST['user_id'],'order_id' => $orderId,'mode' => $payment->mode,'description' => $payment->description,'status' => $payment->status,'added_date' => date('Y-m-d'),'added_time' => date('H:i:s')
);
print_r($payment_data);
header("Location: " . $payment->getCheckoutUrl(),true,303);
} catch (\Mollie\Api\Exceptions\ApiException $e) {
echo "API call Failed: ". htmlspecialchars($e->getMessage());
}
屏幕截图:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。