Skip to content

Commit

Permalink
Add allowPromotionCodes to PerformsCharges
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed Nov 24, 2020
1 parent 4166903 commit c1d8506
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Concerns/PerformsCharges.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@

trait PerformsCharges
{
/**
* Determines if user redeemable promotion codes are available in Stripe Checkout.
*
* @var bool
*/
protected $allowPromotionCodes = false;

/**
* Make a "one off" charge on the customer for the given amount.
*
Expand Down Expand Up @@ -71,6 +78,7 @@ public function refund($paymentIntent, array $options = [])
public function checkout($price, $quantity = 1, array $sessionOptions = [], array $customerOptions = [])
{
return Checkout::create($this, array_merge([
'allow_promotion_codes' => $this->allowPromotionCodes,
'line_items' => [[
'price' => $price,
'quantity' => $quantity,
Expand All @@ -91,6 +99,7 @@ public function checkout($price, $quantity = 1, array $sessionOptions = [], arra
public function checkoutCharge($amount, $name, $quantity = 1, array $sessionOptions = [], array $customerOptions = [])
{
return Checkout::create($this, array_merge([
'allow_promotion_codes' => $this->allowPromotionCodes,
'line_items' => [[
'price_data' => [
'currency' => $this->preferredCurrency(),
Expand All @@ -103,4 +112,16 @@ public function checkoutCharge($amount, $name, $quantity = 1, array $sessionOpti
]],
], $sessionOptions), $customerOptions);
}

/**
* Enables user redeemable promotion codes.
*
* @return $this
*/
public function allowPromotionCodes()
{
$this->allowPromotionCodes = true;

return $this;
}
}

0 comments on commit c1d8506

Please sign in to comment.