|
|
@@ -1,6 +1,7 @@
|
|
|
-package com.atmob.voiceai.sdk.billing.operation;
|
|
|
+package com.atmob.voiceai.sdk.billing.classify;
|
|
|
|
|
|
import android.app.Activity;
|
|
|
+import android.text.TextUtils;
|
|
|
|
|
|
import com.android.billingclient.api.BillingClient;
|
|
|
import com.android.billingclient.api.BillingFlowParams;
|
|
|
@@ -14,13 +15,13 @@ import java.util.Objects;
|
|
|
|
|
|
import atmob.reactivex.rxjava3.core.Single;
|
|
|
|
|
|
-public class Subscription {
|
|
|
+public class Purchases {
|
|
|
|
|
|
- private static final String TAG = Subscription.class.getSimpleName();
|
|
|
+ private static final String TAG = Purchases.class.getSimpleName();
|
|
|
|
|
|
|
|
|
- public static Single<BillingResult> subscriptionGoods(BillingClient billingClient, Activity activity, Object productDetails, String basePlanId, String orderNo) {
|
|
|
- if (billingClient.isFeatureSupported(BillingClient.FeatureType.PRODUCT_DETAILS).getResponseCode() == BillingClient.BillingResponseCode.OK) {
|
|
|
+ public static Single<BillingResult> launchPurchaseGoods(BillingClient billingClient, Activity activity, Object productDetails, String basePlanId, String orderNo) {
|
|
|
+ if (FeatureSupported.isFeatureSupported(billingClient, BillingClient.FeatureType.PRODUCT_DETAILS)) {
|
|
|
return launchProductBillingFlow(billingClient, activity, productDetails, basePlanId, orderNo);
|
|
|
} else {
|
|
|
return launchSkuBillingFlow(billingClient, activity, productDetails, orderNo);
|
|
|
@@ -39,14 +40,15 @@ public class Subscription {
|
|
|
if (subscriptionOfferDetails != null) {
|
|
|
offerToken = subscriptionOfferDetails.getOfferToken();
|
|
|
}
|
|
|
+ BillingFlowParams.ProductDetailsParams.Builder builder = BillingFlowParams.ProductDetailsParams.newBuilder()
|
|
|
+ .setProductDetails(details);
|
|
|
+ if (!TextUtils.isEmpty(offerToken)) {
|
|
|
+ builder.setOfferToken(offerToken);
|
|
|
+ }
|
|
|
BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder()
|
|
|
.setObfuscatedAccountId(orderNo)
|
|
|
.setIsOfferPersonalized(true)
|
|
|
- .setProductDetailsParamsList(Collections.singletonList(
|
|
|
- BillingFlowParams.ProductDetailsParams.newBuilder()
|
|
|
- .setProductDetails(details)
|
|
|
- .setOfferToken(offerToken)
|
|
|
- .build()))
|
|
|
+ .setProductDetailsParamsList(Collections.singletonList(builder.build()))
|
|
|
.build();
|
|
|
return Single.fromCallable(() -> {
|
|
|
BillingResult billingResult = billingClient.launchBillingFlow(activity, billingFlowParams);
|