public async void Run_CancelPaymentLinkTest()
        {
            ShowTestOnTerminal("CancelPaymentLink");

            PaymentLinkRequest setupRequest = new PaymentLinkRequest
            {
                Amount      = "199.99",
                Description = "Widget",
                Subject     = "Widget invoice",
                Transaction = new TransactionDisplayTransaction
                {
                    Subtotal = "195.00",
                    Tax      = "4.99",
                    Total    = "199.99",
                    Items    = new List <TransactionDisplayItem>
                    {
                        new TransactionDisplayItem
                        {
                            Description = "Widget",
                            Price       = "195.00",
                            Quantity    = 1,
                        }
                    },
                },
                AutoSend = true,
                Customer = new Customer
                {
                    CustomerRef  = "Customer reference string",
                    FirstName    = "FirstName",
                    LastName     = "LastName",
                    CompanyName  = "Company Name",
                    EmailAddress = "*****@*****.**",
                    SmsNumber    = "(123) 123-1231",
                },
            };

            output.WriteLine("Setup request: {0}", setupRequest);

            PaymentLinkResponse setupResponse = await blockchyp.SendPaymentLinkAsync(setupRequest);

            output.WriteLine("Setup Response: {0}", setupResponse);

            CancelPaymentLinkRequest request = new CancelPaymentLinkRequest
            {
                LinkCode = setupResponse.LinkCode,
            };

            output.WriteLine("Request: {0}", request);

            CancelPaymentLinkResponse response = await blockchyp.CancelPaymentLinkAsync(request);

            output.WriteLine("Response: {0}", response);

            Assert.True(response.Success, "response.Success");
        }
Пример #2
0
        public static string GetControlChecksum(PaymentLinkResponse response, PaymentConfiguration paymentConfiguration)
        {
            using (SHA256 hasher = SHA256.Create())
            {
                string neededParams = paymentConfiguration.PIN + response.Token;

                byte[] hashedBytes = hasher.ComputeHash(Encoding.ASCII.GetBytes(neededParams));

                StringBuilder sb = new StringBuilder();
                foreach (byte @byte in hashedBytes)
                {
                    sb.Append(@byte.ToString("x2"));
                }

                return(sb.ToString());
            }
        }