I am trying to add the customer's preferred email address for invoices to their account when creating a new customer via Stripe's API. But I receive an error each time I submit the request.
I'm building an array like this;
$postData['name'] = $requestData['name'];
$postData['email'] = $requestData['email_address'];
$postData['phone'] = $requestData['phone_number'];
$postData['address']['line1'] = $requestData['address'];
$postData['address']['line2'] = $requestData['address_2'];
$postData['address']['city'] = $requestData['city'];
$postData['address']['state'] = $requestData['state'];
$postData['address']['postal_code'] = $requestData['zip'];
$postData['address']['country'] = 'US';
$postData['invoicing']['email_to'] = $requestData['invoice_email'];
Then I am formatting the data for submision.
$data_string = http_build_query($postData);
I then receive the following response from the API.
Received unknown parameter: invoicing. Did you mean invoice_settings?
However, when I create a new customer inside the Stripe Dashboard, then look at the logs I can see the Request POST body includes the same parameter.
"invoicing": {
"email_cc": "",
"email_to": [
"[email protected]"
]
}
The only difference I can find is my API Request POST body is formatting the invoice email address as an Object and not an Array within the Object. I'm assuming this has to do with the http_build_query function. However, Stripe's API only accepts form-encoded request bodies. Below is the Request POST body sample from Stripe's log for the failed attempt.
"invoicing": {
"email_to": "[email protected]"
}
The Stripe API Docs lack the documentation of this ability.
CodePudding user response:
As of September 28th 2022 this feature is not possible using Stripe's API. You may add an email address to the customer in the Stripe Dashboard.
After spending over an hour on the phone with their support, they looked at all the API options and this feature is not yet available.
CodePudding user response:
The invoicing
emails you see in the Dashboard request correspond to the separate "Billing email" setting and additional "Emails to CC" values in the "Add customer" modal of the Dashboard. It looks like these additional emails can only be configured via the Stripe Dashboard, not the API. You'll only be able to set a customer email
using the API: https://stripe.com/docs/api/customers/create#create_customer-email