Guest User

Untitled

a guest
Mar 10th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. var billingClient: BillingClient = BillingClient.newBuilder(context).setListener(this).enablePendingPurchases().build()
  2.  
  3. fun getActiveSubs()
  4. {
  5. var purchasesResult = billingClient.queryPurchases(BillingClient.SkuType.SUBS)
  6. val ids: ArrayList<Purchase> = ArrayList()
  7.  
  8. if (!purchasesResult.purchasesList.isNullOrEmpty())
  9. {
  10. purchasesResult.purchasesList.sortBy { it.purchaseTime }
  11. purchasesResult.purchasesList.forEach {
  12. if (it.isAcknowledged)
  13. {
  14. ids.add(it)
  15. }
  16. }
  17. }
  18.  
  19. if (ids.isNotEmpty())
  20. {
  21. val payment = ids.get(ids.size - 1)
  22.  
  23. CoroutineScope(Dispatchers.IO).launch {
  24. Log.d("SUB_INFO","SEND_SUB_SUB_BILING")
  25. UserRepo().setPaymentSub(RBApp.getRBApp(app).getUserAuthApiToken(), payment.purchaseToken, payment.sku)
  26. }
  27.  
  28. ldActiveSubs.postValue(payment)
  29. }
  30. else
  31. ldActiveSubs.postValue(null)
  32. }
Advertisement
Add Comment
Please, Sign In to add comment