mirror of
https://github.com/defold/extension-iap
synced 2025-09-27 17:12:18 +02:00
Compare commits
4 Commits
3.0.0
...
issue-33-r
Author | SHA1 | Date | |
---|---|---|---|
|
53ae8a308e | ||
|
257f95f1d3 | ||
|
1a16fcc795 | ||
|
412a609738 |
@@ -9,7 +9,7 @@
|
||||
|
||||
- name: buy
|
||||
type: function
|
||||
desc: Sets the listener function for In-app purchase events.
|
||||
desc: Purchase a product.
|
||||
parameters:
|
||||
- name: id
|
||||
type: string
|
||||
|
@@ -35,6 +35,7 @@ struct IAP
|
||||
int m_ProviderId;
|
||||
|
||||
dmScript::LuaCallbackInfo* m_Listener;
|
||||
dmScript::LuaCallbackInfo* m_RestoreListener;
|
||||
|
||||
jobject m_IAP;
|
||||
jobject m_IAPJNI;
|
||||
@@ -191,14 +192,23 @@ static int IAP_Restore(lua_State* L)
|
||||
{
|
||||
// TODO: Missing callback here for completion/error
|
||||
// See iap_ios.mm
|
||||
DM_LUA_STACKCHECK(L, 1);
|
||||
|
||||
if (iap->m_RestoreListener)
|
||||
{
|
||||
dmScript::DestroyCallback(iap->m_RestoreListener);
|
||||
iap->m_RestoreListener = 0;
|
||||
}
|
||||
|
||||
if (lua_isfunction(L, 1))
|
||||
{
|
||||
iap->m_RestoreListener = dmScript::CreateCallback(L, 1);
|
||||
}
|
||||
|
||||
int top = lua_gettop(L);
|
||||
JNIEnv* env = Attach();
|
||||
env->CallVoidMethod(g_IAP.m_IAP, g_IAP.m_Restore, g_IAP.m_IAPJNI);
|
||||
Detach();
|
||||
|
||||
assert(top == lua_gettop(L));
|
||||
|
||||
lua_pushboolean(L, 1);
|
||||
return 1;
|
||||
}
|
||||
@@ -501,6 +511,11 @@ static dmExtension::Result FinalizeIAP(dmExtension::Params* params)
|
||||
g_IAP.m_Listener = 0;
|
||||
}
|
||||
|
||||
if (iap->m_RestoreListener)
|
||||
{
|
||||
dmScript::DestroyCallback(iap->m_RestoreListener);
|
||||
}
|
||||
|
||||
if (g_IAP.m_InitCount == 0) {
|
||||
JNIEnv* env = Attach();
|
||||
env->CallVoidMethod(g_IAP.m_IAP, g_IAP.m_Stop);
|
||||
|
@@ -28,6 +28,7 @@ struct IAP
|
||||
bool m_AutoFinishTransactions;
|
||||
NSMutableDictionary* m_PendingTransactions;
|
||||
dmScript::LuaCallbackInfo* m_Listener;
|
||||
dmScript::LuaCallbackInfo* m_RestoreListener;
|
||||
IAPCommandQueue m_CommandQueue;
|
||||
IAPCommandQueue m_ObservableQueue;
|
||||
SKPaymentTransactionObserver* m_Observer;
|
||||
@@ -599,6 +600,11 @@ static dmExtension::Result FinalizeIAP(dmExtension::Params* params)
|
||||
g_IAP.m_Listener = 0;
|
||||
}
|
||||
|
||||
if (iap->m_RestoreListener)
|
||||
{
|
||||
dmScript::DestroyCallback(iap->m_RestoreListener);
|
||||
}
|
||||
|
||||
if (g_IAP.m_InitCount == 0) {
|
||||
if (g_IAP.m_PendingTransactions) {
|
||||
[g_IAP.m_PendingTransactions release];
|
||||
|
@@ -339,7 +339,7 @@ public class IapGooglePlay implements PurchasesUpdatedListener {
|
||||
querySkuDetailsAsync(skuList, new SkuDetailsResponseListener() {
|
||||
@Override
|
||||
public void onSkuDetailsResponse(BillingResult billingResult, List<SkuDetails> skuDetailsList) {
|
||||
if (billingResult.getResponseCode() == BillingResponseCode.OK) {
|
||||
if (billingResult.getResponseCode() == BillingResponseCode.OK && (skuDetailsList != null) && !skuDetailsList.isEmpty()) {
|
||||
buyProduct(skuDetailsList.get(0), purchaseListener);
|
||||
}
|
||||
else {
|
||||
|
Reference in New Issue
Block a user