示例#1
0
        public void CreateTokenTest(string name, string surname, string email)
        {
            var service = new DirectPayService(_baseUrl, _companyToken);
            var data    = new CreateTokenModel
            {
                Customer = new CustomerModel
                {
                    CustomerFirstName = name,
                    CustomerLastName  = surname,
                    CustomerPhone     = "",
                    CustomerEmail     = email
                },
                Transaction = new TransactionModel
                {
                    CompanyRef            = Guid.NewGuid().ToString("N"),
                    PaymentAmount         = decimal.Parse($"{rnd.Next(11, 199)}.{rnd.Next(0, 99)}"),//TODO: Set Transaction Payment Amount here
                    Currency              = Currencies.USD,
                    TransactionChargeType = "1"
                },
                Services = new List <ServiceModel>
                {
                    new ServiceModel
                    {
                        ServiceDescription = "Service Here", //TODO: Get your service from DPO
                        ServiceType        = 0,              //TODO: Get your service type from DPO
                        ServiceDate        = DateTime.Now
                    }
                }
            };
            var response = service.CreateToken(data);

            _debug.WriteLine("Result: {0}", response.Result);
            _debug.WriteLine("Result Explanation: {0}", response.ResultExplanation);
            _debug.WriteLine("Transaction Token: {0} - Amount: {1}", response.TransToken, data.Transaction.PaymentAmount);
            Assert.Equal(true, response.Result == "000");
        }