Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export transactions require a customer name and address - Stripe Error

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 
        ) 
    )); 
like image 944
Shadow Avatar asked Dec 11 '19 08:12

Shadow


3 Answers

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

like image 141
Rajdip Chauhan Avatar answered Oct 31 '22 21:10

Rajdip Chauhan


change the currency to INR from USD

i was working on Node & React this helps me

currency: 'INR'

this will fix your problem probably.

like image 9
Govind Kumar Thakur Avatar answered Oct 31 '22 21:10

Govind Kumar Thakur


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"
        )
like image 2
jaya tanwani Avatar answered Oct 31 '22 21:10

jaya tanwani