public PaymentInitializeResult Initialize(PaymentMethod currentPayment, string orderNumber, string returnUrl, string orderRef) { Log.InfoFormat("Calling PurchasePartPaymentSale for payment with ID:{0} belonging to order with ID: {1}", currentPayment.Payment.Id, currentPayment.OrderGroupId); CustomerDetails customerDetails = CreateModel(currentPayment); if (customerDetails == null) { throw new Exception("Payment class must be ExtendedPayExPayment when using this payment method"); } PurchasePartPaymentSaleResult result = _paymentManager.PurchasePartPaymentSale(orderRef, customerDetails); if (!result.Status.Success) { return new PaymentInitializeResult { ErrorMessage = result.Status.Description } } ; _paymentActions.UpdatePaymentInformation(currentPayment, result.TransactionNumber, result.PaymentMethod); Log.InfoFormat("Successfully called PurchasePartPaymentSale for payment with ID:{0} belonging to order with ID: {1}", currentPayment.Payment.Id, currentPayment.OrderGroupId); return(new PaymentInitializeResult { Success = true }); }
public PaymentCompleteResult Complete(PaymentMethod currentPayment, string orderRef) { Log.InfoFormat("Completing payment with ID:{0} belonging to order with ID: {1}", currentPayment.Payment.Id, currentPayment.OrderGroupId); CompleteResult completeResult = _paymentManager.Complete(orderRef); if (!completeResult.Success || string.IsNullOrWhiteSpace(completeResult.TransactionNumber)) { return new PaymentCompleteResult { TransactionErrorCode = completeResult.ErrorDetails != null ? completeResult.ErrorDetails.TransactionErrorCode : string.Empty } } ; if (completeResult.GetTransactionDetails) { Log.InfoFormat("Retrieving transaction details for payment with ID:{0} belonging to order with ID: {1}", currentPayment.Payment.Id, currentPayment.OrderGroupId); if (_paymentCompleter == null) { _paymentCompleter = new UpdateTransactionDetails(null, _paymentManager); } _paymentCompleter = new UpdateTransactionDetails(_paymentCompleter, _paymentManager); } _paymentActions.UpdatePaymentInformation(currentPayment, completeResult.TransactionNumber, completeResult.PaymentMethod); PaymentCompleteResult result = new PaymentCompleteResult { Success = true }; if (_paymentCompleter != null) { result = _paymentCompleter.Complete(currentPayment, orderRef); } Log.InfoFormat("Successfully completed payment with ID:{0} belonging to order with ID: {1}", currentPayment.Payment.Id, currentPayment.OrderGroupId); return(result); } }