NIX*_*NIX 0 php api curl stripe-payments
我试图在不使用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);
\Stripe\Stripe::setApiKey("my_secret");
\Stripe\Charge::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"
));
?>
Run Code Online (Sandbox Code Playgroud)
我最关心的问题是获取令牌。所有的Stripe文档仅使用stripe.js,而我没有使用javascript。
如何在不使用Javascript的情况下将Stripe令牌放入PHP变量,以便可以将其用于基本事务?
使用时,Stripe不需要服务器兼容PCI stripe.js。
如果您具有Web表单来接受信用卡数据,则希望由Stripe创建卡令牌。决不要将信用卡信息通过电汇发送给您的服务器。这就是为什么代码中的表单字段没有name属性(不提交无名称字段)的原因。这是一件好事。
如果您坚持不使用stripe.js,则有关创建费用的API文档会明确说明
您提供的来源必须是令牌(如Stripe.js返回的令牌)或包含用户信用卡详细信息的关联数组
'amount' => 200, // $2.00,
'currency' => 'usd',
'source' => [
'object' => 'card',
'number' => '...'
'exp_month' => '...',
'exp_year' => '...',
'cvc' => '...',
]
Run Code Online (Sandbox Code Playgroud)
删除stripe.js,name在窗体上添加一些属性,然后使用Charge::create()没有前面所有卷曲内容的方法。
我不得不提到,如果我不清楚使信用卡处理变得简单的API的基础知识,那么我将非常担心自己让信用卡数据接触我的服务器而使自己面临潜在诉讼的风险。
| 归档时间: |
|
| 查看次数: |
2722 次 |
| 最近记录: |