Example #1
0
        private void DoPurchase()
        {
            var tipAmount = 0;

            if (_retryCmd.Length > 2)
            {
                int.TryParse(_retryCmd[2], out tipAmount);
            }
            var cashoutAmount = 0;

            if (_retryCmd.Length > 3)
            {
                int.TryParse(_retryCmd[3], out cashoutAmount);
            }
            var promptForCashout = false;

            if (_retryCmd.Length > 4)
            {
                bool.TryParse(_retryCmd[4], out promptForCashout);
            }
            // posRefId is what you would usually use to identify the order in your own system.
            var posRefId = "kebab-" + DateTime.Now.ToString("dd-MM-yyyy-HH-mm-ss");

            var pres = _spi.InitiatePurchaseTxV2(posRefId, int.Parse(_retryCmd[1]), tipAmount, cashoutAmount, promptForCashout);

            if (!pres.Initiated)
            {
                Console.WriteLine($"# Could not initiate purchase: {pres.Message}. Please Retry.");
            }
        }