我正在尝试在不使用Javascript的情况下执行条带事务。可能是cURL,但我无法使用v2 api计算出标题。
<form action="" method="POST" id="payment-form">
<span class="payment-errors"></span>
<div class="form-row">
<label>
<span>Card Number</span>
<input type="text" size="20" data-stripe="number"/>
</label>
</div>
<div class="form-row">
<label>
<span>CVC</span>
<input type="text" size="4" data-stripe="cvc"/>
</label>
</div>
<div class="form-row">
<label>
<span>Expiration (MM/YYYY)</span>
<input type="text" size="2" data-stripe="exp-month"/>
</label>
<span> / </span>
<input type="text" size="4" data-stripe="exp-year"/>
</div>
<button type="submit">Submit Payment</button>
</form>
<?php
require '../stripe-php/init.php';
//this next line is very wrong
$post = 'client_secret=['sk_07C5ukIdqx'].'&grant_type=authorization_code&code='.$_GET['code'];
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $system['stipe']['token_url']);
curl_setopt($ch,CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
$decode = json_decode($result);
StripeStripe::setApiKey("my_secret");
StripeCharge::create(array(
"amount" => 500,
"currency" => "usd",
"source" => $decode[2], // I am totally guessing the value will be in element #2
"description" => "Charge for test@example.com"
));
?>
我的大部分问题是获得代币。所有的stripe文档都只使用stripe.js,而我没有使用javascript。
如何在不使用Javascript的情况下将stripe令牌放入PHP变量中,以便将其用于基本事务?
Stripe在使用stripe.js
时不要求服务器符合PCI。
如果您有一个接受信用卡数据的web表单,您希望Stripe创建卡令牌。信用卡信息永远不会通过电汇发送到您的服务器。这就是为什么代码中的表单字段没有name
属性(不提交无名称字段(这是件好事
如果你坚持不使用stripe.js,API关于创建收费的文档清楚地说明了
您提供的源必须是一个令牌,如Stripe.js返回的令牌,或者一个包含用户信用卡详细信息的关联数组
'amount' => 200, // $2.00,
'currency' => 'usd',
'source' => [
'object' => 'card',
'number' => '...'
'exp_month' => '...',
'exp_year' => '...',
'cvc' => '...',
]
删除stripe.js
,在表单上放置一些name
属性,然后使用Charge::create()
方法,而不使用前面所有的旋度。
我必须提到的是,如果我不清楚API的基本原理,它使信用卡处理变得非常简单,我会非常担心让信用卡数据接触我的服务器会给自己带来多大的潜在诉讼。