Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.X] Issue with collectTaxIds() method #1208

Closed
YannickYayo opened this issue Jun 24, 2021 · 3 comments · Fixed by #1209
Closed

[13.X] Issue with collectTaxIds() method #1208

YannickYayo opened this issue Jun 24, 2021 · 3 comments · Fixed by #1209
Labels

Comments

@YannickYayo
Copy link

  • Cashier Version: 13.2.0
  • Laravel Version: 8.48.1
  • PHP Version: 7.4.19
  • Database Driver & Version: mariadb 10.6

Description:

I am using the Stripe Checkout, and i want to allow companies to enter their Tax ID. Following the doc, i used the collectTaxIds() method :

auth()->user()
        ->collectTaxIds() // here
        ->allowPromotionCodes()
        ->checkout(
            [
                [
                    'price' => Price::find($this->stripePriceChoosen)->price_id,
                    'quantity' => 1,
                    'tax_rates' => [Tax::active()->french()->first()->tax_id],
                ],
            ],
            [
                'success_url' => route('stripe-payment', [
                    'advertisement' => $this->advertisement->id,
                    'status' => 'success',
                ]),
                'cancel_url' => route('stripe-payment', [
                    'advertisement' => $this->advertisement->id,
                    'status' => 'cancel',
                ]),
            ]
        );

After that, i'm receiving this error from Stripe :

{
  "error": {
    "message": "Invalid object",
    "param": "tax_id_collection",
    "type": "invalid_request_error"
  }
}

Cashier, in the checkout session's data is making the tax_id_collection to true, but following those documentation :
Stripe Api
Stripe doc
tax_id_collection must be an associative array, with the key enable to true :

// before 
[
  'success_url' => 'https://example.com/success',
  'cancel_url' => 'https://example.com/cancel',
  'allow_promotion_codes' => true,
  'payment_method_types' => ['card'],
  'line_items' => [
    [
      'price' => 'price_H5ggYwtDq4fbrJ',
      'quantity' => 2,
      'tax_rates' => ['txr_1J5Z0LB6GOVAU4psl08YX3r6']
    ],
  ],
  'mode' => 'payment',
  'tax_id_collection' => true // here
]

// after
[
  'success_url' => 'https://example.com/success',
  'cancel_url' => 'https://example.com/cancel',
  'allow_promotion_codes' => true,
  'payment_method_types' => ['card'],
  'line_items' => [
    [
      'price' => 'price_H5ggYwtDq4fbrJ',
      'quantity' => 2,
      'tax_rates' => ['txr_1J5Z0LB6GOVAU4psl08YX3r6']
    ],
  ],
  'mode' => 'payment',
  'tax_id_collection' => ['enable' => true] // here
]

Steps To Reproduce:

Use the Stripe checkout to make a payment, and allow users to enter their Tax ID by using the method collectTaxIds().

@driesvints
Copy link
Member

Thanks! No idea how that happened... I sent in a PR here: #1209

@YannickYayo
Copy link
Author

You are fast !
Thank you :D

@driesvints
Copy link
Member

@YannickYayo tagged v13.2.1 for ya: https://github.com/laravel/cashier-stripe/releases/tag/v13.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants