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

feat(Checkout): Add request option parameters #1730

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
use JsonSerializable;
use Stripe\Checkout\Session;

/**
* @phpstan-import-type RequestOptionsArray from \Stripe\Util\RequestOptions
*
* @psalm-import-type RequestOptionsArray from \Stripe\Util\RequestOptions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's RequestOptionsArray?

Copy link
Author

@hutaoseven hutaoseven Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Stripe\Service\Checkout::create($params = null, $opts = null) Can be array

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*/
class Checkout implements Arrayable, Jsonable, JsonSerializable, Responsable
{
/**
Expand Down Expand Up @@ -66,9 +71,10 @@ public static function customer($owner, $parentInstance = null)
* @param \Illuminate\Database\Eloquent\Model|null $owner
* @param array $sessionOptions
* @param array $customerOptions
* @param RequestOptionsArray|\Stripe\Util\RequestOptions|null $opts
* @return \Laravel\Cashier\Checkout
*/
public static function create($owner, array $sessionOptions = [], array $customerOptions = [])
public static function create($owner, array $sessionOptions = [], array $customerOptions = [], $opts = null)
{
$data = array_merge([
'mode' => Session::MODE_PAYMENT,
Expand Down Expand Up @@ -107,7 +113,7 @@ public static function create($owner, array $sessionOptions = [], array $custome
$data['cancel_url'] = $sessionOptions['cancel_url'] ?? route('home').'?checkout=cancelled';
}

$session = $stripe->checkout->sessions->create($data);
$session = $stripe->checkout->sessions->create($data, $opts);

return new static($owner, $session);
}
Expand Down
8 changes: 7 additions & 1 deletion src/CheckoutBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
use Laravel\Cashier\Concerns\AllowsCoupons;
use Laravel\Cashier\Concerns\HandlesTaxes;

/**
* @phpstan-import-type RequestOptionsArray from \Stripe\Util\RequestOptions
*
* @psalm-import-type RequestOptionsArray from \Stripe\Util\RequestOptions
*/
class CheckoutBuilder
{
use AllowsCoupons;
Expand Down Expand Up @@ -60,9 +65,10 @@ public static function make($owner = null, $instance = null)
* @param array|string $items
* @param array $sessionOptions
* @param array $customerOptions
* @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
driesvints marked this conversation as resolved.
Show resolved Hide resolved
* @return \Laravel\Cashier\Checkout
*/
public function create($items, array $sessionOptions = [], array $customerOptions = [])
public function create($items, array $sessionOptions = [], array $customerOptions = [], $opts = null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You still need to pipe this through to the create call.

{
$payload = array_filter([
'allow_promotion_codes' => $this->allowPromotionCodes,
Expand Down
Loading