Closed movicat closed 5 months ago
/**
* Pause the subscription.
*
* @param bool $pauseNow
* @param \DateTimeInterface|string|null $until
* @return $this
*/
public function pause(bool $pauseNow = false, $until = null)
{
$response = Cashier::api('POST', "subscriptions/{$this->paddle_id}/pause", [
'effective_from' => $pauseNow ? 'immediately' : 'next_billing_period',
'resume_at' => $until ? Carbon::parse($until)->format(DateTimeInterface::RFC3339) : null,
])['data'];
$this->forceFill([
'status' => $response['status'],
'paused_at' => Carbon::parse($response['paused_at'], 'UTC'),
])->save();
$this->syncSubscriptionItems($response['items']);
return $this;
}
Hello, Your method did not record the date from the response when calling the api with the "next billing period" parameter. This is well demonstrated in your "cancel" method.
/**
* Cancel the subscription at the end of the current billing period.
*
* @param bool $cancelNow
* @return $this
*/
public function cancel(bool $cancelNow = false)
{
$response = Cashier::api('POST', "subscriptions/{$this->paddle_id}/cancel", [
'effective_from' => $cancelNow ? 'immediately' : 'next_billing_period',
])['data'];
$endsAt = $cancelNow ? $response['canceled_at'] : $response['scheduled_change']['effective_at'];
$this->forceFill([
'status' => $response['status'],
'ends_at' => Carbon::parse($endsAt, 'UTC'),
'trial_ends_at' => $cancelNow ? null : $this->trial_ends_at,
])->save();
return $this;
}
If there was a "Scheduled pause", the method recorded the wrong date.