public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest) { var result = new CapturePaymentResult(); var primaryStoreCurrency = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId); var captureRequest = new CaptureTransactionRequest() { Amount = (int)(Math.Round(capturePaymentRequest.Order.OrderTotal, 2) * 100), Currency = primaryStoreCurrency.CurrencyCode, Descriptor = _paylikePaymentSettings.CaptureDescriptor, TransactionId = capturePaymentRequest.Order.AuthorizationTransactionId }; var captureResponse = _paylikeTransactionService.CaptureTransaction(captureRequest); if (captureResponse.IsError) { result.AddError(captureResponse.ErrorMessage); result.AddError(captureResponse.ErrorContent); } else { result.CaptureTransactionId = captureResponse.Content.Id; result.NewPaymentStatus = PaymentStatus.Paid; } return(result); }
public void CaptureTransaction_Success() { var response = transactionService.CreateTransaction(createTransactionRequest); CaptureTransactionRequest captureRequest = new CaptureTransactionRequest() { Amount = createTransactionRequest.Amount, Currency = createTransactionRequest.Currency, TransactionId = response.Content.Id }; var captureResponse = transactionService.CaptureTransaction(captureRequest); var transaction = captureResponse.Content; Assert.IsFalse(captureResponse.IsError); Assert.AreEqual(201, captureResponse.ResponseCode); Assert.IsNotNull(transaction.Id); Assert.AreEqual(createTransactionRequest.Amount, transaction.Amount); Assert.AreEqual(createTransactionRequest.Currency, transaction.Currency); Assert.AreEqual(createTransactionRequest.Amount, transaction.CapturedAmount); Assert.IsTrue(transaction.Trail[0].Capture); }