Ejemplo n.º 1
0
        /// <summary>
        /// Activate and verify the MEGA product license on the MEGA license server
        /// </summary>
        /// <param name="receipt">Windows Store product purchase receipt</param>
        /// <returns>True if activation has been successful, False if not succeeded</returns>
        public static async Task <bool> ActivateMegaLicenseAsync(string receipt)
        {
            if (string.IsNullOrEmpty(receipt))
            {
                return(false);
            }

            // Validate and activate the MEGA Windows Store (int 13) subscription on the MEGA license server
            var submitPurchaseReceipt = new SubmitPurchaseReceiptRequestListenerAsync();
            var result = await submitPurchaseReceipt.ExecuteAsync(() =>
            {
                // If user has accessed a public node in the last 24 hours, also send the node handle (Task #10801)
                var lastPublicNodeHandle = SettingsService.GetLastPublicNodeHandle();
                if (lastPublicNodeHandle.HasValue)
                {
                    SdkService.MegaSdk.submitPurchaseReceiptWithLastPublicHandle(
                        (int)MPaymentMethod.PAYMENT_METHOD_WINDOWS_STORE,
                        receipt, lastPublicNodeHandle.Value, submitPurchaseReceipt);
                    return;
                }

                SdkService.MegaSdk.submitPurchaseReceipt(
                    (int)MPaymentMethod.PAYMENT_METHOD_WINDOWS_STORE,
                    receipt, submitPurchaseReceipt);
            });

            // If succeeded, save the receipt Id for later checks
            if (result)
            {
                SaveUniqueReceiptId(receipt);
            }

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Send the receipt to MEGA License Server to verify and validate the purchase
        /// </summary>
        /// <param name="receipt">In app purchase receipt received from the Windows Store</param>
        private static void SendLicenseToMega(string receipt)
        {
            // Validate and activate the MEGA Windows Store (int 13) subscription on the MEGA license server
            // If user has accessed a public node in the last 24 hours, also send the node handle (Task #10800)
            var lastPublicNodeHandle = SettingsService.GetLastPublicNodeHandle();

            if (lastPublicNodeHandle.HasValue)
            {
                SdkService.MegaSdk.submitPurchaseReceiptWithLastPublicHandle(
                    (int)MPaymentMethod.PAYMENT_METHOD_WINDOWS_STORE,
                    receipt, lastPublicNodeHandle.Value, new PurchaseReceiptRequestListener(receipt));
                return;
            }

            SdkService.MegaSdk.submitPurchaseReceipt((int)MPaymentMethod.PAYMENT_METHOD_WINDOWS_STORE,
                                                     receipt, new PurchaseReceiptRequestListener(receipt));
        }