Skip to content

Commit ca7cf74

Browse files
committed
Check if subscription is cancelled
1 parent 61d97a1 commit ca7cf74

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ $receipt = GooglePlaySubscription::check($subscriptionId, $purchaseToken);
4040
if($receipt->isValid()){
4141
$receipt->persist();
4242
// extend user's subscription
43+
44+
if ($receipt->isAutoRenewing()){
45+
// schedule next auto-renewing
46+
}
4347
}
4448

4549
// ...

src/GooglePlay/Subscriptions/Subscription.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,19 @@ private function isValidPayment(): bool
179179
return $paymentState === self::PAYMENT_STATE_RECEIVED || $paymentState === self::PAYMENT_STATE_FREE_TRIAL;
180180
}
181181

182+
/**
183+
* @return bool
184+
*/
182185
public function isAutoRenewing(): bool
183186
{
184187
return $this->getResponse()->isAutoRenewing();
185188
}
189+
190+
/**
191+
* @return bool
192+
*/
193+
public function isCancelled(): bool
194+
{
195+
return $this->getResponse()->getUserCancellationTimeMillis() > -1;
196+
}
186197
}

0 commit comments

Comments
 (0)