增加google支付

This commit is contained in:
CounterFire2023 2023-07-09 18:55:35 +08:00
parent 99d1da303d
commit cefd5352dc
3 changed files with 84 additions and 4 deletions

View File

@ -712,6 +712,20 @@ void toWalletJNI(const std::string& url)
JniHelper::callStaticVoidMethod(JCSDK, "toWallet", url);
}
void beginBuyJNI(const std::string& funid, const std::string& productid, const std::string& orderid)
{
JniHelper::callStaticVoidMethod(JCSDK, "buyProduct", funid, productid, orderid);
}
void queryProductsJNI(const std::string& funid, const std::string& content)
{
JniHelper::callStaticVoidMethod(JCSDK, "queryProducts", funid, content);
}
void queryPurchaseJNI(const std::string& funid)
{
JniHelper::callStaticVoidMethod(JCSDK, "queryPurchase", funid);
}
void setPreferredFramesPerSecondJNI(int fps)
{
JniHelper::callStaticVoidMethod(JCLS_RENDERER, "setPreferredFramesPerSecond", fps);

View File

@ -47,6 +47,9 @@ void signWithTwitterJNI(const std::string& funid);
void signWithEmailJNI(const std::string& funid);
void callJcVoidMethodJNI(const std::string& funid, const std::string& method_name);
void toWalletJNI(const std::string& url);
void beginBuyJNI(const std::string& funid, const std::string& productid, const std::string& orderid);
void queryProductsJNI(const std::string& funid, const std::string& content);
void queryPurchaseJNI(const std::string& funid);
extern int getObbAssetFileDescriptorJNI(const std::string& path, long* startOffset, long* size);
extern void convertEncodingJNI(const std::string& src, int byteSize, const std::string& fromCharset, std::string& dst, const std::string& newCharset);

View File

@ -997,7 +997,7 @@ static bool JSB_showQRCode(se::State& s)
}
SE_BIND_FUNC(JSB_showQRCode)
bool jsb_showWebPage(se::State& s) {
bool JSB_showWebPage(se::State& s) {
const auto& args = s.args();
size_t argc = args.size();
if (argc >= 2) {
@ -1013,7 +1013,68 @@ bool jsb_showWebPage(se::State& s) {
}
return false;
}
SE_BIND_FUNC(jsb_showWebPage)
SE_BIND_FUNC(JSB_showWebPage)
static bool JSB_queryProductsJNI(se::State& s)
{
const auto& args = s.args();
size_t argc = args.size();
CC_UNUSED bool ok = true;
if (argc > 1) {
std::string funid;
ok = seval_to_std_string(args[0], &funid);
SE_PRECONDITION2(ok, false, "funid is invalid!");
std::string param0;
ok = seval_to_std_string(args[1], &param0);
SE_PRECONDITION2(ok, false, "param0 is invalid!");
queryProductsJNI(funid, param0);
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2);
return false;
}
SE_BIND_FUNC(JSB_queryProductsJNI)
static bool JSB_queryPurchaseJNI(se::State& s)
{
const auto& args = s.args();
size_t argc = args.size();
CC_UNUSED bool ok = true;
if (argc > 0) {
std::string funid;
ok = seval_to_std_string(args[0], &funid);
SE_PRECONDITION2(ok, false, "funid is invalid!");
queryPurchaseJNI(funid);
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
return false;
}
SE_BIND_FUNC(JSB_queryPurchaseJNI)
static bool JSB_beginBuyJNI(se::State& s)
{
const auto& args = s.args();
size_t argc = args.size();
CC_UNUSED bool ok = true;
if (argc > 2) {
std::string funid;
ok = seval_to_std_string(args[0], &funid);
SE_PRECONDITION2(ok, false, "funid is invalid!");
std::string param0;
ok = seval_to_std_string(args[1], &param0);
SE_PRECONDITION2(ok, false, "param0 is invalid!");
std::string param1;
ok = seval_to_std_string(args[2], &param1);
SE_PRECONDITION2(ok, false, "param0 is invalid!");
beginBuyJNI(funid, param0, param1);
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3);
return false;
}
SE_BIND_FUNC(JSB_beginBuyJNI)
#endif
static bool JSB_toWallet(se::State& s)
@ -1350,8 +1411,10 @@ bool jsb_register_global_variables(se::Object* global)
__jsbObj->defineFunction("callJcVoidMethodJNI", _SE(JSB_callJcVoidMethodJNI));
__jsbObj->defineFunction("signOutGoogle", _SE(JSB_signOutGoogle));
__jsbObj->defineFunction("showQRCode", _SE(JSB_showQRCode));
__jsbObj->defineFunction("showWebPage", _SE(jsb_showWebPage));
__jsbObj->defineFunction("showWebPage", _SE(JSB_showWebPage));
__jsbObj->defineFunction("queryProducts", _SE(JSB_queryProductsJNI));
__jsbObj->defineFunction("queryPurchase", _SE(JSB_queryPurchaseJNI));
__jsbObj->defineFunction("beginBuy", _SE(JSB_beginBuyJNI));
#endif
__jsbObj->defineFunction("toWallet", _SE(JSB_toWallet));