feat: enable explicit IAP restoration (#21461)
This commit is contained in:
parent
53957d47d6
commit
dba8a0caa8
7 changed files with 43 additions and 23 deletions
|
@ -85,6 +85,8 @@ void InAppPurchase::BuildPrototype(v8::Isolate* isolate,
|
|||
prototype->SetClassName(gin::StringToV8(isolate, "InAppPurchase"));
|
||||
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("canMakePayments", &in_app_purchase::CanMakePayments)
|
||||
.SetMethod("restoreCompletedTransactions",
|
||||
&in_app_purchase::RestoreCompletedTransactions)
|
||||
.SetMethod("getReceiptURL", &in_app_purchase::GetReceiptURL)
|
||||
.SetMethod("purchaseProduct", &InAppPurchase::PurchaseProduct)
|
||||
.SetMethod("finishAllTransactions",
|
||||
|
|
|
@ -17,13 +17,15 @@ typedef base::OnceCallback<void(bool isProductValid)> InAppPurchaseCallback;
|
|||
|
||||
// --------------------------- Functions ---------------------------
|
||||
|
||||
bool CanMakePayments(void);
|
||||
bool CanMakePayments();
|
||||
|
||||
void FinishAllTransactions(void);
|
||||
void RestoreCompletedTransactions();
|
||||
|
||||
void FinishAllTransactions();
|
||||
|
||||
void FinishTransactionByDate(const std::string& date);
|
||||
|
||||
std::string GetReceiptURL(void);
|
||||
std::string GetReceiptURL();
|
||||
|
||||
void PurchaseProduct(const std::string& productID,
|
||||
int quantity,
|
||||
|
|
|
@ -141,6 +141,10 @@ bool CanMakePayments() {
|
|||
return [SKPaymentQueue canMakePayments];
|
||||
}
|
||||
|
||||
void RestoreCompletedTransactions() {
|
||||
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
|
||||
}
|
||||
|
||||
void FinishAllTransactions() {
|
||||
for (SKPaymentTransaction* transaction in SKPaymentQueue.defaultQueue
|
||||
.transactions) {
|
||||
|
|
|
@ -51,7 +51,7 @@ class TransactionObserver {
|
|||
const std::vector<Transaction>& transactions) = 0;
|
||||
|
||||
private:
|
||||
InAppTransactionObserver* obeserver_;
|
||||
InAppTransactionObserver* observer_;
|
||||
|
||||
base::WeakPtrFactory<TransactionObserver> weak_ptr_factory_;
|
||||
|
||||
|
|
|
@ -183,14 +183,14 @@ Transaction::Transaction(const Transaction&) = default;
|
|||
Transaction::~Transaction() = default;
|
||||
|
||||
TransactionObserver::TransactionObserver() : weak_ptr_factory_(this) {
|
||||
obeserver_ = [[InAppTransactionObserver alloc]
|
||||
observer_ = [[InAppTransactionObserver alloc]
|
||||
initWithCallback:base::BindRepeating(
|
||||
&TransactionObserver::OnTransactionsUpdated,
|
||||
weak_ptr_factory_.GetWeakPtr())];
|
||||
}
|
||||
|
||||
TransactionObserver::~TransactionObserver() {
|
||||
[obeserver_ release];
|
||||
[observer_ release];
|
||||
}
|
||||
|
||||
} // namespace in_app_purchase
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue