mattesj
mattesj

Reputation: 609

Send additional parameters to Stripe with Laravel Cashier

The Laravel docs states how to send extra parameters to Stripe like email. My question is how to send other parameters like adress and name. Below is some of the customer.updated webhook.

"sources": {
  "object": "list",
  "data": [
    {
      "id": "card_1A3KXJUybOxa5viznC3iZy5U",
      "object": "card",
      "address_city": null, 
      "address_country": null,
      "address_line1": null,
      "address_line1_check": null,
      "address_line2": null,
      "address_state": null,
      "address_zip": null,

And in my Laravel controller..

 $user->newSubscription('Silver', 'Silver')->create($creditCardToken, [
       'email' => $request->input('email'),
       'description' => 'Silver membership'
 ]);

The above works fine to send email and description to Stripe. But 'adress_city' => 'New York' for example doesn't.

Upvotes: 1

Views: 1008

Answers (2)

Qaiser Mehmood
Qaiser Mehmood

Reputation: 212

Using C#, it is like this.

Dictionary<string, string> Extra = new Dictionary<string, string>();
Extra.Add("email", ByEmail);
StripeCustomer customer = customerService.List(new StripeCustomerListOptions() { Limit = 1, ExtraParams = Extra }).SingleOrDefault();

Upvotes: 0

Pratik Mehta
Pratik Mehta

Reputation: 725

You can send other data using metadata key like this below.

$user->newSubscription('Silver', 'Silver')->create($creditCardToken, [
   'email' => $request->input('email'),
   'description' => 'Silver membership',
   'metadata' => [
                'adress_city' => 'New York',
            ],

]);

Thanks,

Upvotes: 2

Related Questions