1

I am implementing stripe payment gateway in cakephp project.

Below is the code which i have tried :

  require_once('stripelib/vendor/autoload.php');
        \Stripe\Stripe::setApiKey('sk_test_xxxxxxxxxxxxxxxxxxxxxx');
        try {
            $charge = \Stripe\Charge::create(array(
                        "amount" => $data['total'] * 100,
                        "currency" => "usd",
                        "card" => $token,
                        "description" => "Charge for Facebook Login code."
            ));
            //  pr($charge);exit;
        }

Here problem is merchant is not getting amount and i got below error :

{"error":"No such token: card_xxxxxxxxxxxxxxxxxxxxxx(invalid_request_error)"}

Any suggestion? Thank you.

floriank
  • 25,546
  • 9
  • 42
  • 66
sradha
  • 2,216
  • 1
  • 28
  • 48

1 Answers1

0

You're trying to use a card ID ("card_...") rather than a token ID ("tok_...") to create the charge.

See this StackOverflow answer for more information on how to create charges: https://stackoverflow.com/a/34416413/5307473

Community
  • 1
  • 1
Ywain
  • 16,854
  • 4
  • 51
  • 67