Export transactions require a customer name and address - Stripe Error
Asked Answered
F

7

11

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 
        ) 
    )); 
Forbes answered 11/12, 2019 at 8:59 Comment(2)
So did you try to provide address to API? Error message does not look enigmatic to me.Illogic
@MaximSagaydachny - Thanks man for your time, but it's resolved with Rajdip Chauhan's solution below.Forbes
Y
12

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

Yak answered 11/12, 2019 at 9:24 Comment(3)
where is this → '$address'?Venosity
@Venosity it's an array. Reference: stripe.com/docs/india-exports#export-of-servicesHelio
How to add the test address?Sonni
C
10

change the currency to INR from USD

i was working on Node & React this helps me

currency: 'INR'

this will fix your problem probably.

Close answered 9/10, 2020 at 8:31 Comment(3)
stripe is not for INR only please guide someone in correct directionPostexilian
sir, for indian cutomer stripe developer had made some changes so you can credit the user in term of INR and build your own logic to convert into other currency hope this will help you.Close
Worked for me as well.Followthrough
I
2

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"
        )
Ivory answered 22/7, 2020 at 21:6 Comment(1)
Please use `` to indicate code, for example `customer=stripe.Customer...`, which then displays as customer=stripe.Customer... If you have a block of code, then separate the code with at least one empty line, and indent the code by 4 spaces.Hiller
W
1

i had this issue in stripe nodejs i fixed it by passing address

const stripeAddress: Stripe.AddressParam = {
        line1: userAddress.street1,
        line2: userAddress.street2,
        city: userAddress.city,
        country: userAddress.country,
        postal_code: userAddress.zip,
        state: userAddress.state,
      };




 const stripeCustomer: Stripe.Customer = await this.stripe.customers.create(
    {
      name: userData.name,
      description: userData.description,
      email: userData.email,
      phone: userData.phoneNumber,
      address: stripeAddress,
    }
  );
Whittle answered 9/8, 2020 at 11:22 Comment(0)
P
0

Here is a complete working solution:

<?php 
require('config2.php');

$token = $_POST['stripeToken'];

$customer = \Stripe\Customer::create(array(
    'name' => 'test',
    'description' => 'test description',
    'email' => '[email protected]',
    'source' => $token,
    "address" => ["city" => "hyd", "country" => "india", "line1" => "adsafd werew", "postal_code" => "500090", "state" => "telangana"]
));


$charge = \Stripe\Charge::create(array( 
        'customer' => $customer->id, 
        'amount'   => '100', 
        'currency' => 'inr', 
        'description' => "TrueCAD 2021 Premium", 
    )); 


echo "<pre>";
print_r($charge);
?>
Pontine answered 9/5, 2021 at 17:7 Comment(0)
S
0

i had this issue with stripe (MERN project). Just make sure you are putting description and shipping details

const paymentIntent = await stripe.paymentIntents.create({
    amount: 100, // subunits of currency
    currency: "usd",
    description: "for amazon-clone project",
    shipping: {
      name: "Random singh",
      address: {
        line1: "510 Townsend St",
        postal_code: "98140",
        city: "San Francisco",
        state: "CA",
        country: "US",
      },
    },
});
Sainted answered 30/8, 2022 at 10:17 Comment(0)
C
-1

Just Use an Indian Stripe test card India (IN) 4000003560000008 Visa instead of 4242424242424242

Country-wise card detail

Crossbreed answered 29/4 at 10:41 Comment(1)
this worked for me in test modeInsensible

© 2022 - 2024 — McMap. All rights reserved.