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] Rename cancelled to canceled #1284

Merged
merged 2 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@
- Add ability to ignore cashier routes ([#763](https://github.com/laravel/cashier-stripe/pull/763))

### Fixed
- Only mount card element if payment has not succeeded or been cancelled ([#765](https://github.com/laravel/cashier-stripe/pull/765))
- Only mount card element if payment has not succeeded or been canceled ([#765](https://github.com/laravel/cashier-stripe/pull/765))
- Set off_session parameter to true when creating a new subscription ([#764](https://github.com/laravel/cashier-stripe/pull/764))


Expand Down
4 changes: 2 additions & 2 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ Exceptions may be thrown for the following methods: `charge`, `invoiceFor`, and

> If you would like to let Stripe host your payment verification pages, [you may configure this in your Stripe settings](https://dashboard.stripe.com/account/billing/automatic). However, you should still handle payment exceptions in your application and inform the user they will receive an email with further payment confirmation instructions.

In addition, the subscription `create` method on the subscription builder previously immediately cancelled any subscription with an `incomplete` or `incomplete_expired` status and threw a `SubscriptionCreationFailed` exception when a subscription could not be created. This has been replaced with the behavior described above and the `SubscriptionCreationFailed` exception has been removed.
In addition, the subscription `create` method on the subscription builder previously immediately canceled any subscription with an `incomplete` or `incomplete_expired` status and threw a `SubscriptionCreationFailed` exception when a subscription could not be created. This has been replaced with the behavior described above and the `SubscriptionCreationFailed` exception has been removed.

#### The Subscription `stripe_status` Column

Expand Down Expand Up @@ -598,7 +598,7 @@ Previously, when a user attempted to change subscription plans and their payment

However, Cashier will now catch the payment failure exception while allowing the plan swap to continue. The payment failure will be handled by Stripe and Stripe may attempt to retry the payment at a later time. If the payment fails during the final retry attempt, Stripe will execute the action you have configured in your billing settings: https://stripe.com/docs/billing/lifecycle#settings

Therefore, you should ensure you have configured Cashier to handle Stripe's webhooks. When configured properly, this will allow Cashier to mark the subscription as cancelled when the final payment retry attempt fails and Stripe notifies your application via a webhook request. Please refer to our [instructions for setting up Stripe webhooks with Cashier.](https://laravel.com/docs/master/billing#handling-stripe-webhooks).
Therefore, you should ensure you have configured Cashier to handle Stripe's webhooks. When configured properly, this will allow Cashier to mark the subscription as canceled when the final payment retry attempt fails and Stripe notifies your application via a webhook request. Please refer to our [instructions for setting up Stripe webhooks with Cashier.](https://laravel.com/docs/master/billing#handling-stripe-webhooks).


## Upgrading To 9.0 From 8.x
Expand Down
4 changes: 2 additions & 2 deletions resources/views/payment.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@

<div v-else-if="paymentIntent.status === 'canceled'">
<h2 class="text-xl mb-4 text-gray-600">
Payment Cancelled
Payment Canceled
</h2>

<p class="mb-6">
This payment was cancelled.
This payment was canceled.
</p>
</div>

Expand Down
6 changes: 3 additions & 3 deletions src/Http/Controllers/WebhookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ protected function handleCustomerSubscriptionUpdated(array $payload)
}

/**
* Handle a cancelled customer from a Stripe subscription.
* Handle a canceled customer from a Stripe subscription.
*
* @param array $payload
* @return \Symfony\Component\HttpFoundation\Response
Expand All @@ -214,7 +214,7 @@ protected function handleCustomerSubscriptionDeleted(array $payload)
$user->subscriptions->filter(function ($subscription) use ($payload) {
return $subscription->stripe_id === $payload['data']['object']['id'];
})->each(function ($subscription) {
$subscription->markAsCancelled();
$subscription->markAsCanceled();
});
}

Expand Down Expand Up @@ -246,7 +246,7 @@ protected function handleCustomerDeleted(array $payload)
{
if ($user = $this->getUserByStripeId($payload['data']['object']['id'])) {
$user->subscriptions->each(function (Subscription $subscription) {
$subscription->skipTrial()->markAsCancelled();
$subscription->skipTrial()->markAsCanceled();
});

$user->forceFill([
Expand Down
16 changes: 14 additions & 2 deletions src/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,27 @@ public function requiresCapture()
}

/**
* Determine if the payment was cancelled.
* Determine if the payment was canceled.
*
* @return bool
*/
public function isCancelled()
public function isCanceled()
{
return $this->paymentIntent->status === StripePaymentIntent::STATUS_CANCELED;
}

/**
* Determine if the payment was canceled.
*
* @return bool
*
* @deprecated Use isCanceled instead.
*/
public function isCancelled()
{
return $this->isCanceled();
}

/**
* Determine if the payment was successful.
*
Expand Down
82 changes: 67 additions & 15 deletions src/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public function syncStripeStatus()
*/
public function recurring()
{
return ! $this->onTrial() && ! $this->cancelled();
return ! $this->onTrial() && ! $this->canceled();
}

/**
Expand All @@ -285,49 +285,87 @@ public function recurring()
*/
public function scopeRecurring($query)
{
$query->notOnTrial()->notCancelled();
$query->notOnTrial()->notCanceled();
}

/**
* Determine if the subscription is no longer active.
*
* @return bool
*/
public function cancelled()
public function canceled()
{
return ! is_null($this->ends_at);
}

/**
* Filter query by cancelled.
* Determine if the subscription is no longer active.
*
* @return bool
*
* @deprecated Use canceled instead.
*/
public function cancelled()
{
return $this->canceled();
}

/**
* Filter query by canceled.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return void
*/
public function scopeCancelled($query)
public function scopeCanceled($query)
{
$query->whereNotNull('ends_at');
}

/**
* Filter query by not cancelled.
* Filter query by canceled.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return void
*
* @deprecated Use scopeCanceled instead.
*/
public function scopeNotCancelled($query)
public function scopeCancelled($query)
{
$this->scopeCanceled($query);
}

/**
* Filter query by not canceled.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return void
*/
public function scopeNotCanceled($query)
{
$query->whereNull('ends_at');
}

/**
* Filter query by not canceled.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return void
*
* @deprecated Use scopeNotCanceled instead.
*/
public function scopeNotCancelled($query)
{
$this->scopeNotCanceled($query);
}

/**
* Determine if the subscription has ended and the grace period has expired.
*
* @return bool
*/
public function ended()
{
return $this->cancelled() && ! $this->onGracePeriod();
return $this->canceled() && ! $this->onGracePeriod();
}

/**
Expand All @@ -338,7 +376,7 @@ public function ended()
*/
public function scopeEnded($query)
{
$query->cancelled()->notOnGracePeriod();
$query->canceled()->notOnGracePeriod();
}

/**
Expand Down Expand Up @@ -1015,7 +1053,7 @@ public function cancelNow()
'prorate' => $this->prorateBehavior() === 'create_prorations',
]);

$this->markAsCancelled();
$this->markAsCanceled();

return $this;
}
Expand All @@ -1032,19 +1070,19 @@ public function cancelNowAndInvoice()
'prorate' => $this->prorateBehavior() === 'create_prorations',
]);

$this->markAsCancelled();
$this->markAsCanceled();

return $this;
}

/**
* Mark the subscription as cancelled.
* Mark the subscription as canceled.
*
* @return void
*
* @internal
*/
public function markAsCancelled()
public function markAsCanceled()
{
$this->fill([
'stripe_status' => StripeSubscription::STATUS_CANCELED,
Expand All @@ -1053,7 +1091,21 @@ public function markAsCancelled()
}

/**
* Resume the cancelled subscription.
* Mark the subscription as canceled.
*
* @return void
*
* @deprecated Use markAsCanceled instead.
*
* @internal
*/
public function markAsCancelled()
{
$this->markAsCanceled();
}

/**
* Resume the canceled subscription.
*
* @return $this
*
Expand All @@ -1072,7 +1124,7 @@ public function resume()

// Finally, we will remove the ending timestamp from the user's record in the
// local database to indicate that the subscription is active again and is
// no longer "cancelled". Then we will save this record in the database.
// no longer "canceled". Then we shall save this record in the database.
$this->fill([
'stripe_status' => $stripeSubscription->status,
'ends_at' => null,
Expand Down
Loading