Php 带条纹的充电卡

Php 带条纹的充电卡,php,stripe-payments,Php,Stripe Payments,一切都在条带中正常工作-生成令牌,写入我的仪表板中的“日志”部分,等等。但是不收费。即使我完成了Stripe文档给出的所有错误处理,我也没有从Stripe或我的代码中得到任何错误。我怎样才能纠正这个问题 require_once ("vendor/autoload.php"); if ($_POST) { echo "catch if"; // Set your secret key: remember to change this to your live secret key in

一切都在条带中正常工作-生成令牌,写入我的仪表板中的“日志”部分,等等。但是不收费。即使我完成了Stripe文档给出的所有错误处理,我也没有从Stripe或我的代码中得到任何错误。我怎样才能纠正这个问题

require_once ("vendor/autoload.php");

if ($_POST) {
 echo "catch if";

 // Set your secret key: remember to change this to your live secret key in production
 // See your keys here: https://dashboard.stripe.com/account/apikeys

 StripeStripe::setApiKey("myApyKey");

 // Get the credit card details submitted by the form

 $token = $_POST['stripeToken'];

 // Create a charge: this will charge the user's card

 try {
  echo "charging";
  $charge = StripeCharge::create(array(
   "amount" => 1000, // Amount in cents
   "currency" => "eur",
   "source" => $token,
   "description" => "Example charge"
  ));
 }

 catch(StripeErrorCard $e) {

  // Since it's a decline, \Stripe\Error\Card will be caught

  $body = $e->getJsonBody();
  $err = $body['error'];
  print ('Status is:' . $e->getHttpStatus() . "\n");
  print ('Type is:' . $err['type'] . "\n");
  print ('Code is:' . $err['code'] . "\n");

  // param is '' in this case

  print ('Param is:' . $err['param'] . "\n");
  print ('Message is:' . $err['message'] . "\n");
 }

 catch(StripeErrorRateLimit $e) {

  // Too many requests made to the API too quickly

 }

 catch(StripeErrorInvalidRequest $e) {

  // Invalid parameters were supplied to Stripe's API

 }

 catch(StripeErrorAuthentication $e) {

  // Authentication with Stripe's API failed
  // (maybe you changed API keys recently)

 }

 catch(StripeErrorApiConnection $e) {

  // Network communication with Stripe failed

 }

 catch(StripeErrorBase $e) {

  // Display a very generic error to the user, and maybe send
  // yourself an email

 }

 catch(Exception $e) {

  // Something else happened, completely unrelated to Stripe

 }

您可能会遇到一个错误,并且您的代码正确地处理了该错误,但是对于许多情况,您的错误处理代码实际上并没有做任何事情

您可能应该在每个
catch
块中添加一些内容(例如
print
调用),以查看返回的问题类型


或者,您的Stripe仪表板可以查看帐户的实时模式和测试模式日志,其中将包含命中Stripe服务器的每个请求(成功或其他)的条目

您可能遇到了一个错误,并且您的代码正确地处理了该错误,但是在许多情况下,您的错误处理代码实际上并没有做任何事情

您可能应该在每个
catch
块中添加一些内容(例如
print
调用),以查看返回的问题类型


或者,您的Stripe仪表板可以查看帐户的实时模式和测试模式日志,其中将包含命中Stripe服务器的每个请求(成功或其他)的条目

尝试使用下面的代码查找错误问题

try {
  echo "charging";
  $charge = StripeCharge::create(array(
   "amount" => 1000, // Amount in cents
   "currency" => "eur",
   "source" => $token,
   "description" => "Example charge"
  ));
 }

 catch(StripeErrorCard $e) {
    $error = $e->getJsonBody();
    <pre>print_r($error);</pre>
    //then you can handle like that 
    if($error == "Your card was declined."){
      echo "Your credit card was declined. Please try again with an alternate card.";
     }
 }
试试看{
回声“充电”;
$charge=StripeCharge::创建(数组(
“金额”=>1000,//以美分为单位的金额
“货币”=>“欧元”,
“source”=>$token,
“说明”=>“费用示例”
));
}
捕获(剥离错误卡$e){
$error=$e->getJsonBody();
打印错误($error);
//那你就可以这样处理了
如果($error==“您的卡被拒绝了。”){
echo“您的信用卡被拒绝。请使用备用卡重试。”;
}
}

尝试使用下面的代码查找错误问题

try {
  echo "charging";
  $charge = StripeCharge::create(array(
   "amount" => 1000, // Amount in cents
   "currency" => "eur",
   "source" => $token,
   "description" => "Example charge"
  ));
 }

 catch(StripeErrorCard $e) {
    $error = $e->getJsonBody();
    <pre>print_r($error);</pre>
    //then you can handle like that 
    if($error == "Your card was declined."){
      echo "Your credit card was declined. Please try again with an alternate card.";
     }
 }
试试看{
回声“充电”;
$charge=StripeCharge::创建(数组(
“金额”=>1000,//以美分为单位的金额
“货币”=>“欧元”,
“source”=>$token,
“说明”=>“费用示例”
));
}
捕获(剥离错误卡$e){
$error=$e->getJsonBody();
打印错误($error);
//那你就可以这样处理了
如果($error==“您的卡被拒绝了。”){
echo“您的信用卡被拒绝。请使用备用卡重试。”;
}
}

您的捕获大多是无声地失败。要么删除它们,要么让它们做一些明显的事情,比如
打印“OH SHIT Stripe InvalidRequest”在这一行之后重试$err=$body['error'];打印错误($err);请看错误。您的捕获基本上是无声地失败的。要么删除它们,要么让它们做一些明显的事情,比如
打印“OH SHIT Stripe InvalidRequest”在这一行之后重试$err=$body['error'];打印错误($err);看到错误了,我发现问题了!!实际上我的API不是最新的!显然Stripe不想告诉我这有那么重要:)他们可能是在告诉你。你的donothing
catch
语句可能对你隐瞒了这一点。我发现了问题!!实际上我的API不是最新的!显然Stripe不想告诉我这有那么重要:)他们可能是在告诉你。您的DoNothing
catch
语句可能对您隐瞒了这一点。