Reputation: 11699
I am getting below error when I create a Stripe Charge
Invalid string id: {"number"=>"401288******1881", "exp_month"=>"02", "exp_year"=>"2015", "cvc"=>"***", "name"=>"Tahir Yasin", "address_line1"=>"lorem ipsum dolar", "address_line2"=>"lorem ipsum dolar", "address_zip"=>"5400", "address_state"=>"Punjab", "address_country"=>"PK"}{"success":true,"error":false}
Stripe Charge and Collecting Fee
try {
$charge = Stripe_Charge::create(array(
'amount' => 500,
'currency' => 'usd',
'card' => array(
'number' => '4012888888881881',
'exp_month' => '02',
'exp_year' => '2015',
'cvc' => '123',
'name' => 'Tahir Yasin',
'address_line1' => 'lorem ipsum dolar',
'address_line2' => 'lorem ipsum dolar',
'address_zip' => '5400',
'address_state' => 'Punjab',
'address_country' => 'PK',
),
'description' => '#100000011, [email protected]',
"application_fee" => 5
), 'SECRET_KEY_OF_CUSTOMER_TAKEN_VIA_STRIPE_CONNECT'
);
} catch (Exception $e) {
echo $e->getMessage();
}
Further digging the stack trace shows
[error] => Array
(
[type] => invalid_request_error
[message] => Invalid string id: {"number"=>"401288******1881", "exp_month"=>"02", "exp_year"=>"2015", "cvc"=>"***", "name"=>"Tahir Yasin", "address_line1"=>"lorem ipsum dolar", "address_line2"=>"lorem ipsum dolar", "address_zip"=>"5400", "address_state"=>"Punjab", "address_country"=>"PK"}
[param] => card
)
I thought this could be due to dummy card details but I injected my real card details but still same error.
Can anyone please look into and let me know what am I missing here?
Upvotes: 0
Views: 7254
Reputation: 25552
This happens because you can not provide card details directly through the API when creating a charge with Stripe Connect. You have to create a token with Stripe Checkout or Stripe.js first and use this card token to create the charge.
As per the documentation:
Note that we require Stripe.js for all applications—you won't be allowed to send credit card data directly from your server.
Upvotes: 3