Esempio n. 1
0
        private static async void Start(int value)
        {
            Console.WriteLine();
            Console.WriteLine("Processing ...");

            ClientResponse response = new ClientResponse();

            switch (value)
            {
            case 1:
                response = await GatewayClient.CallEchoGet();

                break;

            case 2:
                response = await GatewayClient.CallEchoPost();

                break;

            case 3:
                response = await GatewayClient.CallInit();

                var responseObject = JsonConvert.DeserializeObject <PayRes>(response.ResponseValue);
                paymentId = responseObject.PayId;
                break;

            case 4:
                if (!CheckPaymentId())
                {
                    return;
                }
                response = await GatewayClient.CallProcess(paymentId);

                break;

            case 5:
                if (!CheckPaymentId())
                {
                    return;
                }
                response = await GatewayClient.CallStatus(paymentId);

                break;

            case 6:
                if (!CheckPaymentId())
                {
                    return;
                }
                response = await GatewayClient.CallClose(paymentId);

                break;

            case 7:
                if (!CheckPaymentId())
                {
                    return;
                }
                response = await GatewayClient.CallReverse(paymentId);

                break;

            case 8:
                if (!CheckPaymentId())
                {
                    return;
                }
                response = await GatewayClient.CallRefund(paymentId, 150000);

                break;

            case 9:
                if (!CheckPaymentId())
                {
                    return;
                }
                response = await GatewayClient.CallOneClickInit(paymentId);

                break;

            case 10:
                if (!CheckPaymentId())
                {
                    return;
                }
                response = await GatewayClient.CallOneClickStart(paymentId);

                break;

            case 11:
                response = await GatewayClient.CallCustomerInfo("xxx");

                break;
            }

            Console.WriteLine();

            Console.Write("ResponseCode: ");
            Console.ForegroundColor = (response.ResponseCode.StartsWith("200") || response.ResponseCode.StartsWith("303")) ? ConsoleColor.Green : ConsoleColor.Red;
            Console.WriteLine(response.ResponseCode);
            Console.ResetColor();

            Console.WriteLine("ResponseValue: " + response.ResponseValue);

            Console.WriteLine();
            Console.WriteLine("Press Enter to continue.");
        }