public void TestCreatePayment() { PaymentRequest req = new PaymentRequest() { PaymentMethod = new PaymentRequestMethod() { PaymentType = PaymentTypes.Card, PAN = "4242424242424242", ExpMonth = "01", ExpYear = "20", CVC2 = "000" }, Amount = 100, Currency = "352", OrderId = "TEST00000001", TransactionDate = DateTime.Now, TransactionType = TransactionTypes.Sale }; RPGClient client = new RPGClient("myKey", "http://www.borgun.is/", new HttpMessageHandlerMock()); PaymentTransactionResponse response = client.Payment.CreateAsync(req).Result; Assert.AreEqual((int)HttpStatusCode.Created, response.StatusCode); Assert.IsFalse(String.IsNullOrEmpty(response.Uri)); Assert.IsNotNull(response.Transaction); Assert.AreEqual("TestTransaction", response.Transaction.TransactionId); }
public void TestCapture() { PaymentRequest req = new PaymentRequest() { TransactionType = TransactionTypes.PreAuthorization, PaymentMethod = new PaymentRequestMethod() { PaymentType = PaymentTypes.Card, PAN = this.testPan, ExpMonth = this.testExpMonth, ExpYear = this.testExpYear }, Amount = 100, Currency = "352", OrderId = "IntegrTest01", TransactionDate = DateTime.Now }; RPGClient client = new RPGClient(this.config.AppSettings.Settings["PrivateToken"].Value, this.uri); PaymentTransactionResponse response = client.Payment.CreateAsync(req).Result; Assert.AreEqual((int)HttpStatusCode.Created, response.StatusCode); PaymentCaptureResponse captureResponse = client.Payment.CaptureAsync(response.Transaction.TransactionId).Result; Assert.AreEqual(200, captureResponse.StatusCode); captureResponse = client.Payment.CaptureAsync(response.Transaction.TransactionId).Result; Assert.AreEqual(400, captureResponse.StatusCode); }
public async Task <PaymentTransactionResponse> CreateAsync(PaymentRequest req) { // Amount (https://docs.borgun.is/paymentgateways/bapi/rpg/payments.html) // Required Transaction amount, including two decimal points, i.e. 100 USD is 10000. // An exception is JPY, it contains no decimal points. // We handle this here, no reason to leave this to caller if (req.Amount.HasValue && req.Currency != Currency.JPY.ToString()) { req.Amount *= 100; } var paymentRes = new PaymentTransactionResponse(); var resp = await DefaultPolly.PurchaseTransactionPolicy() .ExecuteAsync(() => _client.PostAsJsonAsync("payment", req)) .ConfigureAwait(false); await HandleErrorResponseAsync(resp).ConfigureAwait(false); paymentRes.Transaction = await resp.Content.ReadAsAsync <TransactionInfo>().ConfigureAwait(false); if (resp.Headers.Location != null) { paymentRes.Uri = resp.Headers.Location.AbsoluteUri; } return(paymentRes); }
public void TestGetTransaction() { RPGClient client = new RPGClient("myKey", "http://www.borgun.is/", new HttpMessageHandlerMock()); PaymentTransactionResponse response = client.Payment.GetTransactionAsync("TestTransaction").Result; Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode); Assert.IsNotNull(response.Transaction); Assert.AreEqual("TestTransaction", response.Transaction.TransactionId); }
public async Task <PaymentTransactionResponse> PayTransactionAsync(PaymentTransactionRequest paymentTransactionRequest) { RestClient client = WebServiceContext.GetUrl("/api/v2/sale"); RestRequest request = WebServiceContext.GetRequestBody("post"); request.AddParameter("application/json", JsonConvert.SerializeObject(paymentTransactionRequest), ParameterType.RequestBody); IRestResponse response = await client.ExecuteTaskAsync(request); PaymentTransactionResponse paymentTransactionResponse = JsonConvert.DeserializeObject <PaymentTransactionResponse>(response.Content); return(paymentTransactionResponse); }
public async Task <PaymentTransactionResponse> GetTransactionAsync(string transactionId) { PaymentTransactionResponse paymentRes = new PaymentTransactionResponse(); HttpResponseMessage httpRes = await this.client.GetAsync("api/payment/" + transactionId); paymentRes.StatusCode = (int)httpRes.StatusCode; if (httpRes.IsSuccessStatusCode) { paymentRes.Transaction = await httpRes.Content.ReadAsAsync <TransactionInfo>(); } else { paymentRes.Message = await httpRes.Content.ReadAsStringAsync(); } return(paymentRes); }
public async Task <PaymentTransactionResponse> ExecuteAsync(string tenancyRef) { var response = new PaymentTransactionResponse(); var paymentTransaction = await tenanciesGateway.GetPaymentTransactionsByTenancyRefAsync(tenancyRef).ConfigureAwait(false); response.PaymentTransactions = paymentTransaction.ConvertAll(paymentTrans => new PaymentTransaction { Ref = paymentTrans.TransactionRef, Amount = paymentTrans.Amount.ToString("C"), Date = string.Format("{0:u}", paymentTrans.Date), Type = paymentTrans.Type, PropertyRef = paymentTrans.PropertyRef, Description = paymentTrans.Description } ); return(response); }
public async Task <IActionResult> GetLastByDate(string clientId) { var lastPaymentTransaction = await _paymentTransactionsService.GetLastByDateAsync(clientId); var personalData = await _personalDataService.GetAsync(clientId); if (personalData == null) { return(BadRequest("A user with such an clientId does not exist.")); } var isCreditVoucherOrFxpaygate = lastPaymentTransaction != null && (lastPaymentTransaction.PaymentSystem == CashInPaymentSystem.CreditVoucher || lastPaymentTransaction.PaymentSystem == CashInPaymentSystem.Fxpaygate); var result = isCreditVoucherOrFxpaygate ? PaymentTransactionResponse.Create(lastPaymentTransaction, personalData) : PaymentTransactionResponse.Create(personalData); result.Country = _countryComponent.GetCountryIso3Code(result.Country); return(Ok(result)); }
public async Task <PaymentTransactionResponse> CreateAsync(PaymentRequest req) { PaymentTransactionResponse paymentRes = new PaymentTransactionResponse(); HttpResponseMessage httpRes = await this.client.PostAsJsonAsync("api/payment", req); paymentRes.StatusCode = (int)httpRes.StatusCode; if (httpRes.IsSuccessStatusCode) { paymentRes.Transaction = await httpRes.Content.ReadAsAsync <TransactionInfo>(); if (httpRes.Headers.Location != null) { paymentRes.Uri = httpRes.Headers.Location.AbsoluteUri; } } else { paymentRes.Message = await httpRes.Content.ReadAsStringAsync(); } return(paymentRes); }
public void TestCreatePayment() { PaymentRequest req = new PaymentRequest() { TransactionType = TransactionTypes.PreAuthorization, PaymentMethod = new PaymentRequestMethod() { PaymentType = PaymentTypes.Card, PAN = this.testPan, ExpMonth = this.testExpMonth, ExpYear = this.testExpYear }, Amount = 100, Currency = "352", OrderId = "IntegrTest01", TransactionDate = DateTime.Now }; RPGClient client = new RPGClient(this.config.AppSettings.Settings["PrivateToken"].Value, this.uri); PaymentTransactionResponse response = client.Payment.CreateAsync(req).Result; Assert.AreEqual((int)HttpStatusCode.Created, response.StatusCode); Assert.AreEqual(this.uri + "api/payment/" + response.Transaction.TransactionId, response.Uri); Assert.AreEqual("000", response.Transaction.ActionCode); Assert.AreEqual(TransactionStatus.Uncaptured, response.Transaction.TransactionStatus); Assert.AreEqual(TransactionTypes.PreAuthorization, response.Transaction.TransactionType); req = new PaymentRequest(); response = client.Payment.CreateAsync(req).Result; Assert.AreEqual((int)HttpStatusCode.BadRequest, response.StatusCode); Assert.IsFalse(String.IsNullOrEmpty(response.Message)); client = new RPGClient("InvalidKey", this.uri); response = client.Payment.CreateAsync(req).Result; Assert.AreEqual((int)HttpStatusCode.Unauthorized, response.StatusCode); }
public async Task ChangeAddress(String trans) => transaction = await RippleClientUBC.GetClient().client.Transaction(trans) as PaymentTransactionResponse;