I am trying to perform a stripe transaction without the use of Javascript. Possibly cURL but I cannot figure out the header using the 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"
));
?>
most of my issue is getting the token. All of the stripe docs are only using stripe.js and I am not using javascript.
How do I get the stripe token into a PHP variable without the use of Javascript so I can use it for a basic transaction?
Aucun commentaire:
Enregistrer un commentaire