/// <summary> /// Refunds payment /// </summary> /// <param name="order">Order</param> /// <param name="cancelPaymentResult">Cancel payment result</param> public void Refund(Order order, ref CancelPaymentResult cancelPaymentResult) { try { using (usaepayService svc = new usaepayService()) { svc.Url = EPaymentFormSettings.ServiceUrl; TransactionResponse rsp = svc.refundTransaction(EPaymentFormHelper.ServiceSecurityToken, cancelPaymentResult.CaptureTransactionId, (double)cancelPaymentResult.Amount); switch (rsp.ResultCode) { case "A": cancelPaymentResult.PaymentStatus = PaymentStatusEnum.Refunded; break; case "D": case "E": default: cancelPaymentResult.Error = rsp.ErrorCode; cancelPaymentResult.FullError = rsp.Error; break; } } } catch (Exception ex) { cancelPaymentResult.Error = ex.Message; cancelPaymentResult.FullError = ex.Message; } }
/// <summary> /// Captures payment /// </summary> /// <param name="order">Order</param> /// <param name="processPaymentResult">Process payment result</param> public void Capture(Order order, ref ProcessPaymentResult processPaymentResult) { try { using (usaepayService svc = new usaepayService()) { svc.Url = EPaymentFormSettings.ServiceUrl; TransactionResponse rsp = svc.captureTransaction(EPaymentFormHelper.ServiceSecurityToken, processPaymentResult.AuthorizationTransactionId, (double)order.OrderTotal); switch (rsp.ResultCode) { case "A": processPaymentResult.CaptureTransactionId = rsp.RefNum; processPaymentResult.AVSResult = rsp.AvsResult; processPaymentResult.PaymentStatus = PaymentStatusEnum.Paid; break; case "D": case "E": default: processPaymentResult.Error = rsp.ErrorCode; processPaymentResult.FullError = rsp.Error; break; } } } catch (Exception ex) { processPaymentResult.Error = ex.Message; processPaymentResult.FullError = ex.Message; } }
/// <summary> /// Voids paymen /// </summary> /// <param name="order">Order</param> /// <param name="cancelPaymentResult">Cancel payment result</param> public void Void(Order order, ref CancelPaymentResult cancelPaymentResult) { try { using (usaepayService svc = new usaepayService()) { svc.Url = EPaymentFormSettings.ServiceUrl; if (svc.voidTransaction(EPaymentFormHelper.ServiceSecurityToken, cancelPaymentResult.AuthorizationTransactionId)) { cancelPaymentResult.PaymentStatus = PaymentStatusEnum.Voided; } else { cancelPaymentResult.Error = "Failed"; cancelPaymentResult.FullError = "Failed"; } } } catch (Exception ex) { cancelPaymentResult.Error = ex.Message; cancelPaymentResult.FullError = ex.Message; } }
/// <summary> /// Voids paymen /// </summary> /// <param name="order">Order</param> /// <param name="cancelPaymentResult">Cancel payment result</param> public void Void(Order order, ref CancelPaymentResult cancelPaymentResult) { try { using(usaepayService svc = new usaepayService()) { svc.Url = EPaymentFormSettings.ServiceUrl; if(svc.voidTransaction(EPaymentFormHelper.ServiceSecurityToken, cancelPaymentResult.AuthorizationTransactionId)) { cancelPaymentResult.PaymentStatus = PaymentStatusEnum.Voided; } else { cancelPaymentResult.Error = "Failed"; cancelPaymentResult.FullError = "Failed"; } } } catch(Exception ex) { cancelPaymentResult.Error = ex.Message; cancelPaymentResult.FullError = ex.Message; } }
/// <summary> /// Refunds payment /// </summary> /// <param name="order">Order</param> /// <param name="cancelPaymentResult">Cancel payment result</param> public void Refund(Order order, ref CancelPaymentResult cancelPaymentResult) { try { using(usaepayService svc = new usaepayService()) { svc.Url = EPaymentFormSettings.ServiceUrl; TransactionResponse rsp = svc.refundTransaction(EPaymentFormHelper.ServiceSecurityToken, cancelPaymentResult.CaptureTransactionId, (double)cancelPaymentResult.Amount); switch(rsp.ResultCode) { case "A": { if (cancelPaymentResult.IsPartialRefund) cancelPaymentResult.PaymentStatus = PaymentStatusEnum.PartiallyRefunded; else cancelPaymentResult.PaymentStatus = PaymentStatusEnum.Refunded; } break; case "D": case "E": default: cancelPaymentResult.Error = rsp.ErrorCode; cancelPaymentResult.FullError = rsp.Error; break; } } } catch(Exception ex) { cancelPaymentResult.Error = ex.Message; cancelPaymentResult.FullError = ex.Message; } }
/// <summary> /// Captures payment /// </summary> /// <param name="order">Order</param> /// <param name="processPaymentResult">Process payment result</param> public void Capture(Order order, ref ProcessPaymentResult processPaymentResult) { try { using(usaepayService svc = new usaepayService()) { svc.Url = EPaymentFormSettings.ServiceUrl; TransactionResponse rsp = svc.captureTransaction(EPaymentFormHelper.ServiceSecurityToken, processPaymentResult.AuthorizationTransactionId, (double)order.OrderTotal); switch(rsp.ResultCode) { case "A": processPaymentResult.CaptureTransactionId = rsp.RefNum; processPaymentResult.AVSResult = rsp.AvsResult; processPaymentResult.PaymentStatus = PaymentStatusEnum.Paid; break; case "D": case "E": default: processPaymentResult.Error = rsp.ErrorCode; processPaymentResult.FullError = rsp.Error; break; } } } catch(Exception ex) { processPaymentResult.Error = ex.Message; processPaymentResult.FullError = ex.Message; } }