/// <summary> /// Buffer the event of a purchase using real currency, where a single item /// (that isn't an in-app currency) was purchased. /// The receipt provided will be validated against the Windows Store. /// </summary> /// <remarks> /// See the REST API documentation for the "iap" event. /// Note that this method is currently only supported for the Windows Store, /// and a valid receipt needs to be provided for verification. /// </remarks> /// <param name="receipt"> /// The receipt sent back from the Windows Store upon successful purchase - this receipt will be verified by Swrve /// </param> /// <param name="rewards"> /// SwrveIAPRewards object containing any in-app currency and/or additional items /// included in this purchase that need to be recorded. /// This parameter is optional. /// </param> public void IapWindows(IapReceipt receipt, IapRewards rewards) { if (config.AppStore != SwrveAppStore.Windows) { throw new Exception("This function can only be called to validate IAP events from Windows Store"); } else { string encodedReceipt = (receipt != null) ? receipt.GetBase64EncodedReceipt() : null; if (receipt != null && string.IsNullOrEmpty(encodedReceipt)) { SwrveLog.LogError("IAP event not sent: receipt cannot be empty for Windows Store verification"); return; } // Windows Store IAP is always of quantity 1 Dictionary <string, object> json = new Dictionary <string, object>(); json.Add("app_store", config.AppStore); if (!string.IsNullOrEmpty(GetAppVersion())) { json.Add("app_version", GetAppVersion()); } json.Add("receipt", encodedReceipt); AppendEventToBuffer("iap", json); if (config.AutoDownloadCampaignsAndResources) { // Send events automatically and check for changes CheckForCampaignsAndResourcesUpdates(false); } } }
/// <summary> /// Buffer the event of a purchase using real currency, where any in-app /// currencies were purchased, or where multiple items were purchased as part of a bundle. /// The receipt provided will be validated against the iTunes Store. /// </summary> /// <remarks> /// See the REST API documentation for the "iap" event. /// Note that this method is currently only supported for the Apple App Store, /// and a valid receipt needs to be provided for verification. /// </remarks> /// <param name="quantity"> /// Quantity purchased. /// </param> /// <param name="productId"> /// Unique product identifier for the item bought. This should match the Swrve resource name. /// </param> /// <param name="productPrice"> /// Price of the product purchased in real money. Note that this is the price /// per product, not the total price of the transaction (when quantity > 1). /// </param> /// <param name="currency"> /// Real world currency used for this transaction. This must be an ISO currency code. /// </param> /// <param name="rewards"> /// SwrveIAPRewards object containing any in-app currency and/or additional items /// included in this purchase that need to be recorded. /// This parameter is optional. /// </param> /// <param name="receipt"> /// The receipt sent back from the iTunes Store upon successful purchase - this receipt will be verified by Swrve. /// Use either Base64EncodedReceipt or RawReceipt depending on what is offered by your plugin. /// </param> /// <param name="transactionId"> /// The transaction id identifying the purchase iOS7+ (see SKPaymentTransaction::transactionIdentifier). /// </param> public void IapApple(int quantity, string productId, double productPrice, string currency, IapRewards rewards, IapReceipt receipt, string transactionId) { if (config.AppStore != "apple") { throw new Exception("This function can only be called to validate IAP events from Apple"); } else { string encodedReceipt = null; if (receipt != null) { encodedReceipt = receipt.GetBase64EncodedReceipt(); } if (String.IsNullOrEmpty(encodedReceipt)) { SwrveLog.LogError("IAP event not sent: receipt cannot be empty for Apple Store verification"); return; } _Iap(quantity, productId, productPrice, currency, rewards, encodedReceipt, string.Empty, transactionId, config.AppStore); } }