Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private fun getPublisherInfo(subscriptionCallback: Callback<Subscription>) {
- td?.let {
- val subscription = subscriptionInstance.subscriptionExpiresOn(it.purchaseInfo.purchaseData.purchaseToken)
- subscription.enqueue(subscriptionCallback)
- }
- }
- fun updateExpirationDate(){
- if (isPremium()) {
- val saveEndDate = getEndDateSaved()
- if ((saveEndDate != null && getRemainingDays() < 0) || saveEndDate == null ) {
- //need to get the expire date
- td?.purchaseInfo?.purchaseData?.purchaseToken?.let { token ->
- getPublisherInfo( token, subscriptionCallback )
- }
- getPublisherInfo(object : Callback<Subscription> {
- override fun onResponse(call: Call<Subscription>, response: Response<Subscription>) {
- val b = response.body() ?: return
- val expireDate = Date(b.expiryTimeMillis)
- StorageUtils.writePremiumEndDate(ctx, expireDate)
- Log.d(TAG, "Subscription date : " + expireDate)
- }
- override fun onFailure(call: Call<Subscription>, t: Throwable) {
- Log.e(TAG, "e : " + t.localizedMessage)
- }
- })
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment