Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将3d安全令牌剥离给客户,然后收费_Php_Api_Stripe Payments_Payment - Fatal编程技术网

Php 将3d安全令牌剥离给客户,然后收费

Php 将3d安全令牌剥离给客户,然后收费,php,api,stripe-payments,payment,Php,Api,Stripe Payments,Payment,我试着找出Stripe的系统。 这就是我现在正在尝试的: 生成一个支付49.00欧元的3D安全令牌 当我接收回令牌(成功)时,我创建了“源”作为3D安全令牌的客户 此后,我向客户(customerId)收费。但是它不起作用 如果我删除createcustomer,只需充电,它就可以正常工作。但我需要将卡附在客户身上,以便以后使用 有人能帮我吗 //Load private keys $stripe = new \Stripe\StripeClient( 'XXX' ); \Stripe\

我试着找出Stripe的系统。 这就是我现在正在尝试的:

  • 生成一个支付49.00欧元的3D安全令牌
  • 当我接收回令牌(成功)时,我创建了“源”作为3D安全令牌的客户
  • 此后,我向客户(customerId)收费。但是它不起作用
如果我删除createcustomer,只需充电,它就可以正常工作。但我需要将卡附在客户身上,以便以后使用

有人能帮我吗

//Load private keys
$stripe = new \Stripe\StripeClient(
  'XXX'
);
\Stripe\Stripe::setApiKey('XXX');


//On callback the 3d secure token is $_GET['token']
if($_GET['success']=="true")
{

//Create customer and attach the card.
$customer = \Stripe\Customer::create([
  'email' => mt_rand(111,999). 'aaa.user@example.com',
  'source' => $_GET['token'],
  'name'=> 'Je2ns',
  'phone' => '+4403395848585',
  'shipping' => [
    'name' => 'Jen3ny R3osen',
    'address' => [
      'line1' => '1234 Ma3in Street',
      'city' => 'San Fran3cisco',
      'state' => 'CA',
      'country' => 'FR',
      'postal_code' => '924111',
    ],
  ],
]);



//Charge the customer (this doesnt work???)
$lastCharge = $stripe->charges->create([
  'amount' => 49 * 100,
  'currency' => 'eur',
  'source' => $customer->id,
  'description' => 'Payment for product '.mt_rand(111,999),
]);


print_r($lastCharge);

exit;
}

.btn{
光标:指针;
}
卡
3d安全支持卡号VCV到期月份每年
不支持(美国运通)3782 822463 10005123122020试试这张卡!
可选(无身份验证)424242123122020试用此卡!
可选(需要验证)4000 0000 0000 3055123122020试用此卡!
需要4000 0000 0000 3063123120200试试这张卡!
Stripe.setPublishableKey('pk_test_51HLZKDHY9IQYGDB3CTCBZS2TAPIQ2LK9L541ZYLELIDQRPRJQ2CUKCINK44ODED0ZLWORMKKTO4ULBBAAUBIZ7G00EPPIKJD4')
/**
*当我们点击一张卡片
*/
函数onClick(卡号){
const paymentRequest={
卡号:卡号,
年份:2024年,
第12个月:,
cvc:'123',
货币:欧元,
金额:49*100,
nativeElement:document.querySelector(“#iframe payment”)
};
paymentRequest.nativeElement.innerHTML='正在加载…请稍候…';
doPayment(paymentRequest)。然后((结果)=>{
log('result-->',result);
paymentRequest.nativeElement.innerHTML='Success!!!!您的详细信息是正确的!!!:)';
警报('Success:Token为:'+result.id);
location.href='?success=true&token='+result.id;
}).catch((错误)=>{
控制台错误(error);
paymentRequest.nativeElement.innerHTML='Ups!我们无法验证您的详细信息…';
提醒('Ups,出了什么事,对不起!:(');
});
}


响应:[12-Nov-2020 14:09:13 UTC]PHP致命错误:未捕获(状态400)(请求请求KV5s9g0GJHuOe3)没有这样的令牌:“cus_inrmwjeybdacx”

A
cus******
id是一个客户,而不是令牌。您已经有了一个客户对象,但从您当前共享的代码中不清楚您是如何创建该客户的。现在检查,与客户端一起更新。潜在的问题仍然是您有一个客户对象(在本例中)
cus\u inrmwjeybdacx的id
。它已经附加了一个源代码/卡。您可以检查它以进行验证。您不需要以任何方式转换令牌(因为您没有令牌)。[default\u Source]=>src\u 1hmhtphy9iqygdbk7jizuoc[id]=>cus\u inzowfgqpfztb
<!DOCTYPE html>
<html>
<head>
  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css"
    rel="stylesheet" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
  <style>
    .btn {
      cursor: pointer;
    }
  </style>
</head>
<body>
  <div class="container">
    <div class="row">
      <h1>Cards</h1>
      <table class="table table-striped table-bordered table-hover table-responsive">
        <thead><th>3d secure support</th><th>Card Number</th><th>CVC</th><th>Expiry Month</th><th>Expiry Year</th><th></th></thead>
        <tbody>
          <tr><td>no support (American Express)</td><td>3782 822463 10005</td><td>123</td><td>12</td><td>2020</td><td><button class="btn btn-primary" onclick="onClick('3782 822463 10005')">Try this card!</button></td></tr>
          <tr><td>optional (no authentication)</td><td>4242 4242 4242 4242</td><td>123</td><td>12</td><td>2020</td><td><button class="btn btn-primary" onclick="onClick('4242 4242 4242 4242')">Try this card!</button></td></tr>
          <tr><td>optional (needs authentication)</td><td>4000 0000 0000 3055</td><td>123</td><td>12</td><td>2020</td><td><button class="btn btn-primary" onclick="onClick('4000 0000 0000 3055')">Try this card!</button></td></tr>
          <tr><td>required</td><td>4000 0000 0000 3063</td><td>123</td><td>12</td><td>2020</td><td><button class="btn btn-primary" onclick="onClick('4000 0000 0000 3063')">Try this card!</button></td></tr>
        </tbody>
      </table>

      <div class="col-12" id="iframe-payment"></div>
    </div>
  </div>

  <script type="text/javascript" src="https://js.stripe.com/v2/"></script>
  <script>
    Stripe.setPublishableKey('pk_test_51HlZKDHy9IqUyGdb3cTcBzS2taPiQ2lk9l541zYLeLIDqrpRjQ2CuKcInk44ODeD0ZLwormKKTo4UlbBAAUBIz7g00ePPikjd4')
  </script>
  <script src="js/api.js"></script>
  <script>
    /**
 * When we click on a card
 */
function onClick(cardNumber) {
  const paymentRequest = {
    cardNumber: cardNumber,
    expYear: '2024',
    expMonth: '12',
    cvc: '123',
    currency: 'EUR',
    amount: 49 * 100,
    nativeElement: document.querySelector('#iframe-payment')
  };
  
  paymentRequest.nativeElement.innerHTML = 'Loading... Please wait...';

  doPayment(paymentRequest).then((result) => {
    console.log('result --> ', result);
    paymentRequest.nativeElement.innerHTML = 'Success!!!! Your details are correct!!! :)';
    alert('Success: Token is: ' + result.id);
    location.href='?success=true&token='+result.id;
  }).catch((error) => {
    console.error(error);
    paymentRequest.nativeElement.innerHTML = 'Ups! We can\t validate your details...';
    alert('Ups, something wrong, sorry! :(');
  });
}

</script>