/// <summary> /// Maps the <see cref="PurchaseOrderFormData"/> to a <see cref="ProcessorArgumentCollection"/> /// </summary> /// <param name="purchaseOrder"> /// The purchase order. /// </param> /// <returns> /// The <see cref="ProcessorArgumentCollection"/>. /// </returns> public static ProcessorArgumentCollection AsProcessorArgumentCollection(this PurchaseOrderFormData purchaseOrder) { return(new ProcessorArgumentCollection() { { "purchaseOrderNumber", purchaseOrder.PurchaseOrderNumber } }); }
/// <summary> /// Processes the Authorize and AuthorizeAndCapture transactions /// </summary> /// <param name="invoice">The <see cref="IInvoice"/> to be paid</param> /// <param name="payment">The <see cref="IPayment"/> record</param> /// <param name="transactionMode">Authorize or AuthorizeAndCapture</param> /// <param name="amount">The money amount to be processed</param> /// <param name="purchaseOrder">The <see cref="PurchaseOrderFormData"></see></param> /// <returns>The <see cref="IPaymentResult"/></returns> public IPaymentResult ProcessPayment(IInvoice invoice, IPayment payment, decimal amount, PurchaseOrderFormData purchaseOrder) { if (string.IsNullOrEmpty(purchaseOrder.PurchaseOrderNumber)) { return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception(string.Format("Error Purchase Order Number is empty"))), invoice, false); } invoice.PoNumber = purchaseOrder.PurchaseOrderNumber; payment.Authorized = true; return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, true); }