public void SerializedFieldOrder()
        {
            ReceiptInRequest r = new ReceiptInRequest("UnitTest", "123456", "testcard", 1.23m);

            r.TimestampFormatted = "20160102030405";
            r.Comments           = RealexComment.CreateCommentList(new string[] { "Test Commend on Transaction" });
            r.OrderId            = "15d0df68-8e2d-46c9-b23e-eff539b1bfad";
            r.SetSha1Hash("TestKey");

            XmlSerializer s  = new XmlSerializer(r.GetType());
            StringWriter  sr = new StringWriter();

            s.Serialize(sr, r);

            string[] resultLines = sr.ToString().Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
                                   .Select(row => row.Trim())
                                   .ToArray();

            Assert.AreEqual(13, resultLines.Length);

            Assert.AreEqual("<?xml version=\"1.0\" encoding=\"utf-16\"?>", resultLines[0]);
//            Assert.AreEqual("<request xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" type=\"receipt-in\" timestamp=\"20160102030405\">", resultLines[1]);
            Assert.AreEqual("<merchantid>UnitTest</merchantid>", resultLines[2]);
            Assert.AreEqual("<orderid>15d0df68-8e2d-46c9-b23e-eff539b1bfad</orderid>", resultLines[3]);
            Assert.AreEqual("<autosettleflag flag=\"1\" />", resultLines[4]);
            Assert.AreEqual("<amount currency=\"GBP\">123</amount>", resultLines[5]);
            Assert.AreEqual("<payerref>123456</payerref>", resultLines[6]);
            Assert.AreEqual("<paymentmethod>testcard</paymentmethod>", resultLines[7]);
            Assert.AreEqual("<sha1hash>861acecbd73e038ef45c1c39cfa86f3165e34102</sha1hash>", resultLines[8]);
            Assert.AreEqual("<comments>", resultLines[9]);
            Assert.AreEqual("<comment id=\"1\">Test Commend on Transaction</comment>", resultLines[10]);
            Assert.AreEqual("</comments>", resultLines[11]);
            Assert.AreEqual("</request>", resultLines[12]);
        }
예제 #2
0
        public async Task <string> UpdateCardholderDetails(
            PaymentProviderConfiguration configuration,
            CardholderDetails cardholder)
        {
            var realExXfer = new PayerEditRequest(configuration.AccountIdentifer, cardholder.PayerRef)
            {
                OrderId = Guid.NewGuid().ToString(),
            };

            realExXfer.Payer.Title     = cardholder.Title;
            realExXfer.Payer.FirstName = cardholder.FirstName;
            realExXfer.Payer.Surname   = cardholder.Surname;
            realExXfer.Payer.PayerType = "Customer";
            realExXfer.Payer.Address   = new RealexAddress()
            {
                Line1    = cardholder.Address1,
                Line2    = cardholder.Address2,
                Line3    = cardholder.Address3,
                City     = cardholder.City,
                County   = cardholder.County,
                Postcode = cardholder.Postcode,
                Country  =
                    new RealexCountry()
                {
                    CountryCode = "GB",
                    Name        = "United Kingdom"
                }
            };
            realExXfer.Payer.PhoneNumbers = new RealexPhoneNumbers()
            {
                Home   = cardholder.HomePhone,
                Work   = cardholder.WorkPhone,
                Mobile = cardholder.MobilePhone
            };
            realExXfer.Payer.EMail    = cardholder.Email;
            realExXfer.Payer.Comments = RealexComment.CreateCommentList(cardholder.Comments, maxNumberOfComments: 2);

            PayerEditResponse result = await PostXmlToRealex <PayerEditResponse, PayerEditRequest>(
                realExXfer,
                configuration.SharedSecret,
                logLevelForSuccess : LogLevel.Audit);

            result.ThrowIfNotSuccess();
            return(result.PasRef);
        }
예제 #3
0
        /// <remarks>
        /// Wraps calls to Realex's ReceiptIn API function
        /// </remarks>
        public async Task <ReceiptInResponse> RealexReceiptIn(
            PaymentProviderConfiguration configuration,
            string realexPayerRef,
            decimal amount,
            string subAccount,
            string cardName,
            RealexTssInfo additionalInfo,
            IEnumerable <string> optionalComments)
        {
            ReceiptInRequest req = new ReceiptInRequest(
                merchantId: configuration.AccountIdentifer,
                payerRef: realexPayerRef,
                paymentMethod: cardName,
                amount: amount);

            req.Account = subAccount;
            if (RealEx.Default.RealVaultRemoteUrl.ToLower().Contains("sandbox"))
            {
                req.Account = req.Account + "test";
            }

            req.Comments = RealexComment.CreateCommentList(optionalComments);

            if (null != additionalInfo)
            {
                additionalInfo.TruncateAndStripDisallowed();
                req.TssInfo = additionalInfo;
            }

            ReceiptInResponse response = await PostXmlToRealex <ReceiptInResponse, ReceiptInRequest>(
                req,
                configuration.SharedSecret,
                logLevelForSuccess : LogLevel.Audit);

            return(response);
        }