php - Stripe not charging the card -


i'm having issue stripe happily create token , send on php charging script, @ point 200 ok - token log created on stripe control panel. not charge card, far can see i've done properly, i'm getting no errors, in php or stripe api.

error_reporting(e_all); ini_set('display_errors', 1);  $error = 0;  require_once('stripe-php-master/init.php');  $trialapikey = "sk_test_???";  // these secret keys! $liveapikey = "sk_live_???";  \stripe\stripe::$apibase = "https://api-tls12.stripe.com";  // switch change between live , test environments  \stripe\stripe::setapikey($trialapikey); /* \stripe\stripe::setapikey($liveapikey); */  $token = $_post['token']; $price = $_post['amount']; $price = $price * 100; $desc = $_post['desc'];  try {   $charge = \stripe\charge::create(array(     "amount" => $price,     "currency" => "gbp",     "source" => $token,     "description" => $desc     )); } catch(\stripe\error\card $e) {   // card has been declined   $error++; }  if($error>=1) {     echo "there error processing card, please try again."; } else {     echo "thank you, payment successful."; } 

please use code stripe sucessfull charge.

<?php require_once("stripe2/init.php"); $card_no = '4242 4242 4242 4242'; $card_exp = '05 / 20'; $card_cvc = '123'; $token  = createstripetoken($card_cvc,$card_exp,$card_no); $testcharge = charges(10,$token);  echo $testcharge;  function charges($amount,$token) {  $charge = \stripe\charge::create(array(  "amount" => $amount * 100,  "currency" => "usd",  "source" => $token,    )); $succes = 'your 1 time charges successfully'; return $succes;  } function createstripetoken($card_cvc,$card_exp,$card_no)  {    $exp_month = substr($card_exp,0,2);    $exp_year = substr($card_exp,5,2);     \stripe\stripe::setapikey("your key here");       $data = \stripe\token::create(array(       "card" => array(       "number" => $card_no,       "exp_month" => $exp_month,      "exp_year" => $exp_year,      "cvc" => $card_cvc       )      ));    $response = json_decode(json_encode($data), true);   $token = $response['id'];  return $token;   }   ?> 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -