I'm getting an error when making a charge using a token created from a customer previously created using stripe. I need to be able to charge a user more than once so charges can go to multiple destinations, which is why I'm creating the token. However, when trying to charge anyone using the following code I get the error:
Fatal error: Uncaught exception 'Stripe\Error\InvalidRequest' with message 'No such token: tok_187sfmBqiK1u6WYC3qS20eNu'
$stripe_id and other variables have been assigned in my code, I'm just copy/pasting the main bits:
\Stripe\Stripe::setApiKey("sk_mykey-changedforsecurity"); // authorises secret key
$token = $_POST['stripeToken'];
$customer = \Stripe\Customer::create(array(
"description" => "test customer",
"source" => $token // obtained with Stripe.js
));
$chargetoken = \Stripe\Token::create(
array("customer" => $customer->id),
array("stripe_account" => $stripe_id) // id of the connected account
);
$charge = \Stripe\Charge::create(array(
"amount" => $price,
"currency" => "gbp",
"source" => $chargetoken,
"description" => $title,
"application_fee" => 20,
"destination" => $stripe_id
));
Any help would be very appreciated,
Thanks