diff --git a/src/Plugin.InAppBilling.iOS/InAppBillingImplementation.cs b/src/Plugin.InAppBilling.iOS/InAppBillingImplementation.cs
index b19fdb3..9cb3c76 100644
--- a/src/Plugin.InAppBilling.iOS/InAppBillingImplementation.cs
+++ b/src/Plugin.InAppBilling.iOS/InAppBillingImplementation.cs
@@ -15,12 +15,17 @@ namespace Plugin.InAppBilling
[Preserve(AllMembers = true)]
public class InAppBillingImplementation : BaseInAppBilling
{
+ ///
+ /// Gets or sets a callback for out of band purchases to complete.
+ ///
+ public static Action OnPurchaseComplete { get; set; } = null;
+
///
/// Default constructor for In App Billing on iOS
///
public InAppBillingImplementation()
{
- paymentObserver = new PaymentObserver();
+ paymentObserver = new PaymentObserver(OnPurchaseComplete);
SKPaymentQueue.DefaultQueue.AddTransactionObserver(paymentObserver);
}
@@ -378,6 +383,12 @@ class PaymentObserver : SKPaymentTransactionObserver
public event Action TransactionsRestored;
List restoredTransactions = new List();
+ private readonly Action onPurchaseSuccess;
+
+ public PaymentObserver(Action onPurchaseSuccess = null)
+ {
+ this.onPurchaseSuccess = onPurchaseSuccess;
+ }
public override void UpdatedTransactions(SKPaymentQueue queue, SKPaymentTransaction[] transactions)
{
@@ -401,6 +412,10 @@ public override void UpdatedTransactions(SKPaymentQueue queue, SKPaymentTransact
case SKPaymentTransactionState.Restored:
case SKPaymentTransactionState.Purchased:
TransactionCompleted?.Invoke(transaction, true);
+
+ if (TransactionCompleted != null)
+ onPurchaseSuccess?.Invoke(transaction.ToIABPurchase());
+
SKPaymentQueue.DefaultQueue.FinishTransaction(transaction);
break;
case SKPaymentTransactionState.Failed: