You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,20 @@ iap.cancelSubscription("google", payment, function (error, response) {
57
57
});
58
58
```
59
59
60
+
### Subscription deferral ( Google Play only )
61
+
62
+
Google exposes [an API for deferral](https://developers.google.com/android-publisher/api-ref/purchases/subscriptions/defer) of recurring suscriptions. This might be used to extend a user's subscription purchase until a specified future expiration time ( useful to grant your users some free days or months ).
63
+
64
+
```javascript
65
+
var deferralInfo = {
66
+
expectedExpiryTimeMillis:1546616722237,
67
+
desiredExpiryTimeMillis:1547716722237,
68
+
};
69
+
iap.deferSubscription("google", payment, deferralInfo, function (error, response) {
Copy file name to clipboardExpand all lines: lib/google/index.js
+60Lines changed: 60 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -41,6 +41,17 @@ function validatePaymentAndParseKeyObject(payment) {
41
41
returnkeyObject;
42
42
}
43
43
44
+
functionvalidateDeferralInfo(deferralInfo){
45
+
assert.equal(typeofdeferralInfo,'object','deferralInfo must be an object');
46
+
assert.equal(typeofdeferralInfo.expectedExpiryTimeMillis,'number','expectedExpiryTimeMillis must be a number');
47
+
assert.equal(typeofdeferralInfo.desiredExpiryTimeMillis,'number','desiredExpiryTimeMillis must be a number');
48
+
49
+
assert(deferralInfo.desiredExpiryTimeMillis>deferralInfo.expectedExpiryTimeMillis,'desiredExpiryTimeMillis must be greater than expectedExpiryTimeMillis');
50
+
51
+
returndeferralInfo;
52
+
}
53
+
54
+
44
55
exports.verifyPayment=function(payment,cb){
45
56
letkeyObject;
46
57
@@ -133,3 +144,52 @@ exports.cancelSubscription = function (payment, cb) {
0 commit comments