parent
55a66efa38
commit
fe20a1e35b
2 changed files with 15 additions and 0 deletions
|
@ -46,6 +46,7 @@ class InAppStore : public Object {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Error request_product_info(Variant p_params);
|
Error request_product_info(Variant p_params);
|
||||||
|
Error restore_purchases();
|
||||||
Error purchase(Variant p_params);
|
Error purchase(Variant p_params);
|
||||||
|
|
||||||
int get_pending_event_count();
|
int get_pending_event_count();
|
||||||
|
|
|
@ -63,6 +63,7 @@ InAppStore *InAppStore::instance = NULL;
|
||||||
|
|
||||||
void InAppStore::_bind_methods() {
|
void InAppStore::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("request_product_info"), &InAppStore::request_product_info);
|
ClassDB::bind_method(D_METHOD("request_product_info"), &InAppStore::request_product_info);
|
||||||
|
ClassDB::bind_method(D_METHOD("restore_purchases"), &InAppStore::restore_purchases);
|
||||||
ClassDB::bind_method(D_METHOD("purchase"), &InAppStore::purchase);
|
ClassDB::bind_method(D_METHOD("purchase"), &InAppStore::purchase);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_pending_event_count"), &InAppStore::get_pending_event_count);
|
ClassDB::bind_method(D_METHOD("get_pending_event_count"), &InAppStore::get_pending_event_count);
|
||||||
|
@ -153,6 +154,14 @@ Error InAppStore::request_product_info(Variant p_params) {
|
||||||
return OK;
|
return OK;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Error InAppStore::restore_purchases() {
|
||||||
|
|
||||||
|
printf("restoring purchases!\n");
|
||||||
|
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
};
|
||||||
|
|
||||||
@interface TransObserver : NSObject <SKPaymentTransactionObserver> {
|
@interface TransObserver : NSObject <SKPaymentTransactionObserver> {
|
||||||
};
|
};
|
||||||
@end
|
@end
|
||||||
|
@ -236,6 +245,11 @@ Error InAppStore::request_product_info(Variant p_params) {
|
||||||
printf("status transaction restored!\n");
|
printf("status transaction restored!\n");
|
||||||
String pid = String::utf8([transaction.originalTransaction.payment.productIdentifier UTF8String]);
|
String pid = String::utf8([transaction.originalTransaction.payment.productIdentifier UTF8String]);
|
||||||
InAppStore::get_singleton()->_record_purchase(pid);
|
InAppStore::get_singleton()->_record_purchase(pid);
|
||||||
|
Dictionary ret;
|
||||||
|
ret["type"] = "restore";
|
||||||
|
ret["result"] = "ok";
|
||||||
|
ret["product_id"] = pid;
|
||||||
|
InAppStore::get_singleton()->_post_event(ret);
|
||||||
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
|
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
|
||||||
} break;
|
} break;
|
||||||
default: {
|
default: {
|
||||||
|
|
Loading…
Reference in a new issue