question

lstipakov avatar image
lstipakov asked

Purchasing Subscriptions

Hello, Let's say I would like to offer user monthly and yearly subscriptions. its respective "terms" SKUs are "com.sub.month" and "com.sub.year". Both have same "parent" SKU - "com.sub". When I want to display purchase dialog by calling [b]initiatePurchaseRequest[/b], should I do it by: 1) Using "parent" SKU of those items and Amazon app will display "interstital" dialog with listbox containing subscriptions, OR 2) First display some listbox myself where user should pick the correct item and then call [b]initiatePurchaseRequest[/b] with "terms" SKU of choosen item? -Lev
iap
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Dixith@Amazon avatar image
Dixith@Amazon answered
When you are implementing term SKUs in your subscription item, you should call your initiatepurchaserequest( ) method with your parent SKU . Then the purchase dialog box displayed to customer with all your term SKU's in drop down box.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

lstipakov avatar image
lstipakov answered
Hello, I got it, but how it agrees with statement from FAQ: > The child SKUs represent the different subscription terms and are used to initiate the purchase. https://developer.amazon.com/sdk/in-app-purchasing/reference/faq.html Q: Why do I get a different SKU back when I initiate a purchase for my subscription SKU? A: A subscription is comprised of a non-buyable parent SKU and one or more child term SKUs. This setup prevents users from purchasing multiple subscriptions of the same product. The non-buyable parent represents the product being purchased and is the SKU returned in the purchase response. The child SKUs represent the different subscription terms and are used to initiate the purchase. Subscription terms and charges are handled by Amazon and your app only needs to check whether a subscription is valid.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Dixith@Amazon avatar image
Dixith@Amazon answered
Thank you for pointing out. As per the FAQ, we should pass the child SKU in initiatepurchase( ) request method. The response object in purchase response contains the receipt with metadata information. In the purchase receipt, it returns the parent SKU value. You should retrieve the subscription period by using getsubscriptionperiod( ) method and need to unlock the corresponding term SKU. Please find the code snippet in onPurchaseResponse( ) below. public void onPurchaseResponse(PurchaseResponse response) { if (status == PurchaseResponse.getPurchaseRequestStatus.SUCCESSFUL) { Receipt receipt = response.getReceipt(); String itemType = receipt.getItemType(); String sku = receipt.getSku(); String purchaseToken = receipt.getPurchaseToken(); SubscriptionPeriod subscriptionPeriod = receipt.getSubscriptionPeriod(); Date subscriptionStart = subscriptionPeriod.getStartDate(); Date subscriptionEnd = subscriptionPeriod.getEndDate(); Date today = new Date(); if (subscriptionStart <= today && (subscriptionEnd == null || today <=subscriptionEnd)) { // Entitle subscription } } }
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.