Пример #1
0
        private static async void Start(GatewayClient gatewayClient, int value)
        {
            Console.WriteLine();
            Console.WriteLine("Processing ...");

            ClientResponse response = new ClientResponse();

            switch (value)
            {
            case 1:
                response = await gatewayClient.CallEchoGetAsync();

                break;

            case 2:
                response = await gatewayClient.CallEchoPostAsync();

                break;

            case 3:
                response = await gatewayClient.CallInitAsync();

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

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

                break;

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

                break;

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

                break;

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

                break;

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

                break;

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

                break;

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

                break;

            case 11:
                response = await gatewayClient.CallCustomerInfoAsync("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.");
        }