henk3
September 15, 2019, 6:57pm
1
I have tried many different ways to create a customer through the API including the address without success. When I exclude the address details I successfully create the customer but the moment I add the address code it gives an error.
Here are two methods I tried without success
$customer = \Stripe\Customer::create(array(
['address' => ['line1' => $address]],
['address' => ['city' => $town]],
['address' => ['state' => $state]],
['address' => ['postal_code' => $zipcode]],
"name" => $fullname,
"email" => $email,
"source" => $token,
));
$customer = \Stripe\Customer::create(array(
"address.line1" => $address,
"address.city" => $town,
"address.state" => $state,
"address.postal_code" => $zipcode,
"name" => $fullname,
"email" => $email,
"source" => $token,
));
henk3:
[âaddressâ => [âline1â => $address]],
[âaddressâ => [âcityâ => $town]],
[âaddressâ => [âstateâ => $state]],
[âaddressâ => [âpostal_codeâ => $zipcode]],
okay⌠woah.
From your attempts, it looks like youâre trying to create an associative array for the address value of the overall array.
So letâs take it out a step. First, letâs define your top level, using the same thing as you used for the name, and email, and source.
$customer = \Stripe\Customer::create(array(
"address" => $myaddressarray,
"name" => $fullname,
"email" => $email,
"source" => $token
));
Now, letâs define your address array, using the exact same style as the outer array:
$myaddressarray = array(
"line1" => $address,
"city" => $town,
"state" => $state,
"postal_code" => $zipcode
);
If you want to substitute this code into the original format, you would copy and past everything between the = and the ; (not including either of those), and replace $myaddressarray in the first block with it.
1 Like
henk3
September 15, 2019, 9:45pm
3
Thank you! Im going to try this and see if it works
henk3
September 15, 2019, 9:50pm
4
THANK YOU! It works perfectly now and I understand what I did wrong. thank you!
1 Like
system
Closed
December 16, 2019, 4:50am
5
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.