[Unity Plugin] Upgrade ONE store IAP
Compare Import Unity Package
SDK V17
SDK V19
PURCHASE
Onestore_IapCallbackManager.cs
GaaCallbackManager.cs
Onestore_IapCallManager.cs
GaaCallManager.cs
Onestore_IapResultListener.cs
GaaIapResultListener.cs
Onestore_PurchaseResponse.cs
GaaPurchaseResponse.cs
UTIL
AndroidNative.cs
AndroidNative.cs
UI
Onestore_IapUi.cs
MainUIScript.cs
LogScript.cs
LoadingScript.cs
JSON
global-appstores.json
Compare IapCallManager API
v17 Onestore_IapCallManager.cs
v19 GaaIapCallManager.cs
Connect to billing module
connect
StartConnection
Disconnect with billing module
terminate
EndConnection
Check support status
isBillingSupported
x
Purchase in-app
launchPurchaseFlowAsync
LaunchPurchaseFlow
Consume in-app
consume
Consume
Acknowledge in-app purchase
x
Acknowledge
Purchase history of unconsumed in-app
(including monthly automatic payment)
getPurchases
QueryPurchases
In-app product details
getProductDetails
QueryProductDetails
Change monthly automatic payment status
manageRecurringAuto
ManageRecurringProduct
Update or install billing module
x
LaunchUpdateOrInstallFlow
Call ONE store login
login
LaunchLoginFlow
Check market identification code
x
GetStoreInfo
Initialize & connect ONE store IAP
In v19 SDK and above, you can determine whether it is a success or failure with the value of IapResult.code.
The way to connect to the billing module is the same.
Before
// Onestore_IapUi.cs (C#)public
void
connectService (){ var base64EncodedPublicKey = "MIGfMA0GCSqGSIb3D...."; IapCallManager.connectService (base64EncodedPublicKey);}
After
// MainUIScript.cspublic
void
StartConnection(){ if
(GaaIapCallManager.IsServiceAvailable() == false) { GaaIapCallManager.StartConnection( /* your public key */
); }}
The response to the successful or failed connection has significantly changed.
In SDK V17, you had to confirm the support status through isBillingSupported() after the successful connection.
However, in SDK V19 and above, you do not need to check the support status. Inside the SDK, the support status will be automatically checked.
To check the value of IapResult.code, refer to PurchaseResponse.ResponseCode.
Before
// Onestore_IapCallbackManager.cs (C#)public
static
event
Action<string> serviceConnectionEvent;public
void
ServiceConnectionListener (string
callback){ if
(callback.Contains (preDefinedStrings [CBType.Connected])) { serviceAvailableEvent (); } serviceConnectionEvent (callback);}
// Onestore_IapResultListener.cs (C#)Onestore_IapCallbackManager.serviceConnectionEvent += serviceConnectionResult;void
serviceConnectionResult (string
result){ AndroidNative.showMessage ("serivce connect", result, "ok");}
After
// GaaIapResultListener.csGaaIapCallbackManager.PurchaseClientStateEvent += PurchaseClientStateEvent;void
PurchaseClientStateEvent(IapResult iapResult){ if
(iapResult.IsSuccess()) { ... } else
if
(iapResult.code == ResponseCode.RESULT_NEED_UPDATE) { ... } else
if
(iapResult.code == ResponseCode.RESULT_NEED_LOGIN) { ... }}
Check in-app product details
Before
// Onestore_IapUi.cs (C#)public
void
getProductDetails (){ var inapp_products = new
string[] {inapp_pId1, inapp_pId2, inapp_pId3}; var auto_products = new
string[] {auto_pId1};
IapCallManager.getProductDetails (inapp_products, inapp_type); IapCallManager.getProductDetails (auto_products, auto_type);}
Specify the array value of the in-app ID (productid) and the corresponding in-app type. There are two types of in-app: Managed product (ProductType.INAPP) and Monthly auto-renewal product (ProductType.AUTO). Enter ProductType.ALL to check both types of in-app.
After
// MainUIScript.cs// 상품 상세 정보를 조회한다.string[] all_products = { inapp_p5000, inapp_p10000, inapp_p50000, auto_a100000 };GaaIapCallManager.QueryProductDetails(all_products, ProductType.ALL);
or
string[] inapp_products = new
string[] {inapp_p5000, inapp_p10000, inapp_p50000};string[] auto_products = new
string[] {auto_a100000};
GaaIapCallManager.QueryProductDetails(inapp_products, ProductType.INAPP);GaaIapCallManager.QueryProductDetails(auto_products, ProductType.AUTO);
You can receive the response result value of checking the in-app product details through ProductDetailsSuccessEvent(), ProductDetailsErrorEvent() of GaaIapResultListener.
The communication between Android and Unity is string communication. There is a limit in the string length to be sent at once, and therefore the result value will be transmitted per in-app at a time.
Therefore, the value of ProductDetailsSuccessEvent(..., ..., int count, int totalCount) is important.
ex) If there is one in-app: count = 1, totalCount = 1 /
if there are 10 in-apps: count = 1, totalCount = 10 ... count = 10, totalCount = 10
Before
// Onestore_IapCallbackManager.cs (C#)public
static
event
Action<ProductDetail> queryProductsSuccessEvent;public
static
event
Action<string> queryProductsErrorEvent;
public
void
QueryProductsListener (string
callback){ string
data = findStringAfterCBType (callback, CBType.Success); if
(data.Length > 0) { ProductDetail productDetail = JsonUtility.FromJson<ProductDetail> (data); queryProductsSuccessEvent (productDetail); } else
{ string
errorData = findStringAfterCBType (callback, CBType.Error); queryProductsErrorEvent (errorData); }}
// Onestore_IapResultListener.cs (C#)void
queryProductsSuccessEvent (ProductDetail result){ AndroidNative.showMessage ("queryProducts success", result.ToString (), "ok");}
void
queryProductsErrorEvent (string
result) { AndroidNative.showMessage ("queryProducts error", result, "ok");}
After
// GaaIapResultListener.csList<ProductDetail> products = new
List<ProductDetail>();void
ProductDetailsSuccessEvent(ProductDetail productDetail, int
count, int
totalCount){ if
(count == 1) { products.Clear(); }
products.Add(productDetail);
if
(count == totalCount) { // send ProductDetail List to UI }}
void
ProductDetailsErrorEvent(IapResult iapResult){ if
(iapResult.code == ResponseCode.RESULT_NEED_UPDATE) { ... } else
if
(iapResult.code == ResponseCode.RESULT_NEED_LOGIN) { ... }}
Request purchase
To purchase the in-app, changes have been made in putting productId, productType obtained with QueryProductDetails into the PurchaseFlowParams object and sending it.
Before
// Onestore_IapUi.cs (C#)public
void
buyProductInapp (){ //Up to 100 bytes are permitted for developPayload in size. IapCallManager.buyProduct (inapp_pId1, inapp_type, devPayload);}
After
// MainUIScript.csvoid
BuyProduct(string
productId, string
type){ PurchaseFlowParams param = new
PurchaseFlowParams(); param.productId = productId; param.productType = type; //param.productName = ""; //param.devPayload = "your Developer Payload"; // Up to 200 bytes are permitted for developPayload in size. //param.gameUserId = ""; //param.promotionApplicable = false;
GaaIapCallManager.LaunchPurchaseFlow(param);}
If you call the LaunchPurchaseFlow() method, ONE store billing screen will appear.
Fig.1 ONE store in-app billing screen
For the same reason as ‘Check in-app product information’, count, totalCount exist in the part in which the response result to payment has been received.
Before
// Onestore_IapCallbackManager.cs (C#)public
static
event
Action<PurchaseData> getPurchaseIntentSuccessEvent;public
static
event
Action<string> getPurchaseIntentErrorEvent;
public
void
PurchaseFlowListener (string
callback){ string
data = findStringAfterCBType (callback, CBType.Success);
if
(data.Length > 0) { try
{ PurchaseResponse purchaseRes = JsonUtility.FromJson<PurchaseResponse> (data); PurchaseData purchaseData = JsonUtility.FromJson<PurchaseData> (purchaseRes.purchaseData); getPurchaseIntentSuccessEvent (purchaseData); } catch
(System.Exception ex) { Debug.Log ("PurchaseFlowListener Exception "
+ ex.Message); } } else
{ //onError만 뒤에 추가데이터 IapResult 가 있으므로 추가 데이터만 전달해주고 나머지 에러들은 추가 데이터가 없으므로 callback 그대로만 전달해준다. string
errorData = findStringAfterCBType (callback, CBType.Error); if
(errorData.Length > 0) { getPurchaseIntentErrorEvent (errorData); } else
{ getPurchaseIntentErrorEvent (callback); } }}
// Onestore_IapResultListener.cs (C#)void
getPurchaseIntentSuccessResult (PurchaseData result){ AndroidNative.showMessage ("getPurchaseIntent sucess", result.ToString (), "ok"); PlayerPrefs.SetString (result.productId, JsonUtility.ToJson (result));}
void
getPurchaseIntentErrorResult (string
result){ AndroidNative.showMessage ("getPurchaseIntent error", result, "ok");}
After
// GaaIapResultListener.csprivate
List<PurchaseData> purchases = new
List<PurchaseData>();private
List<string> signatures = new
List<string>();
void
PurchaseUpdatedSuccessEvent(PurchaseData purchaseData, string
signature, int
count, int
totalCount){ if
(purchaseData != null) { if
(count == 1) { purchases.Clear(); signatures.Clear(); }
purchases.Add(purchaseData); signatures.Add(signature);
if
(count == totalCount) { OnPurchaseUpdatedResponse(purchases, signatures); // send to ui } } else { // no PurchaseData }}
void
PurchaseUpdatedErrorEvent(IapResult iapResult){ ...}
Acknowledge purchase
This API is newly added to ONE store IAP library V6(SDK V19).
For details, refer to ‘Use ONE store IAP in Unity’.
Consume Managed product
Before
// Onestore_IapUi.cs (C#)public
void
consume (){ string
inapp_json = PlayerPrefs.GetString (inapp_pId1);
if
(inapp_json.Length > 0) { IapCallManager.consume (inapp_json); } else
{ AndroidNative.showMessage ("error", "no data to consume", "ok"); }}
After
// MainUIScript.csPurchaseData purchaseData = ...GaaIapCallManager.Consume(purchaseData, "your developer payload");
Check purchase history
There is no significant change in the request for check purchase hitsory.
Before
// Onestore_IapUi.cs (C#)public
void
getPurchases (){ Onestore_IapCallManager.getPurchases ();}
// Onestore_IapCallMnager.cs (C#)//inapp과 auto 두 가지 상품 타입이 존재하는데 각각 상품에 대해서 각각 따로 호출해야 합니다. 개발사에서 변경 가능한 부분public
static
void
getPurchases (){ checkServiceAvailable (); iapRequestAdapter.Call ("getPurchase", IAP_API_VERSION, "inapp"); iapRequestAdapter.Call ("getPurchase", IAP_API_VERSION, "auto");}
After
// MainUIScript.csGaaIapCallManager.QueryPurchases(ProductType.INAPP);GaaIapCallManager.QueryPurchases(ProductType.AUTO);
The following is the response part and is transmitted the same as the response for ‘Request purchase’.
Before
// Onestore_IapCallbackManager.cs (C#)public
static
event
Action<PurchaseData> getPurchaseSuccessEvent;public
static
event
Action<string> getPurchaseErrorEvent;
public
void
QueryPurchaseListener (string
callback){ string
data = findStringAfterCBType (callback, CBType.Success); if
(data.Length > 0) { try
{ PurchaseResponse purchaseRes = JsonUtility.FromJson<PurchaseResponse> (data); PurchaseData purchaseData = JsonUtility.FromJson<PurchaseData> (purchaseRes.purchaseData); getPurchaseSuccessEvent (purchaseData); } catch
(System.Exception ex) { Debug.Log ("QueryPurchaseListener Exception "
+ ex.Message); getPurchaseErrorEvent (data); //success but no data } } else
{ //onError만 뒤에 추가데이터 IapResult 가 있으므로 추가 데이터만 전달해주고 나머지 에러들은 추가 데이터가 없으므로 callback 그대로만 전달해줍니다. string
errorData = findStringAfterCBType (callback, CBType.Error); if
(errorData.Length > 0) { getPurchaseErrorEvent (errorData); } else
{ getPurchaseErrorEvent (callback); } }}
After
// GaaIapResultListener.csvoid
QueryPurchasesSuccessEvent(PurchaseData purchaseData, string
signature, int
count, int
totalCount)
void
QueryPurchasesErrorEvent(IapResult iapResult)
Change Monthly auto-renewal product status
In SDK V17, the developer had to decide recurringState in person and to send the command value, however, in SDK V19, if PurchaseData is entered, the SDK determines and transfers the command value.
Before
// Onestore_IapUi.cs (C#)public
void
cancelAutoItem (){ string
auto_json = PlayerPrefs.GetString (auto_pId1); PurchaseData response = JsonUtility.FromJson<PurchaseData> (auto_json);
if
(auto_json.Length > 0) { string
command = ""; if
(response.recurringState == 0) { command = "cancel"; } else
if
(response.recurringState == 1) { command = "reactivate"; } IapCallManager.manageRecurringAuto (auto_json, command); } else
{ AndroidNative.showMessage ("Warning!!", "no data for manageRecurringAuto", "ok"); }}
After
// MainUIScript.csPurchaseData purchaseData = ...string
recurringAction;if
(purchaseData.recurringState == RecurringState.RECURRING) { recurringAction = RecurringAction.CANCEL;} else
if
(purchaseData.recurringState == RecurringState.CANCEL) { recurringAction = RecurringAction.REACTIVATE;}GaaIapCallManager.ManageRecurringProduct(purchaseData, recurringAction);
Request ONE store login
Before
// Onestore_IapUi.cs (C#)IapCallManager.login();
// Onestore_IapResultListener.cs (C#)void
getLoginIntentEvent (string
result){ AndroidNative.showMessage ("getLoginIntent ", result.ToString (), "ok");}
After
// MainUIScript.csGaaIapCallManager.LaunchLoginFlow();
// GaaIapResultListener.csvoid
LoginFlowEvent(IapResult iapResult){ if
(iapResult.IsSuccess()) { // You need to specify the scenario after successful login. }}
Install ONE store service (OSS)
This API is newly added to ONE store IAP library V6(SDK V19).
For details, refer to ‘Use ONE store IAP in Unity’.
Obtain store identification code
This API is newly added to ONE store IAP library V6(SDK V19).
For details, refer to ‘Use ONE store IAP in Unity’.
Compare Import Unity Package
SDK V17
SDK V19
PURCHASE
Onestore_IapCallbackManager.cs
GaaCallbackManager.cs
Onestore_IapCallManager.cs
GaaCallManager.cs
Onestore_IapResultListener.cs
GaaIapResultListener.cs
Onestore_PurchaseResponse.cs
GaaPurchaseResponse.cs
UTIL
AndroidNative.cs
AndroidNative.cs
UI
Onestore_IapUi.cs
MainUIScript.cs
LogScript.cs
LoadingScript.cs
JSON
global-appstores.json
Compare IapCallManager API
v17 Onestore_IapCallManager.cs
v19 GaaIapCallManager.cs
Connect to billing module
connect
StartConnection
Disconnect with billing module
terminate
EndConnection
Check support status
isBillingSupported
x
Purchase in-app
launchPurchaseFlowAsync
LaunchPurchaseFlow
Consume in-app
consume
Consume
Acknowledge in-app purchase
x
Acknowledge
Purchase history of unconsumed in-app
(including monthly automatic payment)
getPurchases
QueryPurchases
In-app product details
getProductDetails
QueryProductDetails
Change monthly automatic payment status
manageRecurringAuto
ManageRecurringProduct
Update or install billing module
x
LaunchUpdateOrInstallFlow
Call ONE store login
login
LaunchLoginFlow
Check market identification code
x
GetStoreInfo
Initialize & connect ONE store IAP
In v19 SDK and above, you can determine whether it is a success or failure with the value of IapResult.code.
The way to connect to the billing module is the same.
Before
// Onestore_IapUi.cs (C#)public
void
connectService (){ var base64EncodedPublicKey = "MIGfMA0GCSqGSIb3D...."; IapCallManager.connectService (base64EncodedPublicKey);}
After
// MainUIScript.cspublic
void
StartConnection(){ if
(GaaIapCallManager.IsServiceAvailable() == false) { GaaIapCallManager.StartConnection( /* your public key */
); }}
The response to the successful or failed connection has significantly changed.
In SDK V17, you had to confirm the support status through isBillingSupported() after the successful connection.
However, in SDK V19 and above, you do not need to check the support status. Inside the SDK, the support status will be automatically checked.
To check the value of IapResult.code, refer to PurchaseResponse.ResponseCode.
Before
// Onestore_IapCallbackManager.cs (C#)public
static
event
Action<string> serviceConnectionEvent;public
void
ServiceConnectionListener (string
callback){ if
(callback.Contains (preDefinedStrings [CBType.Connected])) { serviceAvailableEvent (); } serviceConnectionEvent (callback);}
// Onestore_IapResultListener.cs (C#)Onestore_IapCallbackManager.serviceConnectionEvent += serviceConnectionResult;void
serviceConnectionResult (string
result){ AndroidNative.showMessage ("serivce connect", result, "ok");}
After
// GaaIapResultListener.csGaaIapCallbackManager.PurchaseClientStateEvent += PurchaseClientStateEvent;void
PurchaseClientStateEvent(IapResult iapResult){ if
(iapResult.IsSuccess()) { ... } else
if
(iapResult.code == ResponseCode.RESULT_NEED_UPDATE) { ... } else
if
(iapResult.code == ResponseCode.RESULT_NEED_LOGIN) { ... }}
Check in-app product details
Before
// Onestore_IapUi.cs (C#)public
void
getProductDetails (){ var inapp_products = new
string[] {inapp_pId1, inapp_pId2, inapp_pId3}; var auto_products = new
string[] {auto_pId1};
IapCallManager.getProductDetails (inapp_products, inapp_type); IapCallManager.getProductDetails (auto_products, auto_type);}
Specify the array value of the in-app ID (productid) and the corresponding in-app type. There are two types of in-app: Managed product (ProductType.INAPP) and Monthly auto-renewal product (ProductType.AUTO). Enter ProductType.ALL to check both types of in-app.
After
// MainUIScript.cs// 상품 상세 정보를 조회한다.string[] all_products = { inapp_p5000, inapp_p10000, inapp_p50000, auto_a100000 };GaaIapCallManager.QueryProductDetails(all_products, ProductType.ALL);
or
string[] inapp_products = new
string[] {inapp_p5000, inapp_p10000, inapp_p50000};string[] auto_products = new
string[] {auto_a100000};
GaaIapCallManager.QueryProductDetails(inapp_products, ProductType.INAPP);GaaIapCallManager.QueryProductDetails(auto_products, ProductType.AUTO);
You can receive the response result value of checking the in-app product details through ProductDetailsSuccessEvent(), ProductDetailsErrorEvent() of GaaIapResultListener.
The communication between Android and Unity is string communication. There is a limit in the string length to be sent at once, and therefore the result value will be transmitted per in-app at a time.
Therefore, the value of ProductDetailsSuccessEvent(..., ..., int count, int totalCount) is important.
ex) If there is one in-app: count = 1, totalCount = 1 /
if there are 10 in-apps: count = 1, totalCount = 10 ... count = 10, totalCount = 10
Before
// Onestore_IapCallbackManager.cs (C#)public
static
event
Action<ProductDetail> queryProductsSuccessEvent;public
static
event
Action<string> queryProductsErrorEvent;
public
void
QueryProductsListener (string
callback){ string
data = findStringAfterCBType (callback, CBType.Success); if
(data.Length > 0) { ProductDetail productDetail = JsonUtility.FromJson<ProductDetail> (data); queryProductsSuccessEvent (productDetail); } else
{ string
errorData = findStringAfterCBType (callback, CBType.Error); queryProductsErrorEvent (errorData); }}
// Onestore_IapResultListener.cs (C#)void
queryProductsSuccessEvent (ProductDetail result){ AndroidNative.showMessage ("queryProducts success", result.ToString (), "ok");}
void
queryProductsErrorEvent (string
result) { AndroidNative.showMessage ("queryProducts error", result, "ok");}
After
// GaaIapResultListener.csList<ProductDetail> products = new
List<ProductDetail>();void
ProductDetailsSuccessEvent(ProductDetail productDetail, int
count, int
totalCount){ if
(count == 1) { products.Clear(); }
products.Add(productDetail);
if
(count == totalCount) { // send ProductDetail List to UI }}
void
ProductDetailsErrorEvent(IapResult iapResult){ if
(iapResult.code == ResponseCode.RESULT_NEED_UPDATE) { ... } else
if
(iapResult.code == ResponseCode.RESULT_NEED_LOGIN) { ... }}
Request purchase
To purchase the in-app, changes have been made in putting productId, productType obtained with QueryProductDetails into the PurchaseFlowParams object and sending it.
Before
// Onestore_IapUi.cs (C#)public
void
buyProductInapp (){ //Up to 100 bytes are permitted for developPayload in size. IapCallManager.buyProduct (inapp_pId1, inapp_type, devPayload);}
After
// MainUIScript.csvoid
BuyProduct(string
productId, string
type){ PurchaseFlowParams param = new
PurchaseFlowParams(); param.productId = productId; param.productType = type; //param.productName = ""; //param.devPayload = "your Developer Payload"; // Up to 200 bytes are permitted for developPayload in size. //param.gameUserId = ""; //param.promotionApplicable = false;
GaaIapCallManager.LaunchPurchaseFlow(param);}
If you call the LaunchPurchaseFlow() method, ONE store billing screen will appear.
Fig.1 ONE store in-app billing screen
For the same reason as ‘Check in-app product information’, count, totalCount exist in the part in which the response result to payment has been received.
Before
// Onestore_IapCallbackManager.cs (C#)public
static
event
Action<PurchaseData> getPurchaseIntentSuccessEvent;public
static
event
Action<string> getPurchaseIntentErrorEvent;
public
void
PurchaseFlowListener (string
callback){ string
data = findStringAfterCBType (callback, CBType.Success);
if
(data.Length > 0) { try
{ PurchaseResponse purchaseRes = JsonUtility.FromJson<PurchaseResponse> (data); PurchaseData purchaseData = JsonUtility.FromJson<PurchaseData> (purchaseRes.purchaseData); getPurchaseIntentSuccessEvent (purchaseData); } catch
(System.Exception ex) { Debug.Log ("PurchaseFlowListener Exception "
+ ex.Message); } } else
{ //onError만 뒤에 추가데이터 IapResult 가 있으므로 추가 데이터만 전달해주고 나머지 에러들은 추가 데이터가 없으므로 callback 그대로만 전달해준다. string
errorData = findStringAfterCBType (callback, CBType.Error); if
(errorData.Length > 0) { getPurchaseIntentErrorEvent (errorData); } else
{ getPurchaseIntentErrorEvent (callback); } }}
// Onestore_IapResultListener.cs (C#)void
getPurchaseIntentSuccessResult (PurchaseData result){ AndroidNative.showMessage ("getPurchaseIntent sucess", result.ToString (), "ok"); PlayerPrefs.SetString (result.productId, JsonUtility.ToJson (result));}
void
getPurchaseIntentErrorResult (string
result){ AndroidNative.showMessage ("getPurchaseIntent error", result, "ok");}
After
// GaaIapResultListener.csprivate
List<PurchaseData> purchases = new
List<PurchaseData>();private
List<string> signatures = new
List<string>();
void
PurchaseUpdatedSuccessEvent(PurchaseData purchaseData, string
signature, int
count, int
totalCount){ if
(purchaseData != null) { if
(count == 1) { purchases.Clear(); signatures.Clear(); }
purchases.Add(purchaseData); signatures.Add(signature);
if
(count == totalCount) { OnPurchaseUpdatedResponse(purchases, signatures); // send to ui } } else { // no PurchaseData }}
void
PurchaseUpdatedErrorEvent(IapResult iapResult){ ...}
Acknowledge purchase
This API is newly added to ONE store IAP library V6(SDK V19).
For details, refer to ‘Use ONE store IAP in Unity’.
Consume Managed product
Before
// Onestore_IapUi.cs (C#)public
void
consume (){ string
inapp_json = PlayerPrefs.GetString (inapp_pId1);
if
(inapp_json.Length > 0) { IapCallManager.consume (inapp_json); } else
{ AndroidNative.showMessage ("error", "no data to consume", "ok"); }}
After
// MainUIScript.csPurchaseData purchaseData = ...GaaIapCallManager.Consume(purchaseData, "your developer payload");
Check purchase history
There is no significant change in the request for check purchase hitsory.
Before
// Onestore_IapUi.cs (C#)public
void
getPurchases (){ Onestore_IapCallManager.getPurchases ();}
// Onestore_IapCallMnager.cs (C#)//inapp과 auto 두 가지 상품 타입이 존재하는데 각각 상품에 대해서 각각 따로 호출해야 합니다. 개발사에서 변경 가능한 부분public
static
void
getPurchases (){ checkServiceAvailable (); iapRequestAdapter.Call ("getPurchase", IAP_API_VERSION, "inapp"); iapRequestAdapter.Call ("getPurchase", IAP_API_VERSION, "auto");}
After
// MainUIScript.csGaaIapCallManager.QueryPurchases(ProductType.INAPP);GaaIapCallManager.QueryPurchases(ProductType.AUTO);
The following is the response part and is transmitted the same as the response for ‘Request purchase’.
Before
// Onestore_IapCallbackManager.cs (C#)public
static
event
Action<PurchaseData> getPurchaseSuccessEvent;public
static
event
Action<string> getPurchaseErrorEvent;
public
void
QueryPurchaseListener (string
callback){ string
data = findStringAfterCBType (callback, CBType.Success); if
(data.Length > 0) { try
{ PurchaseResponse purchaseRes = JsonUtility.FromJson<PurchaseResponse> (data); PurchaseData purchaseData = JsonUtility.FromJson<PurchaseData> (purchaseRes.purchaseData); getPurchaseSuccessEvent (purchaseData); } catch
(System.Exception ex) { Debug.Log ("QueryPurchaseListener Exception "
+ ex.Message); getPurchaseErrorEvent (data); //success but no data } } else
{ //onError만 뒤에 추가데이터 IapResult 가 있으므로 추가 데이터만 전달해주고 나머지 에러들은 추가 데이터가 없으므로 callback 그대로만 전달해줍니다. string
errorData = findStringAfterCBType (callback, CBType.Error); if
(errorData.Length > 0) { getPurchaseErrorEvent (errorData); } else
{ getPurchaseErrorEvent (callback); } }}
// GaaIapResultListener.cs void QueryPurchasesSuccessEvent(PurchaseData purchaseData, string signature, int count, int totalCount)
void QueryPurchasesErrorEvent(IapResult iapResult)
After
// GaaIapResultListener.csvoid
PurchaseUpdatedSuccessEvent(PurchaseData purchaseData, string
signature, int
count, int
totalCount)
void
PurchaseUpdatedErrorEvent(IapResult iapResult)
Change Monthly auto-renewal product status
In SDK V17, the developer had to decide recurringState in person and to send the command value, however, in SDK V19, if PurchaseData is entered, the SDK determines and transfers the command value.
Before
// Onestore_IapUi.cs (C#)public
void
cancelAutoItem (){ string
auto_json = PlayerPrefs.GetString (auto_pId1); PurchaseData response = JsonUtility.FromJson<PurchaseData> (auto_json);
if
(auto_json.Length > 0) { string
command = ""; if
(response.recurringState == 0) { command = "cancel"; } else
if
(response.recurringState == 1) { command = "reactivate"; } IapCallManager.manageRecurringAuto (auto_json, command); } else
{ AndroidNative.showMessage ("Warning!!", "no data for manageRecurringAuto", "ok"); }}
After
// MainUIScript.csPurchaseData purchaseData = ...string
recurringAction;if
(purchaseData.recurringState == RecurringState.RECURRING) { recurringAction = RecurringAction.CANCEL;} else
if
(purchaseData.recurringState == RecurringState.CANCEL) { recurringAction = RecurringAction.REACTIVATE;}GaaIapCallManager.ManageRecurringProduct(purchaseData, recurringAction);
Request ONE store login
Before
// Onestore_IapUi.cs (C#)IapCallManager.login();
// Onestore_IapResultListener.cs (C#)void
getLoginIntentEvent (string
result){ AndroidNative.showMessage ("getLoginIntent ", result.ToString (), "ok");}
After
// MainUIScript.csGaaIapCallManager.LaunchLoginFlow();
// GaaIapResultListener.csvoid
LoginFlowEvent(IapResult iapResult){ if
(iapResult.IsSuccess()) { // You need to specify the scenario after successful login. }}
Install ONE store service (OSS)
This API is newly added to ONE store IAP library V6(SDK V19).
For details, refer to ‘Use ONE store IAP in Unity’.
Obtain store identification code
This API is newly added to ONE store IAP library V6(SDK V19).
For details, refer to ‘Use ONE store IAP in Unity’.
Last updated