public void TestCancel() { 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); PaymentCancelResponse cancelResponse = client.Payment.CancelAsync(response.Transaction.TransactionId).Result; Assert.AreEqual(200, cancelResponse.StatusCode); cancelResponse = client.Payment.CancelAsync(response.Transaction.TransactionId).Result; Assert.AreEqual(400, cancelResponse.StatusCode); }
public void TestCancelTransaction() { RPGClient client = new RPGClient("myKey", "http://www.borgun.is/", new HttpMessageHandlerMock()); PaymentCancelResponse response = client.Payment.CancelAsync("TestTransaction").Result; Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode); Assert.IsNotNull(response.Result); Assert.AreEqual("TestTransaction", response.Result.TransactionId); }
public async Task <PaymentCancelResponse> CancelAsync(string transactionId) { PaymentCancelResponse paymentRes = new PaymentCancelResponse(); HttpResponseMessage httpRes = await this.client.PutAsync("api/payment/" + transactionId + "/cancel", null); paymentRes.StatusCode = (int)httpRes.StatusCode; if (httpRes.IsSuccessStatusCode) { paymentRes.Result = await httpRes.Content.ReadAsAsync <CancelAuthorizationResponse>(); } else { paymentRes.Message = await httpRes.Content.ReadAsStringAsync(); } return(paymentRes); }