private PaymentProcessingResult SendRefundRequest(IPurchaseOrder po, IPayment payment) { try { var requestDoc = _requestDocumentCreation.CreateDocumentForRefundRequest(payment); var responseDoc = DocumentHelpers.SendTransaction(requestDoc, _dataCashConfiguration.Config); if (DocumentHelpers.IsSuccessful(responseDoc)) { payment.ProviderTransactionID = DocumentHelpers.GetResponseInfo(responseDoc, "Response.datacash_reference"); var message = string.Format("[{0}] [RefundTransaction-{1}] [Status: {2}] Response: {3} at Time stamp={4}.", payment.PaymentMethodName, DocumentHelpers.GetResponseInfo(responseDoc, "Response.datacash_reference"), DocumentHelpers.GetResponseInfo(responseDoc, "Response.status"), DocumentHelpers.GetResponseInfo(responseDoc, "Response.reason"), DocumentHelpers.GetResponseInfo(responseDoc, "Response.time") ); // add a new order note about this refund AddNoteToPurchaseOrder(po, po.CustomerId, "REFUND", message); _orderRepository.Save(po); return(PaymentProcessingResult.CreateSuccessfulResult(message)); } return(PaymentProcessingResult.CreateUnsuccessfulResult(DocumentHelpers.GetErrorMessage(responseDoc))); } catch (System.Exception e) { return(PaymentProcessingResult.CreateUnsuccessfulResult(e.Message)); } }
private PaymentProcessingResult SendFulfillRequest(IPurchaseOrder po, IOrderForm orderForm, IPayment payment) { try { var requestDoc = _requestDocumentCreation.CreateDocumentForFulfillRequest(payment, orderForm); var responseDoc = DocumentHelpers.SendTransaction(requestDoc, _dataCashConfiguration.Config); if (DocumentHelpers.IsSuccessful(responseDoc)) { // Extract the response details. // When doing capture, refund, etc... transactions, DataCase will return a new Reference Id. We need to store this to ProviderTransactionID // instead of TransactionID, because TransactionID should be the Authorization reference Id, and ProviderTransactionID will be used when we want to refund. payment.ProviderTransactionID = DocumentHelpers.GetResponseInfo(responseDoc, "Response.datacash_reference"); var message = string.Format("[{0}] [Capture payment-{1}] [Status: {2}] .Response: {3} at Time stamp={4}", payment.PaymentMethodName, DocumentHelpers.GetResponseInfo(responseDoc, "Response.merchantreference"), DocumentHelpers.GetResponseInfo(responseDoc, "Response.status"), DocumentHelpers.GetResponseInfo(responseDoc, "Response.reason"), DocumentHelpers.GetResponseInfo(responseDoc, "Response.time") ); // add a new order note about this capture AddNoteToPurchaseOrder(po, po.CustomerId, "CAPTURE", message); _orderRepository.Save(po); return(PaymentProcessingResult.CreateSuccessfulResult(message)); } return(PaymentProcessingResult.CreateUnsuccessfulResult(DocumentHelpers.GetErrorMessage(responseDoc))); } catch (System.Exception e) { return(PaymentProcessingResult.CreateUnsuccessfulResult(e.Message)); } }