Check Purchase Subscriptions Expire Date
npm install google_subscriptionsA small library that allows to retrieve the expiration date of a purchase subscription
npm install google_subscriptions --save
``typescript
import * as Express from "express"
import { GoogleSubscription } from "google_subscriptions"
let app = Express()
//Check the expiration date of a given subscription
let googleSubscription = new GoogleSubscription(process.env.PACKAGE_NAME ,
process.env.PRODUCT_ID,
process.env.SECRET_FILE_PATH,
process.env.CLIENT_KEY,
process.env.SERVICE_ACCOUNT_EMAIL );
googleSubscription.checkExpire(token, ( err, res_t ) => {
if (err) {
console.log("error : " + err);
res.json({"error : " : err});
}else{
console.log("token expire" + res_t);
res.json({"expiryTimeMillis" : res_t });
}
});
// OR
app.use("/subscription", googleSubscription.router())
// http://www.example.com/subscription/expire/{token}
// result
// {"expiryTimeMillis":1528337069881}
`Tests
npm test`
In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.