public void TestFeeAndRefund() { string customerId = "ar2btmquidjhykdaztp6"; Decimal amount = new Decimal(11); string description = "comisión de .Net de " + amount; string refundDescription = "reembolso de comisión de .Net de " + amount; OpenpayAPI openpayAPI = new OpenpayAPI(Constants.NEW_API_KEY, Constants.NEW_MERCHANT_ID); FeeRequest feeRequest = new FeeRequest(); feeRequest.CustomerId = customerId; feeRequest.Description = description; feeRequest.Amount = amount; Fee fee = openpayAPI.FeeService.Create(feeRequest); Assert.IsNotNull(fee); Assert.IsNotNull(fee.Id); Assert.IsNotNull(fee.CreationDate); Assert.AreEqual("completed", fee.Status); Fee refundFee = openpayAPI.FeeService.Refund(fee.Id, refundDescription); Assert.IsNotNull(refundFee); Assert.IsNotNull(refundFee.Id); Assert.IsNotNull(refundFee.CreationDate); Assert.AreEqual("completed", refundFee.Status); }
public async Task <decimal> GetCommission(string auth, string senderCard, string recipientCard, decimal amount) { HttpClient client = new HttpClient(new Helpers.LoggingHandler(new HttpClientHandler())); client.DefaultRequestHeaders.Add("Authorization", "Bearer " + auth); var request = new FeeRequest { sender = new Account { card = new Card { number = senderCard } }, recipient = new Account { card = new Card { number = recipientCard } }, amount = amount, currency = "RUR" }; var result = await client.PostAsJsonAsync(ConfigurationManager.AppSettings["AlfaUrl"] + "uapi/v1/fee", request); var stringContent = await result.Content.ReadAsStringAsync(); var feeReponse = JsonConvert.DeserializeObject <FeeResponse>(stringContent); return(90); }
public void Fee() { // Arrange var request = new FeeRequest(); request.Params.Add(new FeeRequestParams { }); // Act var response = _client.Server.FeeAsync(request).Result; // Assert Assert.AreEqual(Status.Success, response.Result.Status); }
public async Task <Fee> GetFee(int districtId, int numberOfProducts) { District district = await GetDistrictByProvinceAndDistrictName("Hồ Chí Minh", "Quận 5"); //Khai báo string baseUrl = "https://console.ghn.vn/api/v1/apiv3/CalculateFee"; Dictionary <string, string> headers = new Dictionary <string, string>(); Fee fee = new Fee(); Service service = await GetService(districtId); //Cái này là POST FeeRequest feeRequest = new FeeRequest(); feeRequest.Token = "5dce3e3f0ad5df75487e7654"; feeRequest.FromDistrictId = district.DistrictId; //Quận 5 feeRequest.ToDistrictId = districtId; //Test feeRequest.ServiceId = service.ServiceId; //defaultService feeRequest.Weight = 300 * numberOfProducts; //Test var json = JsonConvert.SerializeObject(feeRequest); HttpRequestMessage httpRequestMessage = new HttpRequestMessage(); httpRequestMessage.Method = HttpMethod.Post; httpRequestMessage.RequestUri = new Uri(baseUrl); httpRequestMessage.Headers.Add("Accept", "application/json"); httpRequestMessage.Headers.Add("Accept", "application/json"); HttpContent httpContent = new StringContent(json, Encoding.UTF8, "application/json"); httpRequestMessage.Content = httpContent; HttpClient _Client = new HttpClient(); HttpResponseMessage res = await _Client.SendAsync(httpRequestMessage); using (HttpContent content = res.Content) { string data = await content.ReadAsStringAsync(); if (data != null) { //code || msg || data JObject result = JObject.Parse(data); var calculatedFee = result["data"]["CalculatedFee"].Value <JValue>(); fee.TotalFee = calculatedFee.ToObject <int>(); } } return(fee); }
public void TesFeeCreate() { OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID); FeeRequest request = new FeeRequest(); request.CustomerId = customer_id; request.Amount = 7.0m; request.Description = "Fee Testing"; Fee fee = openpayAPI.FeeService.Create(request); Assert.IsNotNull(fee.Id); Assert.IsNotNull(fee.CreationDate); Assert.IsNotNull(fee.CustomerId); Assert.IsNotNull(fee.Description); Assert.IsNotNull(fee.Method); Assert.IsNotNull(fee.OperationType); Assert.IsNotNull(fee.Status); }
public async Task <RpcJsonResponse <FeeResult> > FeeAsync(FeeRequest request) { return(await PostAsync <RpcJsonResponse <FeeResult>, FeeResult>(request)); }