SDKBOX IAP - Problem with listener

SDKBOX IAP - Problem with listener
0.0 0

#1

Hello, i have some problem with sdkbox iap for javascript 3x (v2.3.16.1)

  1. when i refresh(), i got onProductRequestSuccess(products) but each product in products not have the “priceValue”, and “price” is a string with error currency symbol like “₫22,000”
  2. Im developing android game, so when i open purchase, purchase popup showed, and after that i press back, the popup closed but the function “onCanceled” not be triggered.
    Anyone can help me? :frowning: Many thanks

#2

@nite please help me :frowning:


#3

plz try our js sample https://github.com/sdkbox/sdkbox-sample-iap/tree/master/js

and be sure run your app in release mode.

cocos run -p android -m release

should use this patch:

diff --git a/js/frameworks/runtime-src/Classes/PluginIAPJSHelper.cpp b/js/frameworks/runtime-src/Classes/PluginIAPJSHelper.cpp
index 1a03bc7..1cb9486 100644
--- a/js/frameworks/runtime-src/Classes/PluginIAPJSHelper.cpp
+++ b/js/frameworks/runtime-src/Classes/PluginIAPJSHelper.cpp
@@ -19,6 +19,7 @@ void product_to_obj(JSContext* cx, const sdkbox::Product& p, JS::MutableHandleOb
     JS::RootedValue title(cx);
     JS::RootedValue description(cx);
     JS::RootedValue price(cx);
+    JS::RootedValue priceValue(cx);
     JS::RootedValue currencyCode(cx);
     JS::RootedValue receipt(cx);
     JS::RootedValue receiptCipheredPayload(cx);
@@ -35,6 +36,8 @@ void product_to_obj(JSContext* cx, const sdkbox::Product& p, JS::MutableHandleOb
     JS_SetProperty(cx, jsobj, "description", description);
     price = SB_STR_TO_JSVAL(cx, p.price);
     JS_SetProperty(cx, jsobj, "price", price);
+    priceValue = JS::DoubleValue(p.priceValue);
+    JS_SetProperty(cx, jsobj, "priceValue", priceValue);
     currencyCode = SB_STR_TO_JSVAL(cx, p.currencyCode);
     JS_SetProperty(cx, jsobj, "currencyCode", currencyCode);
     receipt = SB_STR_TO_JSVAL(cx, p.receipt);
@@ -52,6 +55,7 @@ void product_to_obj(JSContext* cx, const sdkbox::Product& p, JS::MutableHandleOb
     JS::RootedValue title(cx);
     JS::RootedValue description(cx);
     JS::RootedValue price(cx);
+    JS::RootedValue priceValue(cx);
     JS::RootedValue currencyCode(cx);
     JS::RootedValue receipt(cx);
     JS::RootedValue receiptCipheredPayload(cx);
@@ -68,6 +72,8 @@ void product_to_obj(JSContext* cx, const sdkbox::Product& p, JS::MutableHandleOb
     JS_SetProperty(cx, jsobj, "description", description);
     price = SB_STR_TO_JSVAL(cx, p.price);
     JS_SetProperty(cx, jsobj, "price", price);
+    priceValue = JS::DoubleValue(p.priceValue);
+    JS_SetProperty(cx, jsobj, "priceValue", priceValue);
     currencyCode = SB_STR_TO_JSVAL(cx, p.currencyCode);
     JS_SetProperty(cx, jsobj, "currencyCode", currencyCode);
     receipt = SB_STR_TO_JSVAL(cx, p.receipt);
@@ -85,6 +91,7 @@ void product_to_obj(JSContext* cx, const sdkbox::Product& p, JS::MutableHandleOb
     jsval title;
     jsval description;
     jsval price;
+    jsval priceValue;
     jsval currencyCode;
     jsval receipt;
     jsval receiptCipheredPayload;
@@ -101,6 +108,8 @@ void product_to_obj(JSContext* cx, const sdkbox::Product& p, JS::MutableHandleOb
     JS_SetProperty(cx, jsobj, "description", &description);
     price = SB_STR_TO_JSVAL(cx, p.price);
     JS_SetProperty(cx, jsobj, "price", &price);
+    priceValue = JS::DoubleValue(p.priceValue);
+    JS_SetProperty(cx, jsobj, "priceValue", priceValue);
     currencyCode = SB_STR_TO_JSVAL(cx, p.currencyCode);
     JS_SetProperty(cx, jsobj, "currencyCode", &currencyCode);
     receipt = SB_STR_TO_JSVAL(cx, p.receipt);

some issue : 2.99 (c++) ----> 2.990000000088123


#4

@yinjimmy: i dont know but i cannot run sample project, but I am sure that sdkbox iap is running
Here is log (at java)

but at onProductRequestSuccess on javascript, i log products by: cc.log("onProductRequestSuccess: " + JSON.stringify(products));
It become:


#5

need to setup first , https://github.com/sdkbox/sdkbox-sample-iap#getting-started

en, i’m trying to reproduce. what is the correct value ? “price”:“₫22,000”, ?


#6

@yinjimmy: yes, i need the result is “price”:“₫22,000” and “priceValue”: “22000” in javascript :frowning:


#7

can you get correct “price”:“₫22,000” in c++


#8

I try to run sample project, but i got error when run “cocos run -p android -m release” (i ran setup_win32.bat already)


#9

run sdkbox update before compile


#10

plz try https://raw.githubusercontent.com/sdkbox/sdkbox-sample-iap/master/js/frameworks/runtime-src/Classes/PluginIAPJSHelper.cpp, replace it with your local file, BACKUP FIRST.

then use pidcat to watch the logcat .

replace with your package id

pidcat org.cocos2dx.PluginTest | grep ">>>>>"   # grep the c++ string value

and , how to reproduce it ? change phone system language ?


#11

i run, but nothing update
sdkbox update


|______ | \ |____/ |] | | _/
| |/ | _ |
] |____| _/ _
Copyright © 2016-2017 SDKBOX Inc. v1.0.1.23
test speed of hosts…

  • test host main: 170.00KB/s.
  • test host china: 35.03KB/s.
    choose the fastest server ‘main’, speed is 170.00KB/s.
    you have no packages installed.

#12

No, i run by default, im from vietnam :grinning:


#13

@yinjimmy, i run sample project, the result is same
JS: name: coin_package
JS: price: ₫63,633

Log in C++ is right:

[₫63,633]
[₫42,496]


#14

thanks for your testing.


#15

I have updated https://raw.githubusercontent.com/sdkbox/sdkbox-sample-iap/master/js/frameworks/runtime-src/Classes/PluginIAPJSHelper.cpp

can you try it again ?


#16

JS: name: remove_ads
JS: price: ₫106,197
JS: priceValue: 106197
Awesome, it run perfectly :grinning::grinning::grinning: Thank you very much :grinning::grinning::grinning:


#17

it’s great.