/// <summary> /// Refunds a payment /// </summary> /// <param name="refundPaymentRequest">Request</param> /// <returns>Result</returns> public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest) { var result = new RefundPaymentResult(); var config = new HpsServicesConfig(); config.SecretApiKey = _secureSubmitPaymentSettings.SecretApiKey; config.DeveloperId = "002914"; config.VersionNumber = "1513"; var creditService = new HpsCreditService(config); try { creditService.Refund( refundPaymentRequest.AmountToRefund, _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode, Int32.Parse(refundPaymentRequest.Order.CaptureTransactionId)); var isOrderFullyRefunded = (refundPaymentRequest.AmountToRefund + refundPaymentRequest.Order.RefundedAmount == refundPaymentRequest.Order.OrderTotal); result.NewPaymentStatus = isOrderFullyRefunded ? PaymentStatus.Refunded : PaymentStatus.PartiallyRefunded; } catch (HpsException ex) { result.AddError(ex.Message); } return(result); }
public void Mastercard_Return_ShouldBe_Ok() { var chargeSvc = new HpsCreditService(_certConfig); var response = chargeSvc.Refund(15.15m, "usd", TestCreditCard.ValidMasterCard, TestCardHolder.CertCardHolderShortZip); Assert.IsNotNull(response); StringAssert.Matches(response.ResponseCode, new Regex("^00$")); }
public void MasterCard_ShouldRefund_Ok() { var creditSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); var creditResponse = creditSvc.Charge(25.00m, "usd", TestCreditCard.ValidMasterCard, TestCardHolder.CertCardHolderShortZipNoStreet); var refundResponse = creditSvc.Refund(25.00m, "usd", creditResponse.TransactionId); StringAssert.Matches(refundResponse.ResponseCode, new Regex("^00$")); }
public void RefundWithTrackData() { HpsTrackData trackData = new HpsTrackData { Value = "%B5473500000000014^MC TEST CARD^251210199998888777766665555444433332?;5473500000000014=25121019999888877776?", Method = HpsTrackDataMethod.Swipe }; var creditService = new HpsCreditService(ServicesConfig); HpsRefund response = creditService.Refund(12.00M, "USD", trackData); Assert.IsNotNull(response); Assert.AreEqual("00", response.ResponseCode); }