Auto–renewable Subscriptions
Hive SDK v4.11.6 supports new feature called auto-renewable subscriptions, which repeats payment on a regular basis. The types of subscription are monthly subscription, yearly subscription, and free trials in general. If you like to know more about the subscription format provided by Google and Apple, refer to the following table. Auto–renewable subscriptions are available if user selects the period of regular payment by OS type.
OS | Apple | |
Renewal terms | Weekly Monthly Every 3 months Every 6 months Yearly |
Weekly Monthly Every 2 months Every 3 months Every 6 months Yearly |
Make sure to let your game users access the auto-renewable subscriptions at any time regardless of device type if the user is regularly charged a specific subscription. Subscription restoration is essential feature in accordance with user needs.
Price change
Auto-renewal subscriptions are free to upgrade or downgrade the subscription level. Subscriptions are not a single-use, and provide receipt when users try to reinstate.
On Google, subscriptions are free to upgrade or downgrade the subscription level and change to new one regardless of previous subscription. If the user changes the price, the value of previous subscription is calculated on a daily basis and provided after the expiry of the new subscription.
On Apple platforms, subscription group is defined on iTunes console, so change to one of other subscription types in a same group is available. If the user upgrades his/her subscription, the value of previous subscription is calculated on a daily basis and provided after the expiry of the new subscription. In case of downgrade, it renews to the new subscription after the existing subscription is expired.
Purchase, Restoration and Grace period
Purchase
- Free trials
If a subscription has free-trial period, it is not calcualted as sales. After free-trial expires, the subscription is charged automatically. - Discount for new subscribers
It is a promotion for new subscribers. This promotion is available in a specific period of time with discounted prices.
Cancellation
Subscribers can cancel the subscription prior to renewal period. How to cancel is described in Manage Subscriptions menu from each market. After the subscription canceled, auto-renewal is expired.
Refund
If a subscriber request to refund the rest value of the subscription after cancellation, the amount of refund is calculated based on the rest of time period and the value of subscription (Google console).
Restoration
Subscribers can reinstate the subscription if the subscription is unavailable after payment. Value calculation for restoration is based on the ownership policy if a subscriber has the ownership of the subscription.
Grace Period
When subscription renewal is failed to charge, use grace period. Make sure to value the state in grace period as same as that of subscription.
Account Hold (Google)
Account hold is a state that fails to renew a subscription due to issues occurred at the moment of payment, and ends with unsolved issues. In this case, make sure to process the subscription unavailable for maximum 30 days.
Pause (Google)
Pausing subscription is available for maximum three months. When the period ends, the subscription is automatically resumed.
Displaying Google Notification Popup
If Google subscription state is in grace period or on account hold, display a notification popup. The popup should contain the current subscription state, how to solve issues and a button that links to market settings. This button is not essential in the grace period, however, it is recommended for user convenience. In case the user changes the payment information in the grace period or on hold state, the subscription is automatically paid at the moment the user is set in case of the grace period state. On the account hold, the user should restart the subscription. When the subscription state of users is renewed after the restart, provide a subscription purchase page and a restoration button for users to give benefits of their subscription.
Notification popup samples are as follows. Use these phrases or customize them for each game.
- Notification Phrases in Grace Period
Korean | 구독 자동 결제에 실패하였습니다. Google Play의 구독 설정으로 이동하여 결제 수단을 확인해주세요. |
English | Failed to make automatic payment for subscription. Go to the your Google Play subscription settings and check your payment method. |
Japanese | 購読自動決済に失敗しました。 Google Playの購読設定に移動し、決済方法を確認してください。 |
Chinese Simplified | 自动付款失败。 前往谷歌商店的订阅设置,查看付款方式吧。 |
Chinese Traditional | 自動續訂扣款失敗。 請至Google Play的[訂閱]設定中,確認付款方式。 |
French | Echec du paiement automatique de l’abonnement. Vérifiez le mode de paiement dans les paramètres d’abonnement de Google Play. |
German | Die automatische Zahlung des Abonnements ist fehlgeschlagen. Gehe zu den Einstellungen deiner Google Play-Abonnements und überprüfe deine Zahlungsmethode. |
Russian | Не удалось совершить автоматическую оплату за подписку. Перейдите в настройки подписки Google Play и проверьте метод оплаты. |
Spanish | No se pudo hacer el pago automático de la subscripción. Ve a los ajustes de subscripción de tu Google Play y comprueba tu método de pago. |
Portuguese | Falha ao realizar o pagamento automático da assinatura. Acesse as suas configurações de assinatura da Google Play e verifique o seu método de pagamento. |
Indonesian | Gagal melakukan pembayaran otomatis untuk berlangganan. Silakan buka pengaturan langganan Google Play dan periksa metode pembayaranmu. |
Vietnamese | Thanh toán tự động cho đăng ký không thành công. Vui lòng vào thiết lập đăng ký của Google Play và kiểm tra phương thức thanh toán của bạn. |
Thai | การชำระเงินอัตโนมัติเพื่อสมัครบริการล้มเหลว กรุณาไปที่หน้าตั้งค่า Subscription ใน Google Play แล้วตรวจสอบวิธีการชำระเงิน |
Italian | Impossibile effettuare il pagamento automatico per l’abbonamento. Vai alle impostazioni degli abbonamenti di Google Play e controlla il tuo metodo di pagamento. |
Turkish | Abonelik için otomatik ödeme başarısız. Google Play Abonelik ayarına gidip ödeme yöntemini seçiniz. |
Arabic | فشل في إجراء عملية الدفع الآلي للاشتراك. انتقل إلى إعداداتك في غوغل بلاي وتحقق من طريقة الدفع. |
- Notification Phrases when it is in pending state
Korean | 구독 자동 결제가 정상적으로 이뤄지지 않아 구독 서비스가 만료되었습니다. Google Play의 구독 설정으로 이동하여 결제 방법을 확인하고 다시 결제를 해주세요. 결제 후엔 반드시 복원(restore)버튼을 클릭하여 구독 상태를 확인해주세요. |
English | The subscription service has expired because the auto subscription payment has failed. Go to the your Google Play subscription settings, check your payment method and try again. Be sure to click Restore after purchase to check your subscription status. |
Japanese | 購読自動決済が行われなかったため、購読サービスが終了しました。 Google Playの購読設定に移動して決済方法を確認し、もう一度お試しください。 決済した後、必ず【復元】ボタンをタップして購読状態を確認してください。 |
Chinese Simplified | 由于自动付款失败,订阅服务已到期。 前往谷歌商店的订阅设置,查看付款方式后重新进行付款吧。 付款后请务必点击复原(restore)按键查看订阅状态。 |
Chinese Traditional | 自動續訂扣款失敗,已取消訂閱服務。 請至Google Play的[訂閱]設定中,確認付款方式後,再次付款。 付款完畢後,請務必點選[回復]按鈕,並確認訂閱狀態。 |
French | Le service d’abonnement est interrompu : le paiement automatique ne s’est pas déroulé normalement. Veuillez procéder de nouveau au paiement en vous rendant dans les paramètres d’abonnement de Google Play. Après le paiement, confirmez bien le statut de l’abonnement en appuyant sur le bouton “Reprendre”. |
German | Der Abonnement ist abgelaufen, weil die automatische Zahlung für das Abonnement fehlgeschlagen ist. Gehe zu den Einstellungen deiner Google Play-Abonnements, überprüfe deine Zahlungsmethode und versuche es erneut. Bitte stelle sicher, dass du nach dem Kauf auf Wiederherstellen klickst, um den Status deines Abonnements zu überprüfen. |
Russian | Срок действия подписки истек, поскольку не удалось произвести автоматическую оплату за подписку. Перейдите в настройки подписки Google Play, проверьте метод оплаты и повторите вновь. После оплаты подтвердите статус подписки, нажав на кнопку «Возобновить». |
Spanish | La subscripción del servicio ha expirado porque ha fallado el método de pago automático de la subscripción. Ve a los ajustes de subscripción de tu Google Play, comprueba tu método de pago e inténtalo de nuevo. Asegúrate de pulsar Restaurar después de comprar para comprobar el estado de tu subscripción. |
Portuguese | O serviço de assinatura expirou porque houve uma falha no pagamento automático da assinatura. Acesse as suas configurações de assinatura da Google Play, verifique o seu método de pagamento e tente novamente. Certifique-se de clicar em Recuperar após a compra, para conferir o status da sua assinatura. |
Indonesian | Layanan berlangganan dihentikan karena pembayaran otomatis telah gagal. Silakan buka pengaturan langganan Google Play, periksa metode pembayaranmu dan coba lagi. Pastikan kamu klik Pulihkan setelah membeli untuk melihat status berlangganan. |
Vietnamese | Dịch vụ đăng ký đã hết hạn do thanh toán đăng ký tự động không thành công. Vui lòng vào thiết lập đăng ký của Google Play để kiểm tra phương thức thanh toán của bạn và thanh toán lại. Đừng quên nhấn vào nút Khôi Phục (Restore) sau khi thanh toán để kiểm tra tình trạng đăng ký của bạn. |
Thai | บริการจากการสมัครบริการหมดอายุแล้ว เนื่องจากชำระเงินอัตโนมัติไม่สำเร็จ กรุณาไปที่หน้าตั้งค่า Subscription ใน Google Play แล้วตรวจสอบวิธีการชำระเงินอีกครั้ง อย่าลืมกด Restore หลังซื้อ เพื่อตรวจสอบสถานะการสมัครของคุณ |
Italian | Il servizio di abbonamento è scaduto perché il pagamento dell’abbonamento automatico è fallito. Vai alle impostazioni degli abbonamenti di Google Play, controlla il metodo di pagamento e riprova. Assicurati di fare clic su Ripristina dopo l’acquisto per controllare lo stato dell’abbonamento. |
Turkish | Abone otomatik ödeme düzgün gerçekleşmediği için abonelik hizmeti sona erdi. Google Play Abonelik ayarına gidip ödeme yöntemini kontrol edip tekrar ödeme yapınız. Ödemeyi yaptıktan sonra geri yükle (restore) butonuna tıklayıp abonelik durumunuzu kontrol ediniz. |
Arabic | انتهت صلاحية خدمة الاشتراك بسبب فشل دفع الاشتراك الآلي. انتقل إلى إعداداتك في غوغل بلاي وتحقق من طريقة الدفع و حاول مرة أخرى. تأكد من النقر فوق زر استعادة الأشتراك بعد الشراء للتحقق من حالة اشتراكك. |
Purchase process of subscription
Diagram
Flowchart
Google Subscription V2 Support
Google subscription API V2 allows you to create and manage multiple benefits using a new subscription method. The examples of the benefits include a benefit on your first subscription, and a discount by subscribing an additional product when you already had a subscription. For more information on Google subscriptions, see here.
If you use Google subscription V2, you can grant differentiated benefits to the payment price according to the subscription status, such as the subscription period and the number of the past subscriptions. To use Google subscription V2, please follow the steps below.
Register Product in the Google Play Console
Register your products to be sold using Google subscription V2 on the Google Play Console. For more details, please refer to Play Console Guide.
Check the Registered Product Information with getSubscriptionProductInfo
You can check your product information registered in the Google Play Console at the response value of IAPV4.getSubscriptionProductInfo method, the originalMarketJson
of the IAPV4Product
object.
productId
: productbasePlanId
: subscription planofferIdToken
: benefit
The below presents an example product called “sub003” whose information can be found in originalMarketJson
, after registering a weekly and a monthly payment each and defining two benefits for the monthly payment.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
{ "productId": "sub003", "type": "subs", "title": "sub003-name (HIVE SDK)", "name": "sub003-name", "localizedIn": [ "ko-KR" ], "skuDetailsToken": "AEuhp4KfxD0MTrwzJV_jl0exSz9NuCZzipMe8mo45lR7pi3y_bWsvXdeKNM04CMxxNY=", "subscriptionOfferDetails": [ { "offerIdToken": "AUj\/Yhj7Zx5lt7B0G4qWDtmPFDioPkobZB7zw0xi1A8+B4iD0AbZbwQJKitQLCjR9CMLssbH+g43p4wf3tLREE8H41NgdDpOaCsla0xoTQKPkCsH6+U4XszzPUtOGNwuskbzNjEDfTJoF50j1fSd+IXCkQ==", "basePlanId": "baseprice-p1m", "offerId": "offer-freetrial", "pricingPhases": [ { "priceAmountMicros": 0, "priceCurrencyCode": "KRW", "formattedPrice": "free", "billingPeriod": "P1M", "recurrenceMode": 2, "billingCycleCount": 1 }, { "priceAmountMicros": 1650000000, "priceCurrencyCode": "KRW", "formattedPrice": "₩1,650", "billingPeriod": "P1M", "recurrenceMode": 2, "billingCycleCount": 2 }, { "priceAmountMicros": 3300000000, "priceCurrencyCode": "KRW", "formattedPrice": "₩3,300", "billingPeriod": "P1M", "recurrenceMode": 1 } ], "offerTags": [ "offer-free", "offer-freetrial" ] }, { "offerIdToken": "AUj\/YhjUXnT6K8XbdZd5lUtCSef0HA+qikjGfNPEAXvLeLKWTZ0RqwcFIvR5GhECXTRD1SdUrn0LcaB6oquBo5QeUTEZJGTstWGzfmrwL3oSsvBs1EERERSdJ6NDq54=", "basePlanId": "baseprice-p1m", "pricingPhases": [ { "priceAmountMicros": 3300000000, "priceCurrencyCode": "KRW", "formattedPrice": "₩3,300", "billingPeriod": "P1M", "recurrenceMode": 1 } ], "offerTags": [] }, { "offerIdToken": "AUj\/YhhlJDIsjfnvcc5TfxlBjSA+o3QcNsCAjU+DfXBJn2JF\/zLgew468AvchceNBynmB3CvnPLhqlr8be8dJlIvAEkKgdas1DGoiu3p52jSvwsxh8jQLN7QReXUdrY=", "basePlanId": "baseprice-p1w", "pricingPhases": [ { "priceAmountMicros": 500000000, "priceCurrencyCode": "KRW", "formattedPrice": "₩500", "billingPeriod": "P1W", "recurrenceMode": 1 } ], "offerTags": [] } ] } |
There are a total of 3 benefit key values shown in the offerIdToken
example above, 2 benefit types for the monthly payment and 1 base benefit for the weekly payment. The first or the second benefit will actually be applied to the users when making monthly payment.
Request Subscription
Request a subscription as shown below using IAPV4Product
object originalMarketJson
obtained above. You can request a subscription with applying the corresponding benefits to the user.
Field Name | Description | Required |
---|---|---|
YOUR_PRODUCT_MARKET_PID | This is the productId in originalMarketJson . |
Y |
YOUR_PRODUCT_OLD_MARKET_PID | The productId the user has already subscribed to. It is required when upgrading the existing subscription to the one the user is currently requesting. |
N |
YOUR_PAYLOAD | This is the purchase metadata predefined by the game studio. | N |
YOUR_OFFER_ID_TOKEN | This is the offerIdToken in originalMarketJson . If you do not enter a value in this field, the Hive SDK will use the first offerIdToken in the subscriptionOfferDetails of originalMarketJson . |
N |
API Reference: IAPV4 .purchaseSubscription
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
using hive; IAPV4PurchaseParam.Builder builder = new IAPV4.IAPV4PurchaseParam.Builder(); IAPV4PurchaseParam param = builder.setMarketPid("YOUR_PRODUCT_MARKET_PID") .setOldMarketPid("YOUR_PRODUCT_OLD_MARKET_PID") .setIapPayload("YOUR_PAYLOAD") .setOfferToken("YOUR_OFFER_ID_TOKEN") .build(); IAPV4.purchaseSubscription (param, (ResultAPI result, IAPV4Receipt receipt) => { if (result.isSuccess()) { // TODO: Request verification of receipt with received receipt } }); |
API Reference: IAPV4 ::purchaseSubscription
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include <HIVE_SDK_Plugin/HIVE_CPP.h> using namespace std; using namespace hive; auto* param = new IAPV4PurchaseParam(); param->marketPid = "YOUR_PRODUCT_MARKET_PID"; param->oldMarketPid = "YOUR_PRODUCT_OLD_MARKET_PID"; param->iapPayload = "YOUR_PAYLOAD"; param->offerToken = "YOUT_OFFER_ID_TOKEN"; IAPV4::purchaseSubscription(*param, [=](ResultAPI const & result, IAPV4Receipt const & receipt) { if (result.isSuccess()) { // TODO: Request verification of receipt with received receipt } }); |
API Reference: IAPV4.purchaseSubscription
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import com.hive.IAPV4 import com.hive.ResultAPI val param = IAPV4.IAPV4PurchaseParam.Builder() .setMarketPid("YOUR_PRODUCT_MARKET_PID") .setOldMarketPid("YOUR_PRODUCT_OLD_MARKET_PID") .setIapPayload("YOUR_PAYLOAD") .setOfferToken("YOUR_OFFER_ID_TOKEN") .build() IAPV4.purchaseSubscription(param, object : IAPV4.IAPV4PurchaseListener { override fun onIAPV4Purchase(result: ResultAPI, receipt: IAPV4.IAPV4Receipt?) { if (result.isSuccess) { // TODO: Request verification of receipt with received receipt } } }) |
API Reference: IAPV4.INSTANCE .purchaseSubscription
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import com.hive.IAPV4; import com.hive.ResultAPI; IAPV4.IAPV4PurchaseParam param = new IAPV4.IAPV4PurchaseParam.Builder() .setMarketPid("YOUR_PRODUCT_MARKET_PID") .setOldMarketPid("YOUR_PRODUCT_OLD_MARKET_PID") .setIapPayload("YOUR_PAYLOAD") .setOfferToken("YOUR_OFFER_ID_TOKEN") .build(); IAPV4.INSTANCE.purchaseSubscription(param, (result, iapV4Receipt) -> { if (result.isSuccess()) { // TODO: Request verification of receipt with received receipt } }); |
API Reference: IAPV4Interface.purchaseSubscription
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
import HIVEService let param = IAPV4PurchaseParam.Builder() .setMarketPid("YOUR_PRODUCT_MARKET_PID") .setOldMarketPid("YOUR_PRODUCT_OLD_MARKET_PID") .setIapPayload("YOUR_PAYLOAD") .setOfferToken("YOUR_OFFER_ID_TOKEN") .build() IAPV4Interface.purchaseSubscription(param) { result, receipt in if result.isSuccess() { // TODO: Request verification of receipt with received receipt } } |
API Reference: HIVEIAPV4 purchaseSubscription
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
#import <HIVEService/HIVEService-Swift.h> HIVEIAPV4PurchaseParamBuilder *builder = [[HIVEIAPV4PurchaseParamBuilder alloc] init]; HIVEIAPV4PurchaseParam *param = [[[[[builder setMarketPid: @"YOUR_PRODUCT_MARKET_PID"] setIapPayload: @"YOUR_PRODUCT_OLD_MARKET_PID"] setOldMarketPid: @"YOUR_PAYLOAD"] setOfferToken: @"YOUR_OFFER_ID_TOKEN"] build]; [HIVEIAPV4 purchaseSubscription: param handler: ^(HIVEResultAPI *result, HIVEIAPV4Receipt *receipt) { if ([result isSuccess]) { // TODO: Request verification of receipt with received receipt } }]; |
Subscription API
Get Subscription Product List
When a user enters the subscription product shop in the game, the IAPV4.getSubscriptionProductInfo()
method which queries the list of subscription products must be called. When this API is called, the IAPV4Product
object which contains the product list and product information will be returned as the result. The IAPV4Product
object is similar to the one returned in Searching Product List.
IAPV4Product
object
Field Name | Description |
marketPid | the unique product ID registered at in-app store |
currency | Currency type (e.g. KRW/USD) |
price | Product price |
title | Product title |
displayPrice | the string of the product price (e.g. $100.00) More |
productDescription | Product details |
originalMarketJson | the original product information received from the market when using Google subscription V2, the product information defined in the Google Play Console can be checked with this. |
displayOriginalPrice | Price string before discount Available with Hive SDK v4.12.0 and later, for Google only |
originalPrice | Original price without discount |
iconURL | Product icon (512*512) Available with Hive SDK v4.12.0 and later, for Google only |
displayPrice
- Send the displayPrice with the combination of currency sign and price in order (e.g. $0.99). As Android or iOS has its own display type, the order of currency sign and price may show up differently in several countries depending on the OS.
- Make sure to output the currency sign of each country as the same with its table. Refer to the Hive Identifier Policy to confirm the table of currency sign.
- In case of additional countries to add or change VAT, server calculates VAT of all currency and adds to displayPrice, price, displayOriginalPrice andoriginalPrice. Therefore, you have no more work relevant to VAT.
Followings are sample codes to implement getSubscriptionProductInfo()
method.
API Reference: hive.IAPV4.getProductInfo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
// Callback handler managing the request result of searching subscription lists public void onIAPV4ProductInfoCB(ResultAPI result, List productInfoList, int balance) { if (result.isSuccess()) { foreach(hive.IAPV4.IAPV4Product productInfo in productInfoList) { // Implementation of the desired features by the game studio, such as shop UI. } } else { // Error Handling } } // Request to search subscription lists hive.IAPV4.getSubscriptionProductInfo(onIAPV4ProductInfoCB); |
API Reference: IAPV4::getSubscriptionProductInfo
1 2 3 4 5 6 7 8 9 10 11 |
// Request to search subscription lists IAPV4::getSubscriptionProductInfo([=](ResultAPI const & result, std::vector const & productInfoList, unsigned int balance) { if (result.isSuccess()) { for( auto productInfo : productInfoList) { // Implementation of the desired features by the game studio, such as shop UI. } } else { // Error Handling } }); |
API Reference: com.hive.IAPV4.getSubscriptionProductInfo
1 2 3 4 5 6 7 8 9 10 11 12 13 |
// Request to search subscription lists IAPV4.getSubscriptionProductInfo(new IAPV4.IAPV4ProductInfoListener() { @Override public void onIAPV4ProductInfo(ResultAPI result, final List iapV4ProductList, final int balance) { if (result.isSuccess()) { for (IAPV4Product productInfo : iapV4ProductList) { // Implementation of the desired features by the game studio, such as shop UI. } } else { // Error Handling } } }); |
API Reference: HIVEIAPV4::getSubscriptionProductInfo:
1 2 3 4 5 6 7 8 9 10 11 |
// Request to search subscription lists [HIVEIAPV4 getSubscriptionProductInfo:^(HIVEResultAPI *result, NSArray *productInfoList, NSUInteger balance) { if( [result isSuccess]) { for( HIVEIAPV4Product* productInfo in productInfoList) { // Implementation of the desired features by the game studio, such as shop UI. } } else { // Error Handling } }]; |
Purchase Subscription Product
Call the IAPV4 class purchaseSubscriptionUpdate()
method to request subscription purchase using MarketPid registered in Apple App Store and Google Play Store as a parameter.
The following is an example implementation of purchaseSubscriptionUpdate()
.
API Reference: hive.IAPV4.purchaseSubscriptionUpdate
1 2 3 4 5 6 7 8 9 10 11 12 13 |
String marketPid = "{YOUR_PRODUCT_MARKET_PID}"; String oldMarketPid = "{YOUR_PRODUCT_OLD_MARKET_PID}"; String iapPayload = "{YOUR_PRODUCT_IAP_PAYLOAD}"; // Request to purchase subscription products IAPV4.purchaseSubscriptionUpdate(marketPid, oldMarketPid, iapPayload, (ResultAPI result, IAPV4Receipt receipt) => { if (result.isSuccess()) { // Request to verify the receipt with the received receipt } else { // Error Handling } }); |
API Reference: IAPV4::purchaseSubscriptionUpdate
1 2 3 4 5 6 7 8 9 10 11 12 13 |
std::string marketPid = "{YOUR_PRODUCT_MARKET_PID}"; std::string oldMarketPid = "{YOUR_PRODUCT_OLD_MARKET_PID}"; std::string iapPayload = "{YOUR_PRODUCT_IAP_PAYLOAD}"; // Request to purchase subscription products IAPV4::purchaseSubscriptionUpdate(marketPid, oldMarketPid, iapPayload, [=](ResultAPI const & result, IAPV4Receipt const & receipt) { if (result.isSuccess()) { // Request to verify the receipt with the received receipt } else { // Error Handling } }); |
API Reference: com.hive.IAPV4.purchaseSubscriptionUpdate
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
val marketPid = "{YOUR_PRODUCT_MARKET_PID}" val oldMarketPid = "{YOUR_PRODUCT_OLD_MARKET_PID}" val iapPayload = "{YOUR_PRODUCT_IAP_PAYLOAD}" // Request to purchase subscription products IAPV4.purchaseSubscriptionUpdate(pid, oldMarketPid, iapPayload, object : IAPV4.IAPV4PurchaseListener { override fun onIAPV4Purchase(result: ResultAPI, iapV4Receipt: IAPV4.IAPV4Receipt?) { if (result.isSuccess()) { // Request to verify the receipt with the received receipt } else { // Error Handling } } }) |
API Reference: com.hive.IAPV4.purchaseSubscriptionUpdate
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
String marketPid = "{YOUR_PRODUCT_MARKET_PID}"; String oldMarketPid = "{YOUR_PRODUCT_OLD_MARKET_PID}"; String iapPayload = "{YOUR_PRODUCT_IAP_PAYLOAD}"; // Request to purchase subscription products IAPV4.purchaseSubscriptionUpdate(pid, oldMarketPid, iapPayload, new IAPV4.IAPV4PurchaseListener() { @Override public void onIAPV4Purchase(ResultAPI result, IAPV4.IAPV4Receipt iapV4Receipt) { if (result.isSuccess()) { // Request to verify the receipt with the received receipt } else { // Error Handling } } }); |
API Reference: HIVEIAPV4::purchaseSubscriptionUpdate:oldMarketPid:additionalInfo:handler:
1 2 3 4 5 6 7 8 9 10 11 12 |
let marketPid = "{YOUR_PRODUCT_MARKET_PID}" let oldMarketPid = "{YOUR_PRODUCT_OLD_MARKET_PID}" let iapPayload = "{YOUR_PRODUCT_IAP_PAYLOAD}" // Request to purchase subscription products HIVEIAPV4.purchaseSubscriptionUpdate(marketPid, oldMarketPid: oldMarketPid, iapPayload: iapPayload) { result, receipt in if result.isSuccess() { // Request to verify the receipt with the received receipt } else { // Error Handling } } |
API Reference: HIVEIAPV4::purchaseSubscriptionUpdate:oldMarketPid:additionalInfo:handler:
1 2 3 4 5 6 7 8 9 10 11 12 |
NSString* marketPid = @"{YOUR_PRODUCT_MARKET_PID}"; NSString* oldMarketPid = @"{YOUR_PRODUCT_OLD_MARKET_PID}"; NSString* iapPayload = @"{YOUR_PRODUCT_IAP_PAYLOAD}"; // Request to purchase subscription products [HIVEIAPV4 purchaseSubscriptionUpdate:marketPid oldMarketPid:oldMarketPid iapPayload:iapPayload handler:^(HIVEResultAPI *result, HIVEIAPV4Receipt *receipt) { if ([result isSuccess]) { // Request to verify the receipt with the received receipt } else { // Error Handling } }]; |
Restoring subscription state
If the current subscription is not available on the subscriber’s device, implement restoreSubscription()
method in the IAPV4 class to restore the subscription and request the receipt of the charged subscription.
Followings are sample codes to implement restoreSubscription()
method.
API Reference: hive .IAPV4.restoreSubscription
1 2 3 4 5 6 7 |
using hive; IAPV4.restoreSubscription((ResultAPI result, List<IAPV4Receipt> receiptList) => { if (result.isSuccess()) { // TODO: Request receipt verification using the received receiptList } }); |
API Reference: IAPV4 ::restoreSubscription
1 2 3 4 5 6 7 8 9 |
#include <HIVE_SDK_Plugin/HIVE_CPP.h> using namespace std; using namespace hive; IAPV4::restoreSubscription([=](ResultAPI const & result, vector<reference_wrapper<IAPV4Receipt>> receiptList) { if (result.isSuccess()) { // TODO: Request receipt verification using the received receiptList } }); |
API Reference: IAPV4.restoreSubscription
1 2 3 4 5 6 7 8 9 10 |
import com.hive.IAPV4 import com.hive.ResultAPI IAPV4.restoreSubscription(object : IAPV4.IAPV4RestoreListener { override fun onIAPV4Restore(result: ResultAPI, iapv4ReceiptList: ArrayList<IAPV4.IAPV4Receipt>?) { if (result.isSuccess) { // TODO: Request receipt verification using the received iapv4ReceiptList } } }) |
API Reference: com .hive.IAPV4.restoreSubscription
1 2 3 4 5 6 7 8 |
import com.hive.IAPV4; import com.hive.ResultAPI; IAPV4.INSTANCE.restoreSubscription((result, iapv4ReceiptList) -> { if (result.isSuccess()) { // TODO: Request receipt verification using the received iapv4ReceiptList } }); |
API Reference: IAPV4Interface .restoreSubscription
1 2 3 4 5 6 7 |
import HIVEService IAPV4Interface.restoreSubscription() { result, receiptList in if result.isSuccess() { // TODO: Request receipt verification using the received receiptList } } |
API Reference: HIVEIAPV4 ::restoreSubscription:
1 2 3 4 5 6 7 |
#import <HIVEService/HIVEService-Swift.h> [HIVEIAPV4 restoreSubscription: ^(HIVEResultAPI *result, NSArray<HIVEIAPV4Receipt *> *receiptList) { if ([result isSuccess]) { // TODO: Request receipt verification using the received receiptList } }]; |