コード例 #1
0
        public async Task <TransactionRegistrationResponse> InitializeTransaction(string _returnurl, string _merchantreference, string _merchantid, string _description, string _totalamount, string _currencycode, string _customerEmail, string _customerNumber, string _customerFirstName, string _customerLastName, bool isLive)
        {
            var client = HttpConnection.Call(_token, isLive);

            if (isLive)
            {
                baseURL = Constants.BaseEndURlLive;
            }

            List <Product> _products = new List <Product>();

            var _product = new Product
            {
                Name      = _description,
                Quantity  = "1",
                Unitprice = _totalamount
            };

            _products.Add(_product);

            var _customer = new Customer
            {
                Email     = _customerEmail,
                Firstname = _customerFirstName,
                Lastname  = _customerLastName,
                Mobile    = _customerNumber,
            };

            var transactionRegistrationRequest = new TransactionRegistrationRequest
            {
                Returnurl         = _returnurl,
                Customerip        = "",
                Merchantreference = _merchantreference,
                Merchantid        = _merchantid,
                Description       = _description,
                Currencycode      = _currencycode,
                Totalamount       = _totalamount,
                Paymentmethod     = "card",
                TransactionType   = "Payment",
                Connectionmode    = "redirect",
                Customer          = _customer,
                Product           = _products
            };


            var requestJson   = JsonConvert.SerializeObject(transactionRegistrationRequest);
            var stringContent = new StringContent(requestJson, Encoding.UTF8, "application/json");
            var response      = await client.PostAsync(baseURL + "/SetRequest", stringContent);

            var responseJson = await response.Content.ReadAsStringAsync();

            return(JsonConvert.DeserializeObject <TransactionRegistrationResponse>(responseJson));
        }
コード例 #2
0
        public async Task <RetrieveTransactionResponse> RetrieveTransaction(string _merchantId, string _merchantReference, string _transactionReference, bool isLive)
        {
            var client = HttpConnection.Call(_token, isLive);

            if (isLive)
            {
                baseURL = Constants.BaseEndURlLive;
            }

            var _retrieveTransactionRequest = new RetrieveTransactionRequest
            {
                Merchantid           = _merchantId,
                Merchantreference    = _merchantReference,
                Transactionreference = _transactionReference,
            };

            var requestJson   = JsonConvert.SerializeObject(_retrieveTransactionRequest);
            var stringContent = new StringContent(requestJson, Encoding.UTF8, "application/json");
            var response      = await client.PostAsync(baseURL + "/Retrieve", stringContent);

            var responseJson = await response.Content.ReadAsStringAsync();

            return(JsonConvert.DeserializeObject <RetrieveTransactionResponse>(responseJson));
        }