mirror of
https://github.com/defold/extension-iap
synced 2025-09-28 09:32:19 +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
|
- name: buy
|
||||||
type: function
|
type: function
|
||||||
desc: Sets the listener function for In-app purchase events.
|
desc: Purchase a product.
|
||||||
parameters:
|
parameters:
|
||||||
- name: id
|
- name: id
|
||||||
type: string
|
type: string
|
||||||
|
@@ -35,6 +35,7 @@ struct IAP
|
|||||||
int m_ProviderId;
|
int m_ProviderId;
|
||||||
|
|
||||||
dmScript::LuaCallbackInfo* m_Listener;
|
dmScript::LuaCallbackInfo* m_Listener;
|
||||||
|
dmScript::LuaCallbackInfo* m_RestoreListener;
|
||||||
|
|
||||||
jobject m_IAP;
|
jobject m_IAP;
|
||||||
jobject m_IAPJNI;
|
jobject m_IAPJNI;
|
||||||
@@ -191,14 +192,23 @@ static int IAP_Restore(lua_State* L)
|
|||||||
{
|
{
|
||||||
// TODO: Missing callback here for completion/error
|
// TODO: Missing callback here for completion/error
|
||||||
// See iap_ios.mm
|
// 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();
|
JNIEnv* env = Attach();
|
||||||
env->CallVoidMethod(g_IAP.m_IAP, g_IAP.m_Restore, g_IAP.m_IAPJNI);
|
env->CallVoidMethod(g_IAP.m_IAP, g_IAP.m_Restore, g_IAP.m_IAPJNI);
|
||||||
Detach();
|
Detach();
|
||||||
|
|
||||||
assert(top == lua_gettop(L));
|
|
||||||
|
|
||||||
lua_pushboolean(L, 1);
|
lua_pushboolean(L, 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -501,6 +511,11 @@ static dmExtension::Result FinalizeIAP(dmExtension::Params* params)
|
|||||||
g_IAP.m_Listener = 0;
|
g_IAP.m_Listener = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (iap->m_RestoreListener)
|
||||||
|
{
|
||||||
|
dmScript::DestroyCallback(iap->m_RestoreListener);
|
||||||
|
}
|
||||||
|
|
||||||
if (g_IAP.m_InitCount == 0) {
|
if (g_IAP.m_InitCount == 0) {
|
||||||
JNIEnv* env = Attach();
|
JNIEnv* env = Attach();
|
||||||
env->CallVoidMethod(g_IAP.m_IAP, g_IAP.m_Stop);
|
env->CallVoidMethod(g_IAP.m_IAP, g_IAP.m_Stop);
|
||||||
|
@@ -28,6 +28,7 @@ struct IAP
|
|||||||
bool m_AutoFinishTransactions;
|
bool m_AutoFinishTransactions;
|
||||||
NSMutableDictionary* m_PendingTransactions;
|
NSMutableDictionary* m_PendingTransactions;
|
||||||
dmScript::LuaCallbackInfo* m_Listener;
|
dmScript::LuaCallbackInfo* m_Listener;
|
||||||
|
dmScript::LuaCallbackInfo* m_RestoreListener;
|
||||||
IAPCommandQueue m_CommandQueue;
|
IAPCommandQueue m_CommandQueue;
|
||||||
IAPCommandQueue m_ObservableQueue;
|
IAPCommandQueue m_ObservableQueue;
|
||||||
SKPaymentTransactionObserver* m_Observer;
|
SKPaymentTransactionObserver* m_Observer;
|
||||||
@@ -599,6 +600,11 @@ static dmExtension::Result FinalizeIAP(dmExtension::Params* params)
|
|||||||
g_IAP.m_Listener = 0;
|
g_IAP.m_Listener = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (iap->m_RestoreListener)
|
||||||
|
{
|
||||||
|
dmScript::DestroyCallback(iap->m_RestoreListener);
|
||||||
|
}
|
||||||
|
|
||||||
if (g_IAP.m_InitCount == 0) {
|
if (g_IAP.m_InitCount == 0) {
|
||||||
if (g_IAP.m_PendingTransactions) {
|
if (g_IAP.m_PendingTransactions) {
|
||||||
[g_IAP.m_PendingTransactions release];
|
[g_IAP.m_PendingTransactions release];
|
||||||
|
@@ -339,7 +339,7 @@ public class IapGooglePlay implements PurchasesUpdatedListener {
|
|||||||
querySkuDetailsAsync(skuList, new SkuDetailsResponseListener() {
|
querySkuDetailsAsync(skuList, new SkuDetailsResponseListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSkuDetailsResponse(BillingResult billingResult, List<SkuDetails> skuDetailsList) {
|
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);
|
buyProduct(skuDetailsList.get(0), purchaseListener);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Reference in New Issue
Block a user