Stripe Checkout PHP API 获取 500 内部服务器错误

编程入门 行业动态 更新时间:2024-10-21 15:55:31
本文介绍了Stripe Checkout PHP API 获取 500 内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是我的情况,我正在使用 Stripe PHP Api 实现自定义 Stripe Checkout.

Here is my situation, i'm implementing Custom Stripe Checkout with Stripe PHP Api.

我已经请求了一个像这样使用 jquery 的 post 方法 >

I have requested a post Method using jquery like this one >

var handler = StripeCheckout.configure({ key: 'pk_test_yGQM97VuEUdttuOOFQcyaPHW', image: 'stripe/img/documentation/checkout/marketplace.png', locale: 'auto', token: function (token) { // You can access the token ID with `token.id`. // Get the token ID to your server-side code for use. $.post( 'charge.php', { sT: token.id, sE: token.email }, function (data) { console.log(data); } ); } }); var thePayment = document.getElementById('pay-amount'); if (thePayment) { thePayment.addEventListener('click', function (e) { var desc = $('#pay-amount').attr('data-desc'); var amount = Number($('#pay-amount').attr('data-amount')); var email = $('#pay-amount').attr('data-email'); // Open Checkout with further options: handler.open({ name: 'Test', description: desc, amount: amount, email: email, allowRememberMe: false }); e.preventDefault(); }); } // Close Checkout on page navigation: window.addEventListener('popstate', function () { handler.close(); });

PHP 方面就是这样的 >

And the PHP side is just like this one >

require_once('html/includes/vendor/autoload.php'); $stripe = array( "secret_key" => "sk_test_nJxSc9Yw716tLBWTa9HHMxhj", "publishable_key" => "pk_test_yGQM97VuEUdttuOOFQcyaPHW" ); $charge_reply = array(); \Stripe\Stripe::setApiKey($stripe['secret_key']); if ($_SERVER['REQUEST_METHOD'] === 'POST') { $token = $_POST['sT']; $email = $_POST['sE']; $customer = \Stripe\Customer::create(array( 'email' => $email, 'source' => $token )); $charge = \Stripe\Charge::create(array( "amount" => 1000, "currency" => "usd", "source" => $customer->id, "email" => $email, "description" => "Example charge" )); $charge_reply[] = [ 'token' => $token, 'email' => $email ]; sendJson($charge_reply); return; }

我还启用了 php 中的 curl、json、mbstring.但是在向charge.php请求post方法后接受的函数,在控制台日志中打印POST example/charge.php 500 (Internal Server Error).

I have also enabled the curl,json,mbstring in php. But the function that accepts after requesting a post method to the charge.php, prints POST example/charge.php 500 (Internal Server Error) in the console log.

有什么办法可以解决这个问题吗?

So is there any way i can fix this?

推荐答案

500(内部服务器错误)是您的代码中的错误,这意味着它们是一个致命错误.

500 (Internal Server Error) is something wrong in your code which means their is a fatal error.

要查找错误,您应该在页面顶部使用以下代码.

To find the error you should use below code in your top of the page.

ini_set('display_errors',1); error_reporting(E_ALL);

它将返回确切的错误以便修复它.

It will return the exact error so can fix it.

注意:请勿在本地开发的生产环境中使用它.

Note: Do not use it in production environment this for your local development.

更多推荐

Stripe Checkout PHP API 获取 500 内部服务器错误

本文发布于:2023-11-26 18:21:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634673.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   服务器   Checkout   Stripe   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!