I'm using stripe SDK for creating customers & charge to a customer using API, but getting an error with "Fatal error: Uncaught (Status 400) (Request req_ZyqUtykjUcOqrU) As per Indian regulations, export transactions require a customer name and address. More info here: https://stripe.com/docs/india-exports thrown in /opt/lampp/htdocs/stripe/lib/Exception/ApiErrorException.php on line 38"
My code is like below:
\Stripe\Stripe::setApiKey(STRIPE_API_KEY);
$customer = \Stripe\Customer::create(array(
'name' => 'test',
'description' => 'test description',
'email' => $email,
'source' => $token
));
$orderID = strtoupper(str_replace('.','',uniqid('', true)));
$charge = \Stripe\Charge::create(array(
'customer' => $customer->id,
//'source' => 'rtest',
'amount' => $itemPrice,
'currency' => $currency,
'description' => $itemName,
'metadata' => array(
'order_id' => $orderID
)
));
As your error suggested you need to pass address object in stripe customer create API as per below example
$customer = \Stripe\Customer::create(array(
'name' => 'test',
'description' => 'test description',
'email' => $email,
'source' => $token,
"address" => ["city" => $city, "country" => $country, "line1" => $address, "line2" => "", "postal_code" => $zipCode, "state" => $state]
));
Note: line1 is required in address object
change the currency to INR from USD
i was working on Node & React this helps me
currency: 'INR'
this will fix your problem probably.
Even I was facing the same issue.
Just make sure you are putting the same currency.
For example: if you have mentioned india as your country then put "inr" else "usd" use this for your reference:
customer=stripe.Customer.create(
email=request.POST["email"],
name=request.POST["nickname"],
source=request.POST["stripeToken"],
)
customer=stripe.Customer.modify(
customer.id,
address={"city":"mumbai","country":"india","line1":"unr","line2":"thane","postal_code":"421005","state":"maharashtra"},
)
charge=stripe.Charge.create(
customer=customer,
amount=500,
currency='inr',
description="payment"
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With