public Uri CreatePaymentForm(PaymentInfo paymentInfo, CustomFields customFields = null)
        {
            var additional = customFields ?? new CustomFields();

            additional.ApiClient        = _fingerprint.GetClientName();
            additional.ApiClientVersion = _fingerprint.GetClientVersion();
            var uriBuilder = new UriBuilder("https://oplata.qiwi.com/create");

            try
            {
                var parameters = HttpUtility.ParseQueryString(uriBuilder.Query);
                parameters["amount"] = paymentInfo.Amount.ValueString;
                foreach (var keyValuePair in additional.ToDictionary())
                {
                    if (null != keyValuePair.Value)
                    {
                        parameters["customFields[" + keyValuePair.Key + "]"] = keyValuePair.Value.ToString();
                    }
                }
                parameters["publicKey"] = paymentInfo.PublicKey;
                parameters["billId"]    = paymentInfo.BillId;
                if (null != paymentInfo.SuccessUrl)
                {
                    parameters["successUrl"] = paymentInfo.SuccessUrl.ToString();
                }

                uriBuilder.Query = parameters.ToString();
                return(uriBuilder.Uri);
            }
            catch (System.Exception e)
            {
                throw new UrlEncodingException(e);
            }
        }
Exemplo n.º 2
0
        private static void TestCreateBill_Assert(CreateBillInfo createBillInfo, IFingerprint fingerprint,
                                                  BillResponse billResponse)
        {
            var query = HttpUtility.ParseQueryString(billResponse.PayUrl.Query);

            Assert.AreEqual(createBillInfo.BillId, billResponse.BillId, "Same bill id");
            Assert.AreEqual(createBillInfo.Amount.ValueDecimal, billResponse.Amount.ValueDecimal, "Same amount value");
            Assert.AreEqual(createBillInfo.Amount.CurrencyEnum, billResponse.Amount.CurrencyEnum,
                            "Same amount currency");
            Assert.AreEqual(createBillInfo.Comment, billResponse.Comment, "Same comment");
            Assert.AreEqual(createBillInfo.ExpirationDateTime, billResponse.ExpirationDateTime,
                            "Same expiration dateTime");
            Assert.AreEqual(createBillInfo.Customer.Email, billResponse.Customer.Email, "Same email");
            Assert.AreEqual(createBillInfo.Customer.Account, billResponse.Customer.Account, "Same account");
            Assert.AreEqual(createBillInfo.Customer.Phone, billResponse.Customer.Phone, "Same phone");
            Assert.AreEqual(createBillInfo.SuccessUrl, query["successUrl"], "Same success url");
            Assert.AreEqual(BillStatusEnum.Waiting, billResponse.Status.ValueEnum, "Status value preset");
            Assert.AreEqual(fingerprint.GetClientName(), billResponse.CustomFields.ApiClient, "Api client preset");
            Assert.AreEqual(fingerprint.GetClientVersion(), billResponse.CustomFields.ApiClientVersion,
                            "Api client preset");
        }