এই নির্দেশিকায় Play Billing Library API-এর সাথে আপনার অ্যাপ কীভাবে ইন্টিগ্রেট করবেন তা বর্ণনা করা হয়েছে যাতে আপনি ব্যবহারকারীদের বিলিংয়ের বিকল্প অফার করতে পারেন।
PBL-এর সাথে ইন্টিগ্রেশন
আপনি চারটি পরিস্থিতিতে PBL-এর সাথে বিলিং সংক্রান্ত পছন্দ ইন্টিগ্রেট করতে পারবেন। কে পছন্দ স্ক্রিন রেন্ডার করে এবং কোথায় পেমেন্ট হবে তার উপর ভিত্তি করে পরিস্থিতি আলাদা হয়। নিচের সারণীতে ইন্টিগ্রেশন সংক্রান্ত পরিস্থিতি উল্লেখ করা হয়েছে:
| আপনি কোন বিলিং চয়েস স্ক্রিন রেন্ডার করতে চান? | |||
| Google Play-এর | আপনার নিজের (UX নির্দেশিকা অনুযায়ী) | ||
| পেমেন্ট কোথায় করা হয়? | অ্যাপ-মধ্যস্থ | পরিস্থিতির উদাহরণ 1A
Google পছন্দ স্ক্রিন দেখায় এবং আপনার অ্যাপের মধ্যে বিকল্প বিলিং ম্যানেজ করা হয়। |
পরিস্থিতির উদাহরণ 1B
অ্যাপ ডেভেলপার পছন্দ স্ক্রিন দেখায় এবং বিকল্প বিলিং আপনার অ্যাপের মধ্যে ম্যানেজ করা হয়। |
| এক্সটার্নাল ওয়েব লিঙ্ক | পরিস্থিতির উদাহরণ 2A
Google পছন্দ স্ক্রিন দেখায় এবং কেনাকাটার জন্য ব্যবহারকারীকে আপনার অ্যাপের বাইরে আপনার নিজস্ব ওয়েবসাইটে লিঙ্ক করা হয়। |
পরিস্থিতি ২খ
অ্যাপ ডেভেলপার পছন্দের স্ক্রিন দেখান এবং কেনাকাটার জন্য ব্যবহারকারীকে আপনার অ্যাপের বাইরে আপনার নিজস্ব ওয়েবসাইটে লিঙ্ক করা হয়। |
|
নিম্নলিখিত ছবি থেকে এই ধরনের প্রতিটি পরিস্থিতির জন্য বিলিং সংক্রান্ত বিকল্পের ফ্লো সম্পর্কে বিস্তারিত জানতে পারবেন:
PBL ইন্টিগ্রেশন সংক্রান্ত পরিস্থিতি
আপনার ইন্টিগ্রেশন পরিস্থিতির উপর নির্ভর করে, আপনার অ্যাপে বিলিং সংক্রান্ত পছন্দ প্রয়োগ করতে এই বিভাগের ধাপগুলি অনুসরণ করুন।
পরিস্থিতি 1A ম্যানেজ করুন
Google পছন্দ স্ক্রিন রেন্ডার করে এবং বিকল্প বিলিং আপনার অ্যাপের মধ্যে ম্যানেজ করা হয়। এই পরিস্থিতিতে বিলিং পছন্দ চালু করতে নিম্নলিখিত ধাপগুলি অনুসরণ করুন:
BillingClient ইনস্ট্যান্স তৈরি করার সময়
EnableBillingProgramParams-এর সাথেenableBillingProgramকল করুন এবং তারপরে কানেকশন শুরু করুন। যেমন:Kotlin
// Build the parameters to enable the Billing Choice program and assign the listener // to handle user selection of the developer-provided billing option. val enableBillingProgramParams = EnableBillingProgramParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .setDeveloperProvidedBillingListener(developerProvidedBillingListener) .build() // Build the parameters to enable support for pending purchases. val pendingPurchasesParams = PendingPurchasesParams.newBuilder() .enableOneTimeProducts() .build() // Construct the BillingClient instance with the purchases updated listener, // pending purchases support, and the billing choice params. val billingClient = BillingClient.newBuilder(context) .setListener(purchasesUpdatedListener) .enablePendingPurchases(pendingPurchasesParams) .enableBillingProgram(enableBillingProgramParams) .build() // Establish a connection to Google Play val billingResult = suspendCancellableCoroutine<BillingResult> { continuation -> billingClient.startConnection(object : BillingClientStateListener { // Called when the connection setup process completes. override fun onBillingSetupFinished(billingResult: BillingResult) { // Resume the coroutine and pass back the BillingResult to the caller. if (continuation.isActive) { continuation.resume(billingResult) } } // Called if the connection to the Play Store service is dropped. // This prevents the await or suspension point from hanging indefinitely. override fun onBillingServiceDisconnected() { if (continuation.isActive) { continuation.resume( BillingResult.newBuilder() .setResponseCode(BillingResponseCode.SERVICE_DISCONNECTED) .setDebugMessage("Billing service disconnected during connection setup") .build() ) } } }) }
জাভা
EnableBillingProgramParams params = EnableBillingProgramParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .setDeveloperProvidedBillingListener(developerProvidedBillingListener) .build(); BillingClient billingClient = BillingClient.newBuilder(context) .setListener(purchasesUpdatedListener) .enablePendingPurchases( PendingPurchasesParams.newBuilder() .enableOneTimeProducts() .build() ) .enableBillingProgram(params) .build();ব্যবহারকারীর জন্য Google-এর রেন্ডার করা বিলিং সংক্রান্ত পছন্দ উপলভ্য কিনা তা যাচাই করুন।
প্রোগ্রামের উপলভ্যতা চেক করতে
isBillingProgramAvailableAsyncকল করুন এবং তারপর উপলভ্য প্রোডাক্ট দেখতেqueryProductDetailsAsyncকল করুন। যেমন:Kotlin
val (billingResult, billingProgramAvailabilityDetails) = billingClient.isBillingProgramAvailable(BillingProgram.BILLING_CHOICE) if (billingResult.responseCode == BillingResponseCode.OK) { val billingChoiceAvailabilityDetails = billingProgramAvailabilityDetails.billingChoiceAvailabilityDetails if (billingChoiceAvailabilityDetails != null && billingChoiceAvailabilityDetails.choiceScreenType == ChoiceScreenType.GOOGLE_RENDERED ) { // Billing choice is available. Query products and proceed. } else { // Fallback to other available programs. } } else { // Fallback to other available programs. }
জাভা
// ... billingClient.isBillingProgramAvailableAsync( BillingProgram.BILLING_CHOICE, (billingResult, billingProgramAvailabilityDetails) -> { if (billingResult.getResponseCode() == BillingResponseCode.OK) { BillingChoiceAvailabilityDetails billingChoiceAvailabilityDetails = billingProgramAvailabilityDetails.getBillingChoiceAvailabilityDetails(); if (billingChoiceAvailabilityDetails != null && billingChoiceAvailabilityDetails.getChoiceScreenType() == ChoiceScreenType.GOOGLE_RENDERED) { // Billing choice is available. Query products and proceed. } else { // Fallback to other available programs. } } else { // Fallback to other available programs. } } );মনে রাখবেন: Google বা ডেভেলপার রেন্ডার করা বিলিং সংক্রান্ত পছন্দের স্ক্রিন উপলভ্য আছে কিনা তা
billingProgramAvailabilityDetailsআপনাকে জানায়।ব্যবহারকারী 'কিনুন' বোতামে ক্লিক করলে, কেনাকাটা সম্পর্কিত ফ্লো ট্রিগার করতে
launchBillingFlowকল করুন। বিলিংয়ের বিকল্প উপলভ্য থাকলে,DeveloperBillingOptionParamsথেকেBillingFlowParams-এ পাস করুন। যেমন:Kotlin
val developerBillingOptionParams = DeveloperBillingOptionParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .build() val billingFlowParams = BillingFlowParams.newBuilder() .setProductDetailsParamsList(productDetailsParamsList) .enableDeveloperBillingOption(developerBillingOptionParams) .build() val billingResult = billingClient.launchBillingFlow(activity, billingFlowParams)
জাভা
DeveloperBillingOptionParams developerBillingOptionParams = DeveloperBillingOptionParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .build(); BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder() .setProductDetailsParamsList(productDetailsParamsList) .enableDeveloperBillingOption(developerBillingOptionParams) .build(); BillingResult billingResult = billingClient.launchBillingFlow(activity, billingFlowParams);মনে রাখবেন: তত্ত্বাবধানে থাকা ব্যবহারকারীদের জন্য অভিভাবকীয় নিয়ন্ত্রণ দেখানো হয়।
বিলিংয়ের ধরন সংক্রান্ত ব্যবহারকারীর পছন্দ এইভাবে ম্যানেজ করুন:
- ব্যবহারকারী Play Billing বেছে নিলে, বিলিংয়ের ফলাফল
PurchasesUpdatedListener-এ ফেরত পাঠানো হয় যা ধাপ ১-এ রেজিস্টার করা হয়েছে। - ব্যবহারকারী আপনার বিকল্প বিলিং বেছে নিলে, বিলিংয়ের ফলাফল
ধাপ ১-এ রেজিস্টার করা
DeveloperProvidedBillingListener-এ ফেরত পাঠানো হয়। ফেরত আসাDeveloperProvidedBillingDetails-এ এই ক্ষেত্রে একটিexternalTransactionTokenরয়েছে। টোকেনটি ট্রানজ্যাকশন রিপোর্টিংয়ের জন্য ব্যবহার করা হবে।
- ব্যবহারকারী Play Billing বেছে নিলে, বিলিংয়ের ফলাফল
পরিস্থিতি 1B ম্যানেজ করা
ডেভেলপার পছন্দ স্ক্রিন রেন্ডার করেন এবং বিকল্প বিলিং আপনার অ্যাপের মধ্যে ম্যানেজ করা হয়। এই পরিস্থিতিতে বিলিং সংক্রান্ত পছন্দ চালু করতে নিম্নলিখিত ধাপগুলি অনুসরণ করুন:
BillingClientইনস্ট্যান্স তৈরি করার সময়EnableBillingProgramParams-এDeveloperProvidedBillingListenerছাড়াenableBillingProgramকল করুন এবং তারপরে কানেকশন শুরু করুন। যেমন:Kotlin
// Build the parameters to enable the Billing Choice program. val enableBillingProgramParams = EnableBillingProgramParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .build() // Build the parameters to enable support for pending purchases. val pendingPurchasesParams = PendingPurchasesParams.newBuilder() .enableOneTimeProducts() .build() // Construct the BillingClient instance with the purchases updated listener, // pending purchases support, and the billing choice params. val billingClient = BillingClient.newBuilder(context) .setListener(purchasesUpdatedListener) .enablePendingPurchases(pendingPurchasesParams) .enableBillingProgram(enableBillingProgramParams) .build() // Establish a connection to Google Play val billingResult = suspendCancellableCoroutine<BillingResult> { continuation -> billingClient.startConnection(object : BillingClientStateListener { // Called when the connection setup process completes. override fun onBillingSetupFinished(billingResult: BillingResult) { // Resume the coroutine and pass back the BillingResult to the caller. if (continuation.isActive) { continuation.resume(billingResult) } } // Called if the connection to the Play Store service is dropped. // This prevents the await or suspension point from hanging indefinitely. override fun onBillingServiceDisconnected() { if (continuation.isActive) { continuation.resume( BillingResult.newBuilder() .setResponseCode(BillingResponseCode.SERVICE_DISCONNECTED) .setDebugMessage("Billing service disconnected during connection setup") .build() ) } } }) }
জাভা
EnableBillingProgramParams params = EnableBillingProgramParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .build(); BillingClient billingClient = BillingClient.newBuilder(context) .setListener(purchasesUpdatedListener) .enablePendingPurchases() .enableBillingProgram(params) .build();ডেভেলপারের রেন্ডার করা বিলিং সংক্রান্ত পছন্দ ব্যবহারকারীর জন্য উপলভ্য কিনা তা যাচাই করুন।
প্রোগ্রামের উপলভ্যতা চেক করতে
isBillingProgramAvailableAsyncকল করুন এবং তারপর উপলভ্য প্রোডাক্ট দেখতেqueryProductDetailsAsyncকল করুন। যেমন:Kotlin
val (billingResult, billingProgramAvailabilityDetails) = billingClient.isBillingProgramAvailable(BillingProgram.BILLING_CHOICE) if (billingResult.responseCode == BillingResponseCode.OK) { val billingChoiceAvailabilityDetails = billingProgramAvailabilityDetails.billingChoiceAvailabilityDetails if (billingChoiceAvailabilityDetails != null && billingChoiceAvailabilityDetails.choiceScreenType == ChoiceScreenType.DEVELOPER_RENDERED ) { // Billing choice is available. Query products and proceed. // You can inspect details such as: // - billingChoiceAvailabilityDetails.choiceScreenType // - billingChoiceAvailabilityDetails.isExternalLinkAvailable } else { // Fallback to other available programs. } } else { // Fallback to other available programs. }
জাভা
// ... billingClient.isBillingProgramAvailableAsync( BillingProgram.BILLING_CHOICE, (billingResult, billingProgramAvailabilityDetails) -> { if (billingResult.getResponseCode() == BillingResponseCode.OK) { BillingChoiceAvailabilityDetails billingChoiceAvailabilityDetails = billingProgramAvailabilityDetails.getBillingChoiceAvailabilityDetails(); if (billingChoiceAvailabilityDetails != null && billingChoiceAvailabilityDetails.getChoiceScreenType() == ChoiceScreenType.DEVELOPER_RENDERED) { // Billing choice is available. Query products and proceed. // You can inspect details such as: // - billingChoiceAvailabilityDetails.getChoiceScreenType() // - billingChoiceAvailabilityDetails.isExternalLinkAvailable() } else { // Fallback to other available programs. } } else { // Fallback to other available programs. } } );মনে রাখবেন:
billingProgramAvailabilityDetailsআপনাকে জানায় যে Google-এর রেন্ডার করা বা ডেভেলপারের রেন্ডার করা বিলিং সংক্রান্ত পছন্দের স্ক্রিন উপলভ্য আছে কিনা।Play Billing ব্যানার ও লয়ালটি সংক্রান্ত তথ্য পেতে
getBillingChoiceInfoAsyncপদ্ধতি কল করুন। যেমন:Kotlin
// 1. Create the params required for the request val params = GetBillingChoiceInfoParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .setPlayBillingChoiceImageLayout(GetBillingChoiceInfoParams.ImageLayout.RECTANGULAR_FOUR_BY_ONE) .build() // 2. Call the suspend method on your billingClient instance val (billingResult, playBillingChoiceInfo) = billingClient.getBillingChoiceInfo(params) if (billingResult.responseCode == BillingResponseCode.OK && playBillingChoiceInfo != null) { // Access the URL of the image associated with the Play Billing Choice val imageUrl = playBillingChoiceInfo.playBillingChoiceImageUrl // Access the Play Loyalty string information, if available val loyaltyInfo = playBillingChoiceInfo.playBillingLoyaltyInfo // Populate your developer-rendered UI elements playBillingLoyaltyTextView.text = loyaltyInfo loadImage(imageUrl, playBillingImageView) } else { // Handle error scenarios }
জাভা
// 1. Create the params required for the request GetBillingChoiceInfoParams params = GetBillingChoiceInfoParams.newBuilder() .setBillingProgram(BillingClient.BillingProgram.BILLING_CHOICE) .setPlayBillingChoiceImageLayout(GetBillingChoiceInfoParams.ImageLayout.RECTANGULAR_FOUR_BY_ONE) .build(); // 2. Call the method asynchronously on your billingClient instance billingClient.getBillingChoiceInfoAsync(params, (billingResult, playBillingChoiceInfo) -> { if (billingResult.getResponseCode() == BillingResponseCode.OK && playBillingChoiceInfo != null) { // Access the URL of the image associated with the Play Billing Choice String imageUrl = playBillingChoiceInfo.getPlayBillingChoiceImageUrl(); // Access the Play Loyalty string information, if available String loyaltyInfo = playBillingChoiceInfo.getPlayBillingLoyaltyInfo(); // Populate your developer-rendered UI elements playBillingLoyaltyTextView.setText(loyaltyInfo); loadImage(imageUrl, playBillingImageView); } else { // Handle error scenarios } });DeveloperBillingType IN_APP-এ সেট করে এক্সটার্নাল ট্রানজ্যাকশন টোকেন তৈরি করুন। যেমন:
Kotlin
// Build the parameters specifying the billing program and that the billing type is IN_APP. val params = BillingProgramReportingDetailsParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .setDeveloperBillingType(DeveloperBillingType.IN_APP) .build() // Call the suspending extension function to request the reporting details val (billingResult, billingProgramReportingDetails) = billingClient.createBillingProgramReportingDetails(params) if (billingResult.responseCode != BillingResponseCode.OK) { // Handle failures such as retrying due to network errors. return } // Extract the transaction token from the returned reporting details val transactionToken = billingProgramReportingDetails?.externalTransactionToken // Persist the external transaction token locally. Pass it to // DeveloperBillingOptionParams when launchBillingFlow is called. // It can also be used as part of your external website
জাভা
BillingProgramReportingDetailsParams params = BillingProgramReportingDetailsParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .setDeveloperBillingType(DeveloperBillingType.IN_APP) .build(); billingClient.createBillingProgramReportingDetailsAsync( params, new BillingProgramReportingDetailsListener() { @Override public void onCreateBillingProgramReportingDetailsResponse( BillingResult billingResult, @Nullable BillingProgramReportingDetails billingProgramReportingDetails ) { if (billingResult.getResponseCode() != BillingResponseCode.OK) { // Handle failures such as retrying due to network errors. return; } String transactionToken = billingProgramReportingDetails.getExternalTransactionToken(); // Persist the external transaction token locally. Pass it to // DeveloperBillingOptionParams when launchBillingFlow is called. // It can also be used as part of your external website } } );ব্যবহারকারী 'কিনুন' বিকল্পে ক্লিক করলে, তথ্য সংক্রান্ত ডায়ালগ দেখাতে
showBillingProgramInformationDialogকল করুন। যেমন, ব্যবহারকারীদের জন্য তথ্য ডায়ালগ দেখুন। অনুরোধে ৪ নম্বর ধাপ থেকে BillingProgram এবং transactionToken সেট করতে হবে।মনে রাখবেন: তত্ত্বাবধানে থাকা ব্যবহারকারীদের জন্য অভিভাবকীয় নিয়ন্ত্রণ দেখানো হয়।
পূর্ববর্তী ধাপের ফলাফল
OKহলে, আপনার বিকল্প বিলিং পছন্দ স্ক্রিন চালু করুন।বিলিংয়ের ধরন সংক্রান্ত ব্যবহারকারীর পছন্দ এইভাবে ম্যানেজ করুন:
- ব্যবহারকারী Play Billing বেছে নিলে, স্ট্যান্ডার্ড Play Billing নির্দেশিকা
অনুসরণ করে
launchBillingFlowকল করুন। বিলিংয়ের ফলাফলPurchasesUpdatedListener-এ ফেরত পাঠানো হয় যা ১ নম্বর ধাপে রেজিস্টার করা হয়েছে। - ব্যবহারকারী আপনার বিকল্প বিলিং বেছে নিলে, আপনাকে নিজেই ট্রানজ্যাকশন ম্যানেজ করতে হবে এবং ৪ নম্বর ধাপে জেনারেট করা টোকেন ব্যবহার করে Play-তে রিপোর্ট করতে হবে।
- ব্যবহারকারী Play Billing বেছে নিলে, স্ট্যান্ডার্ড Play Billing নির্দেশিকা
অনুসরণ করে
পরিস্থিতি 2A ম্যানেজ করুন
Google পছন্দ স্ক্রিন রেন্ডার করে এবং বিকল্প বিলিং আপনার অ্যাপের বাইরে ম্যানেজ করা হয়। এই পরিস্থিতিতে বিলিং পছন্দ চালু করতে নিম্নলিখিত ধাপগুলি অনুসরণ করুন:
BillingClient ইনস্ট্যান্স তৈরি করার সময়
EnableBillingProgramParams-এর সাথেenableBillingProgramকল করুন এবং তারপরে কানেকশন শুরু করুন। যেমন:Kotlin
// Build the parameters to enable the Billing Choice program and assign the listener // to handle user selection of the developer-provided billing option. val enableBillingProgramParams = EnableBillingProgramParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .setDeveloperProvidedBillingListener(developerProvidedBillingListener) .build() // Build the parameters to enable support for pending purchases. val pendingPurchasesParams = PendingPurchasesParams.newBuilder() .enableOneTimeProducts() .build() // Construct the BillingClient instance with the purchases updated listener, // pending purchases support, and the billing choice params. val billingClient = BillingClient.newBuilder(context) .setListener(purchasesUpdatedListener) .enablePendingPurchases(pendingPurchasesParams) .enableBillingProgram(enableBillingProgramParams) .build() // Establish a connection to Google Play val billingResult = suspendCancellableCoroutine<BillingResult> { continuation -> billingClient.startConnection(object : BillingClientStateListener { // Called when the connection setup process completes. override fun onBillingSetupFinished(billingResult: BillingResult) { // Resume the coroutine and pass back the BillingResult to the caller. if (continuation.isActive) { continuation.resume(billingResult) } } // Called if the connection to the Play Store service is dropped. // This prevents the await or suspension point from hanging indefinitely. override fun onBillingServiceDisconnected() { if (continuation.isActive) { continuation.resume( BillingResult.newBuilder() .setResponseCode(BillingResponseCode.SERVICE_DISCONNECTED) .setDebugMessage("Billing service disconnected during connection setup") .build() ) } } }) }
জাভা
EnableBillingProgramParams params = EnableBillingProgramParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .setDeveloperProvidedBillingListener(developerProvidedBillingListener) .build(); BillingClient billingClient = BillingClient.newBuilder(context) .setListener(purchasesUpdatedListener) .enablePendingPurchases( PendingPurchasesParams.newBuilder() .enableOneTimeProducts() .build() ) .enableBillingProgram(params) .build();নিম্নলিখিত বিষয়গুলি উপলভ্য আছে কিনা তা যাচাই করুন:
- Google-এর মাধ্যমে রেন্ডার করা বিলিংয়ের বিভিন্ন বিকল্প
- এক্সটার্নাল ওয়েব লিঙ্ক
প্রোগ্রামের উপলভ্যতা চেক করতে
isBillingProgramAvailableAsyncনম্বরে কল করুন এবং তারপর উপলভ্য প্রোডাক্ট দেখতেqueryProductDetailsAsyncনম্বরে কল করুন। যেমন:Kotlin
// Check the availability of the billing choice program asynchronously using coroutines val (billingResult, billingProgramAvailabilityDetails) = billingClient.isBillingProgramAvailable(BillingProgram.BILLING_CHOICE) // Ensure the billing program query succeeded if (billingResult.responseCode == BillingResponseCode.OK) { // Retrieve the availability details specific to the billing choice program val billingChoiceAvailabilityDetails = billingProgramAvailabilityDetails.billingChoiceAvailabilityDetails // Check if billing choice is available, renders via Google Play, and external link is supported if (billingChoiceAvailabilityDetails != null && billingChoiceAvailabilityDetails.choiceScreenType == ChoiceScreenType.GOOGLE_RENDERED && billingChoiceAvailabilityDetails.isExternalLinkAvailable ) { // Billing choice is available and external transaction links are supported. Query products and proceed. } else { // Fallback to other available programs. } } else { // Fallback to other available programs. }
জাভা
// ... billingClient.isBillingProgramAvailableAsync( BillingProgram.BILLING_CHOICE, (billingResult, billingProgramAvailabilityDetails) -> { if (billingResult.getResponseCode() == BillingResponseCode.OK) { BillingChoiceAvailabilityDetails billingChoiceAvailabilityDetails = billingProgramAvailabilityDetails.getBillingChoiceAvailabilityDetails(); if (billingChoiceAvailabilityDetails != null && billingChoiceAvailabilityDetails.getChoiceScreenType() == ChoiceScreenType.GOOGLE_RENDERED && billingChoiceAvailabilityDetails.isExternalLinkAvailable()) { // Billing choice is available and external transaction links are supported. // Query products and proceed. } else { // Fallback to other available programs. } } else { // Fallback to other available programs. } } );ব্যবহারকারী কেনার ইচ্ছা প্রকাশ করলে, এক্সটার্নাল ট্রানজ্যাকশন টোকেন তৈরি করতে
createBillingProgramReportingDetailsAsyncকল করুন। যেমন:Kotlin
// Build the parameters for creating reporting details val params = BillingProgramReportingDetailsParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .setDeveloperBillingType(DeveloperBillingType.EXTERNAL_LINK) .build() // Call the suspend function to create billing program reporting details val (billingResult, billingProgramReportingDetails) = billingClient.createBillingProgramReportingDetails(params) // Handle response failure cases if (billingResult.responseCode != BillingResponseCode.OK) { // Handle failures such as retrying due to network errors. return } // Retrieve the external transaction token val transactionToken = billingProgramReportingDetails?.externalTransactionToken // Persist the external transaction token locally. Pass it to // DeveloperBillingOptionParams when launchBillingFlow is called. // It can also be used as part of your external website
জাভা
BillingProgramReportingDetailsParams params = BillingProgramReportingDetailsParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .setDeveloperBillingType(DeveloperBillingType.EXTERNAL_LINK) .build(); billingClient.createBillingProgramReportingDetailsAsync( params, new BillingProgramReportingDetailsListener() { @Override public void onCreateBillingProgramReportingDetailsResponse( BillingResult billingResult, @Nullable BillingProgramReportingDetails billingProgramReportingDetails ) { if (billingResult.getResponseCode() != BillingResponseCode.OK) { // Handle failures such as retrying due to network errors. return; } String transactionToken = billingProgramReportingDetails.getExternalTransactionToken(); // Persist the external transaction token locally. Pass it to // DeveloperBillingOptionParams when launchBillingFlow is called. // It can also be used as part of your external website. } } );ব্যবহারকারী 'কিনুন' বোতামে ক্লিক করলে, কেনাকাটা সম্পর্কিত ফ্লো ট্রিগার করতে
launchBillingFlowকল করুন। ব্যবহারকারীর জন্য বিলিংয়ের বিকল্প উপলভ্য থাকলে, নিম্নলিখিত কাজগুলি করুন:DeveloperBillingOptionParamsথেকেBillingFlowParams-এ পাস করুন।- ধাপ ৩ থেকে এক্সটার্নাল ট্রানজ্যাকশন টোকেন
DeveloperBillingOptionParams-এ পাস করুন।
যেমন:
Kotlin
// Build the developer billing option parameters with the external link URI, // the transaction token, and browser/app launch mode. val developerBillingOptionParams = DeveloperBillingOptionParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .setLinkUri(Uri.parse("https://www.example.com/external/purchase")) .setExternalTransactionToken(transactionToken) .setLaunchMode( DeveloperBillingOptionParams.LaunchMode.LAUNCH_IN_EXTERNAL_BROWSER_OR_APP ) .build() val billingFlowParams = BillingFlowParams.newBuilder() .setProductDetailsParamsList(productDetailsParamsList) .enableDeveloperBillingOption(developerBillingOptionParams) .build() val billingResult = billingClient.launchBillingFlow(activity, billingFlowParams)
জাভা
DeveloperBillingOptionParams developerBillingOptionParams = DeveloperBillingOptionParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .setLinkUri(Uri.parse("https://www.example.com/external/purchase")) .setExternalTransactionToken(transactionToken) .setLaunchMode( DeveloperBillingOptionParams.LaunchMode.LAUNCH_IN_EXTERNAL_BROWSER_OR_APP) .build();মনে রাখবেন: তত্ত্বাবধানে থাকা ব্যবহারকারীদের জন্য অভিভাবকীয় নিয়ন্ত্রণ দেখানো হয়।
বিলিংয়ের ধরন সংক্রান্ত ব্যবহারকারীর পছন্দ এইভাবে ম্যানেজ করুন:
- ব্যবহারকারী Play Billing বেছে নিলে, স্ট্যান্ডার্ড Play Billing নির্দেশিকা
অনুসরণ করে
launchBillingFlowকল করুন। বিলিংয়ের ফলাফলPurchasesUpdatedListener-এ ফেরত পাঠানো হয় যা ১ নম্বর ধাপে রেজিস্টার করা হয়েছে। - ব্যবহারকারী আপনার বিকল্প বিলিং বেছে নিলে, বিলিংয়ের ফলাফল
DeveloperProvidedBillingListener-এ ফেরত পাঠানো হয় যা ধাপ- -এ রেজিস্টার করা আছে
- ফেরত পাঠানো
DeveloperProvidedBillingDetails-এexternalTransactionTokenথাকে যা ৪ নম্বর ধাপেDeveloperBillingOptionParams-এ পাস করা হয়েছে, যদি এটি সঠিক টোকেন হয়।
- ফেরত পাঠানো
- ব্যবহারকারী Play Billing বেছে নিলে, স্ট্যান্ডার্ড Play Billing নির্দেশিকা
অনুসরণ করে
পরিস্থিতি 2B ম্যানেজ করুন
ডেভেলপার পছন্দ স্ক্রিন রেন্ডার করেন এবং বিকল্প বিলিং অ্যাপের বাইরে ম্যানেজ করা হয়। এই পরিস্থিতিতে বিলিং সংক্রান্ত পছন্দ চালু করতে নিম্নলিখিত ধাপগুলি অনুসরণ করুন:
BillingClient ইনস্ট্যান্স তৈরি করার সময়
DeveloperProvidedBillingListenerছাড়াEnableBillingProgramParams-এenableBillingProgramকল করুন এবং তারপর কানেকশন শুরু করুন। যেমন:Kotlin
// Build the parameters to enable the Billing Choice program. val enableBillingProgramParams = EnableBillingProgramParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .build() // Build the parameters to enable support for pending purchases. val pendingPurchasesParams = PendingPurchasesParams.newBuilder() .enableOneTimeProducts() .build() // Construct the BillingClient instance with the purchases updated listener, // pending purchases support, and the billing choice params. val billingClient = BillingClient.newBuilder(context) .setListener(purchasesUpdatedListener) .enablePendingPurchases(pendingPurchasesParams) .enableBillingProgram(enableBillingProgramParams) .build() // Establish a connection to Google Play val billingResult = suspendCancellableCoroutine<BillingResult> { continuation -> billingClient.startConnection(object : BillingClientStateListener { // Called when the connection setup process completes. override fun onBillingSetupFinished(billingResult: BillingResult) { // Resume the coroutine and pass back the BillingResult to the caller. if (continuation.isActive) { continuation.resume(billingResult) } } // Called if the connection to the Play Store service is dropped. // This prevents the await or suspension point from hanging indefinitely. override fun onBillingServiceDisconnected() { if (continuation.isActive) { continuation.resume( BillingResult.newBuilder() .setResponseCode(BillingResponseCode.SERVICE_DISCONNECTED) .setDebugMessage("Billing service disconnected during connection setup") .build() ) } } }) }
জাভা
EnableBillingProgramParams params = EnableBillingProgramParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .build(); BillingClient billingClient = BillingClient.newBuilder(context) .setListener(purchasesUpdatedListener) .enablePendingPurchases() .enableBillingProgram(params) .build();নিম্নলিখিত বিষয়গুলি উপলভ্য আছে কিনা তা যাচাই করুন:
- Google-এর মাধ্যমে রেন্ডার করা বিলিংয়ের বিভিন্ন বিকল্প
- এক্সটার্নাল ওয়েব লিঙ্ক
প্রোগ্রামের উপলভ্যতা চেক করতে
isBillingProgramAvailableAsyncনম্বরে কল করুন এবং তারপর উপলভ্য প্রোডাক্ট দেখতেqueryProductDetailsAsyncনম্বরে কল করুন। যেমন:Kotlin
// Check the availability of the billing choice program asynchronously using a coroutine val (billingResult, billingProgramAvailabilityDetails) = billingClient.isBillingProgramAvailable(BillingProgram.BILLING_CHOICE) // Ensure the response code is OK if (billingResult.responseCode == BillingResponseCode.OK) { // Retrieve the billing choice availability details val billingChoiceAvailabilityDetails = billingProgramAvailabilityDetails.billingChoiceAvailabilityDetails // Check if billing choice details are available, choice screen is developer-rendered, // and external transaction links are supported. if (billingChoiceAvailabilityDetails != null && billingChoiceAvailabilityDetails.choiceScreenType == ChoiceScreenType.DEVELOPER_RENDERED && billingChoiceAvailabilityDetails.isExternalLinkAvailable ) { // Billing choice is available and external transaction links are supported. // Query products and proceed. } else { // Fallback to other available programs. } } else { // Fallback to other available programs. }
জাভা
// ... billingClient.isBillingProgramAvailableAsync( BillingProgram.BILLING_CHOICE, (billingResult, billingProgramAvailabilityDetails) -> { if (billingResult.getResponseCode() == BillingResponseCode.OK) { BillingChoiceAvailabilityDetails billingChoiceAvailabilityDetails = billingProgramAvailabilityDetails.getBillingChoiceAvailabilityDetails(); if (billingChoiceAvailabilityDetails != null && billingChoiceAvailabilityDetails.getChoiceScreenType() == ChoiceScreenType.DEVELOPER_RENDERED && billingChoiceAvailabilityDetails.isExternalLinkAvailable()) { // Billing choice is available and external transaction links are supported. Query products and proceed. } else { // Fallback to other available programs. } } else { // Fallback to other available programs. } } );Play Billing ব্যানার ও লয়ালটি সংক্রান্ত তথ্য পেতে
getBillingChoiceInfoAsyncপদ্ধতি কল করুন।Kotlin
// 1. Create the params required for the request val params = GetBillingChoiceInfoParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .setPlayBillingChoiceImageLayout(GetBillingChoiceInfoParams.ImageLayout.RECTANGULAR_FOUR_BY_ONE) .build() // 2. Call the suspend method on your billingClient instance val (billingResult, playBillingChoiceInfo) = billingClient.getBillingChoiceInfo(params) if (billingResult.responseCode == BillingResponseCode.OK && playBillingChoiceInfo != null) { // Access the URL of the image associated with the Play Billing Choice val imageUrl = playBillingChoiceInfo.playBillingChoiceImageUrl // Access the Play Loyalty string information, if available val loyaltyInfo = playBillingChoiceInfo.playBillingLoyaltyInfo // Populate your developer-rendered UI elements playBillingLoyaltyTextView.text = loyaltyInfo loadImage(imageUrl, playBillingImageView) } else { // Handle error scenarios }
জাভা
// 1. Create the params required for the request GetBillingChoiceInfoParams params = GetBillingChoiceInfoParams.newBuilder() .setBillingProgram(BillingClient.BillingProgram.BILLING_CHOICE) .setPlayBillingChoiceImageLayout(GetBillingChoiceInfoParams.ImageLayout.RECTANGULAR_FOUR_BY_ONE) .build(); // 2. Call the method asynchronously on your billingClient instance billingClient.getBillingChoiceInfoAsync(params, (billingResult, playBillingChoiceInfo) -> { if (billingResult.getResponseCode() == BillingResponseCode.OK && playBillingChoiceInfo != null) { // Access the URL of the image associated with the Play Billing Choice String imageUrl = playBillingChoiceInfo.getPlayBillingChoiceImageUrl(); // Access the Play Loyalty string information, if available String loyaltyInfo = playBillingChoiceInfo.getPlayBillingLoyaltyInfo(); // Populate your developer-rendered UI elements playBillingLoyaltyTextView.setText(loyaltyInfo); loadImage(imageUrl, playBillingImageView); } else { // Handle error scenarios } });ব্যবহারকারী কেনার ইচ্ছা প্রকাশ করলে, এক্সটার্নাল ট্রানজ্যাকশন টোকেন তৈরি করতে
createBillingProgramReportingDetailsAsyncকল করুন। যেমন:Kotlin
// Build the parameters for creating reporting details val params = BillingProgramReportingDetailsParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .setDeveloperBillingType(DeveloperBillingType.EXTERNAL_LINK) .build() // Call the suspend function to create billing program reporting details val (billingResult, billingProgramReportingDetails) = billingClient.createBillingProgramReportingDetails(params) // Handle response failure cases if (billingResult.responseCode != BillingResponseCode.OK) { // Handle failures such as retrying due to network errors. return } // Retrieve the external transaction token val transactionToken = billingProgramReportingDetails?.externalTransactionToken // Persist the external transaction token locally. Pass it to // DeveloperBillingOptionParams when launchBillingFlow is called. // It can also be used as part of your external website
জাভা
BillingProgramReportingDetailsParams params = BillingProgramReportingDetailsParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .setDeveloperBillingType(DeveloperBillingType.EXTERNAL_LINK) .build(); billingClient.createBillingProgramReportingDetailsAsync( params, new BillingProgramReportingDetailsListener() { @Override public void onCreateBillingProgramReportingDetailsResponse( BillingResult billingResult, @Nullable BillingProgramReportingDetails billingProgramReportingDetails ) { if (billingResult.getResponseCode() != BillingResponseCode.OK) { // Handle failures such as retrying due to network errors. return; } String transactionToken = billingProgramReportingDetails.getExternalTransactionToken(); // Persist the external transaction token locally. Pass it to // DeveloperBillingOptionParams when launchBillingFlow is called. // It can also be used as part of your external website. } } );ব্যবহারকারী 'কিনুন' বিকল্পে ক্লিক করলে আপনার বিকল্প পছন্দের স্ক্রিন লঞ্চ করুন।
বিলিংয়ের ধরন সংক্রান্ত ব্যবহারকারীর পছন্দ এইভাবে ম্যানেজ করুন:
ব্যবহারকারী Play Billing বেছে নিলে, স্ট্যান্ডার্ড Play Billing নির্দেশিকা অনুসরণ করে
launchBillingFlowকল করুন। বিলিংয়ের ফলাফলPurchasesUpdatedListener-এ ফেরত পাঠানো হয় যা ১ নম্বর ধাপে রেজিস্টার করা হয়েছে।তত্ত্বাবধানে থাকা ব্যবহারকারীদের জন্য অভিভাবকীয় নিয়ন্ত্রণ দেখানো হয়।
ব্যবহারকারী আপনার বিকল্প বিলিং বেছে নিলে, launchExternalLink কল করুন। যেমন:
Kotlin
// An activity reference from which the purchase flow will be launched. val params = LaunchExternalLinkParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .setExternalTransactionToken(transactionToken) // You can pass along the external transaction token from // BillingProgramReportingDetails as a URL parameter in the URI .setLinkUri(yourLinkUri) .setLinkType(LaunchExternalLinkParams.LinkType.LINK_TO_DIGITAL_CONTENT_OFFER) .setLaunchMode( LaunchExternalLinkParams.LaunchMode.LAUNCH_IN_EXTERNAL_BROWSER_OR_APP ) .build() // Call launchExternalLink with a callback billingClient.launchExternalLink(activity, params) { billingResult -> if (billingResult.responseCode == BillingResponseCode.OK) { // Proceed with the rest of the purchase flow. If the user // purchases an item, be sure to report the transaction to Google // Play. } else { // Handle failures such as retrying due to network errors. } }
জাভা
// An activity reference from which the purchase flow will be launched. Activity activity = ...; LaunchExternalLinkParams params = LaunchExternalLinkParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) // You can pass along the external transaction token from // BillingProgramReportingDetails as a URL parameter in the URI .setLinkUri(yourLinkUri) .setLinkType(LaunchExternalLinkParams.LinkType.LINK_TO_DIGITAL_CONTENT_OFFER) .setLaunchMode( LaunchExternalLinkParams.LaunchMode.LAUNCH_IN_EXTERNAL_BROWSER_OR_APP) .setExternalTransactionToken(transactionToken) .build(); LaunchExternalLinkResponseListener listener = new LaunchExternalLinkResponseListener() { @Override public void onLaunchExternalLinkResponse(BillingResult billingResult) { if (billingResult.getResponseCode() == BillingResponseCode.OK) { // Proceed with the rest of the purchase flow. If the user // purchases an item, be sure to report the transaction to Google // Play. } else { // Handle failures such as retrying due to network errors. } } }; billingClient.launchExternalLink(activity, params, listener);৪ নম্বর ধাপ থেকে এক্সটার্নাল ট্রানজ্যাকশন টোকেন
LaunchExternalLinkParams-এ পাস করুন। এটি OK রিটার্ন করলে, ট্রানজ্যাকশন চালিয়ে যান এবং Google Play-তে ট্রানজ্যাকশন সম্পর্কে রিপোর্ট করুন।তত্ত্বাবধানে থাকা ব্যবহারকারীদের জন্য অভিভাবকীয় নিয়ন্ত্রণ দেখানো হয়।
সাবস্ক্রিপশন রিপ্লেসমেন্টের সময় বিলিংয়ের বিকল্প
সাবস্ক্রিপশন পরিবর্তন করার জন্য, ব্যবহারকারীর পছন্দ সংক্রান্ত স্ক্রিন দেখানো উচিত নয়, কারণ আপগ্রেড ও ডাউনগ্রেডের জন্য আসল কেনাকাটার ক্ষেত্রে ব্যবহারকারীর পছন্দ সংরক্ষিত থাকে।
আসল কেনাকাটা Google Play Billing-এর মাধ্যমে প্রসেস করা হলে, আপনাকে
স্ট্যান্ডার্ড Google Play Billing
সাবস্ক্রিপশন রিপ্লেসমেন্ট সংক্রান্ত তথ্য সহ launchBillingFlow কল করতে হবে।
তবে, আসল কেনাকাটা যদি বিকল্প বিলিংয়ের মাধ্যমে প্রসেস করা হয়ে থাকে, তাহলে সাবস্ক্রিপশন পরিবর্তন করার বিষয়টি পরিস্থিতি অনুযায়ী সামান্য আলাদাভাবে ম্যানেজ করা হয়।
পরিস্থিতি ১A-তে সাবস্ক্রিপশন পরিবর্তন করা
আপগ্রেড বা ডাউনগ্রেডের অনুরোধ করা ব্যবহারকারীদের ডেভেলপারের বিলিংয়ের বিকল্প সিস্টেমের মাধ্যমে এগিয়ে যেতে হবে, ব্যবহারকারীর পছন্দের অভিজ্ঞতা আবার দেখার প্রয়োজন নেই।
এটি করতে, ব্যবহারকারী আপগ্রেড বা ডাউনগ্রেডের অনুরোধ করলে launchBillingFlow-এ কল করুন। আসল কেনাকাটার জন্য এক্সটার্নাল ট্রানজ্যাকশন আইডি প্রদান করতে, প্যারামিটারে SubscriptionUpdateParams অবজেক্টের মধ্যে setOriginalExternalTransactionId ব্যবহার করুন। এটি ব্যবহারকারীর পছন্দের স্ক্রিন দেখায় না, কারণ আসল কেনাকাটার জন্য ব্যবহারকারীর পছন্দ আপগ্রেড ও ডাউনগ্রেডের জন্য সংরক্ষিত থাকে। এই ক্ষেত্রে launchBillingFlow-এ কল করলে
ট্রানজ্যাকশনের জন্য একটি নতুন এক্সটার্নাল ট্রানজ্যাকশন টোকেন জেনারেট হয় যা আপনি
কলব্যাক থেকে ফিরিয়ে আনতে পারবেন।
Kotlin
// The external transaction ID from the current // alternative billing subscription. val externalTransactionId = "external_transaction_id" val developerBillingOptionParams = DeveloperBillingOptionParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .build() val billingFlowParams = BillingFlowParams.newBuilder() .setProductDetailsParamsList( listOf( BillingFlowParams.ProductDetailsParams.newBuilder() // Fetched using queryProductDetailsAsync. .setProductDetails(productDetailsNewPlan) // offerIdToken can be found in // ProductDetails=>SubscriptionOfferDetails. .setOfferToken(offerTokenNewPlan) .build() ) ) .setSubscriptionUpdateParams( SubscriptionUpdateParams.newBuilder() .setOriginalExternalTransactionId(externalTransactionId) .build() ) .enableDeveloperBillingOption(developerBillingOptionParams) .build() val billingResult = billingClient.launchBillingFlow(activity, billingFlowParams) // When the user selects the alternative billing flow, // the DeveloperProvidedBillingListener is triggered.
জাভা
// The external transaction ID from the current
// alternative billing subscription.
String externalTransactionId = //... ;
DeveloperBillingOptionParams developerBillingOptionParams =
DeveloperBillingOptionParams.newBuilder()
.setBillingProgram(BillingProgram.BILLING_CHOICE)
.build();
List<ProductDetailsParams> productDetailsParamsList = new ArrayList<>();
productDetailsParamsList.add(
ProductDetailsParams.newBuilder()
// Fetched using queryProductDetailsAsync.
.setProductDetails(productDetailsNewPlan)
// offerIdToken can be found in
// ProductDetails=>SubscriptionOfferDetails
.setOfferToken(offerTokenNewPlan)
.build());
BillingFlowParams billingFlowParams =
BillingFlowParams.newBuilder()
.setProductDetailsParamsList(productDetailsParamsList)
.setSubscriptionUpdateParams(
SubscriptionUpdateParams.newBuilder()
.setOriginalExternalTransactionId(externalTransactionId)
.build())
.enableDeveloperBillingOption(developerBillingOptionParams)
.build();
BillingResult billingResult = billingClient.launchBillingFlow(activity, billingFlowParams);
// When the user selects the alternative billing flow,
// the DeveloperProvidedBillingListener is triggered.
আপগ্রেড বা ডাউনগ্রেড সম্পূর্ণ হলে, নতুন সাবস্ক্রিপশন কেনার জন্য আগের কলের মাধ্যমে প্রাপ্ত এক্সটার্নাল ট্রানজ্যাকশন টোকেন ব্যবহার করে আপনাকে নতুন ট্রানজ্যাকশন রিপোর্ট করতে হবে।
পরিস্থিতি ১B-তে সাবস্ক্রিপশন পরিবর্তন করা
এই পরিস্থিতিতে, একটি নতুন এক্সটার্নাল ট্রানজ্যাকশন টোকেন তৈরি করতে হবে। সাধারণ কেনাকাটার সাথে একমাত্র পার্থক্য হল, এই পরিস্থিতিতে, ব্যবহারকারীর পছন্দ সংরক্ষিত থাকে এবং আপনাকে আপগ্রেড বা ডাউনগ্রেডের জন্য পছন্দের স্ক্রিন দেখাতে হবে না। তবে, আপনাকে অবশ্যই একবারের জন্য দেখানো তথ্য ডায়ালগ এবং অভিভাবকের সম্মতি দেখাতে হবে।
ইন্টিগ্রেশন কোডের স্যাম্পেলের জন্য, পরিস্থিতি 1B-এর ৪ নম্বর ধাপ দেখুন: ডেভেলপার পছন্দ স্ক্রিন দেখান এবং আপনার অ্যাপের মধ্যে বিকল্প বিলিং ম্যানেজ করা হয়।
আপগ্রেড বা ডাউনগ্রেড সম্পূর্ণ হলে, নতুন সাবস্ক্রিপশন কেনার জন্য আগের কলের মাধ্যমে প্রাপ্ত এক্সটার্নাল ট্রানজ্যাকশন টোকেন ব্যবহার করে আপনাকে নতুন ট্রানজ্যাকশন রিপোর্ট করতে হবে।
পরিস্থিতি ২A-তে সাবস্ক্রিপশন পরিবর্তন করা
যেসব সাবস্ক্রিপশন মূলত ডেভেলপারের ওয়েবসাইট বা ব্যবহারকারীর পছন্দের পরে কোনও পেমেন্ট অ্যাপের মাধ্যমে কেনা হয়েছে, সেগুলির ক্ষেত্রে আপগ্রেড বা ডাউনগ্রেডের অনুরোধ করা ব্যবহারকারীকে ডেভেলপারের ওয়েবসাইট বা পেমেন্ট অ্যাপের মাধ্যমে প্রসেস সম্পূর্ণ করতে হবে এবং ব্যবহারকারীর পছন্দের অভিজ্ঞতা আবার দেখাতে হবে না।
এটি করতে, ব্যবহারকারী আপগ্রেড বা ডাউনগ্রেডের অনুরোধ করলে launchBillingFlow-এ কল করুন। SubscriptionUpdateParams অবজেক্টের অধীনে অন্যান্য প্যারামিটার উল্লেখ করার পরিবর্তে,
setOriginalExternalTransactionId ব্যবহার করুন,
আসল কেনাকাটার জন্য এক্সটার্নাল ট্রানজ্যাকশন আইডি প্রদান করুন।
এই কলে DeveloperBillingOptionParams-এর ভ্যালুও লিখতে হবে। এটি ব্যবহারকারীর পছন্দের স্ক্রিন দেখায় না, কারণ আপগ্রেড ও ডাউনগ্রেডের জন্য আসল কেনাকাটার ক্ষেত্রে ব্যবহারকারীর পছন্দ সংরক্ষিত থাকে। যেমন:
Kotlin
val externalTransactionId = "external_transaction_id" // 1. Construct DeveloperBillingOptionParams indicating the billing program val developerBillingOptionParams = DeveloperBillingOptionParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .build() // 2. Build BillingFlowParams combining DeveloperBillingOptionParams and SubscriptionUpdateParams val billingFlowParams = BillingFlowParams.newBuilder() .setProductDetailsParamsList( listOf( BillingFlowParams.ProductDetailsParams.newBuilder() // Fetched using queryProductDetailsAsync. .setProductDetails(productDetailsNewPlan) // offerIdToken can be found in ProductDetails=>SubscriptionOfferDetails. .setOfferToken(offerTokenNewPlan) .build() ) ) .setSubscriptionUpdateParams( SubscriptionUpdateParams.newBuilder() .setOriginalExternalTransactionId(externalTransactionId) .build() ) .enableDeveloperBillingOption(developerBillingOptionParams) .build()
জাভা
String externalTransactionId = //... ;
// 1. Construct DeveloperBillingOptionParams indicating the billing program
DeveloperBillingOptionParams developerBillingOptionParams =
DeveloperBillingOptionParams.newBuilder()
.setBillingProgram(BillingClient.BillingProgram.BILLING_CHOICE)
.build();
// 2. Add ProductDetailsParams
List productDetailsParamsList = new ArrayList<>();
productDetailsParamsList.add(
ProductDetailsParams.newBuilder()
// Fetched using queryProductDetailsAsync.
.setProductDetails(productDetailsNewPlan)
// offerIdToken can be found in ProductDetails=>SubscriptionOfferDetails
.setOfferToken(offerTokenNewPlan)
.build());
// 3. Build BillingFlowParams combining DeveloperBillingOptionParams and SubscriptionUpdateParams
BillingFlowParams billingFlowParams =
BillingFlowParams.newBuilder()
.setProductDetailsParamsList(productDetailsParamsList)
.setSubscriptionUpdateParams(
SubscriptionUpdateParams.newBuilder()
.setOriginalExternalTransactionId(externalTransactionId)
.build())
.enableDeveloperBillingOption(developerBillingOptionParams)
.build();
এছাড়াও, আপনাকে নতুন এক্সটার্নাল ট্রানজ্যাকশন টোকেন জেনারেট করতে হবে। যেমন:
Kotlin
val params = BillingProgramReportingDetailsParams.newBuilder() .setBillingProgram(BillingProgram.BILLING_CHOICE) .setDeveloperBillingType(DeveloperBillingType.EXTERNAL_LINK) .build() val (billingResult, billingProgramReportingDetails) = billingClient.createBillingProgramReportingDetails(params) if (billingResult.responseCode != BillingResponseCode.OK) { // Handle failures such as retrying due to network errors. return } val externalTransactionToken = billingProgramReportingDetails?.externalTransactionToken // Persist the external transaction token locally. Pass it to // the external website using DeveloperBillingOptionParams when // launchBillingFlow is called.
জাভা
BillingProgramReportingDetailsParams params =
BillingProgramReportingDetailsParams.newBuilder()
.setBillingProgram(BillingProgram.BILLING_CHOICE)
.setDeveloperBillingType(DeveloperBillingType.EXTERNAL_LINK)
.build();
billingClient.createBillingProgramReportingDetailsAsync(
params,
new BillingProgramReportingDetailsListener() {
@Override
public void onCreateBillingProgramReportingDetailsResponse(
BillingResult billingResult,
@Nullable BillingProgramReportingDetails billingProgramReportingDetails) {
if (billingResult.getResponseCode() != BillingResponseCode.OK) {
// Handle failures such as retrying due to network errors.
return;
}
String transactionToken =
billingProgramReportingDetails.getExternalTransactionToken();
// Persist the external transaction token locally. Pass it to
// the external website using DeveloperBillingOptionParams when
// launchBillingFlow is called.
}
});
নতুন টোকেন তৈরি করার পরে, পারচেজ ফ্লো চালু করতে আপনাকে অবশ্যই launchBillingFlow
মেথড কল করতে হবে।
আপগ্রেড বা ডাউনগ্রেড সম্পূর্ণ হলে, নতুন সাবস্ক্রিপশন কেনার জন্য আগের কলের মাধ্যমে প্রাপ্ত এক্সটার্নাল ট্রানজ্যাকশন টোকেন ব্যবহার করে আপনাকে নতুন ট্রানজ্যাকশন রিপোর্ট করতে হবে।
পরিস্থিতি ২B-তে সাবস্ক্রিপশন পরিবর্তন করা
এই পরিস্থিতিতে সাবস্ক্রিপশন রিপ্লেসমেন্ট ম্যানেজ করার ধাপগুলি পরিস্থিতি ২এ-তে সাবস্ক্রিপশন রিপ্লেসমেন্ট-এ বর্ণিত ধাপগুলির মতোই। একমাত্র
পার্থক্য হল, ট্রানজ্যাকশন টোকেন জেনারেট করার পরে, launchBillingFlow পদ্ধতি কল করার
পরিবর্তে, আপনাকে অবশ্যই লিঙ্কআউট ডিসক্লেমার ডায়ালগ দেখানোর জন্য launchExternalLink কল
করতে হবে। এই পরিস্থিতিতে, ব্যবহারকারীর পছন্দ সংরক্ষিত থাকে,
এবং আপনাকে আপগ্রেড বা ডাউনগ্রেডের জন্য পছন্দের স্ক্রিন দেখাতে হবে না।
ইন্টিগ্রেশন কোডের স্যাম্পেল দেখতে, পরিস্থিতি 2B-এর ৬ নম্বর ধাপ দেখুন: ডেভেলপার পছন্দ স্ক্রিন দেখান এবং আপনার অ্যাপের মধ্যে বিকল্প বিলিং ম্যানেজ করা হয়।
আপগ্রেড বা ডাউনগ্রেড সম্পূর্ণ হলে, নতুন সাবস্ক্রিপশন কেনার জন্য আগের কলের মাধ্যমে প্রাপ্ত এক্সটার্নাল ট্রানজ্যাকশন টোকেন ব্যবহার করে আপনাকে নতুন ট্রানজ্যাকশন রিপোর্ট করতে হবে।