I've been trying to integrate a new payment processor (Redirect Method) and have followed the steps detailed here https://www.nopcommerce.com/boards/t/2891/how-to-code-my-own-payment-method.aspx
I am however not hitting the PostProcessPayment method and I'm not sure why.
When I try to integrate the payment processor using the hosted pages method the ProcessPayment method is being hit correctly.
Is there a setting somewhere where I need to trigger the redirect method to work.
Here is how I have implemented the CardSavePaymentProcessor.
namespace NopSolutions.NopCommerce.Payment.Methods.CardSave
{
public class CardSavePaymentProcessor : IPaymentMethod
{
#region IPaymentMethod Members
public bool CanCapture
{
get
{
return false;
}
}
public bool CanRefund
{
get
{
return false;
}
}
public bool CanVoid
{
get
{
return false;
}
}
public void CancelRecurringPayment(Order order, ref CancelPaymentResult cancelPaymentResult)
{
throw new NopException("Void method not supported");
}
public void Capture(Order order, ref ProcessPaymentResult processPaymentResult)
{
throw new NotImplementedException();
}
public decimal GetAdditionalHandlingFee()
{
return (decimal)0.00;
}
public PaymentMethodTypeEnum PaymentMethodType
{
get
{
return PaymentMethodTypeEnum.Standard;
}
}
public string PostProcessPayment(Order order)
{
string strPreSharedKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
string strPassword = "XXXXXXXXXXXXX";
string strMerchantID = "XXXXXXXXXXXXXXX";
string postUrl = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
StringBuilder hashString = new StringBuilder();
hashString.Append("PreSharedKey=" + strPreSharedKey);
hashString.Append("&MerchantID=" + strMerchantID);
hashString.Append("&Password=" + strPassword);
hashString.Append("&Amount=" + order.OrderTotal);
hashString.Append("&CurrencyCode=" + 826);
hashString.Append("&OrderID=" + order.OrderID);
hashString.Append("&TransactionType=" + TRANSACTION_TYPE.SALE);
hashString.Append("&TransactionDateTime=" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss zzzz"));
hashString.Append("&CallbackURL=" + "http://www.admin.shopnutter.co.uk");
hashString.Append("&OrderDescription=");
hashString.Append("&CustomerName=" + order.CardName);
hashString.Append("&Address1=" + order.BillingAddress1);
hashString.Append("&Address2=" + order.BillingAddress2);
hashString.Append("&Address3=");
hashString.Append("&Address4=");
hashString.Append("&City=" + order.BillingCity);
hashString.Append("&State=");
hashString.Append("&PostCode=" + order.BillingZipPostalCode);
hashString.Append("&CountryCode=" + 826);
hashString.Append("&CV2Mandatory=" + "true");
hashString.Append("&Address1Mandatory=" + "false");
hashString.Append("&CityMandatory=" + "false");
hashString.Append("&PostCodeMandatory=" + "false");
hashString.Append("&StateMandatory=" + "false");
hashString.Append("&CountryMandatory=" + "false");
string hashDigest = CardSaveGateway.Hash.ComputeHashDigest(hashString.ToString(), strPreSharedKey, CardSaveGateway.Hash.HASH_METHOD.SHA1);
RemotePost remotePostHelper = new RemotePost();
remotePostHelper.FormName = "CardSaveContactForm";
remotePostHelper.Params.Add("HashDigest", hashDigest);
remotePostHelper.Params.Add("MerchantID", strMerchantID);
remotePostHelper.Url = postUrl;
remotePostHelper.Post();
return string.Empty;
}
public void ProcessPayment(PaymentInfo paymentInfo, Customer customer, Guid OrderGuid, ref ProcessPaymentResult processPaymentResult)
{
processPaymentResult.PaymentStatus = PaymentStatusEnum.Pending;
}
public void ProcessRecurringPayment(PaymentInfo paymentInfo, Customer customer, Guid OrderGuid, ref ProcessPaymentResult processPaymentResult)
{
throw new NopException("Void method not supported");
}
public void Refund(Order order, ref CancelPaymentResult cancelPaymentResult)
{
throw new NopException("Void method not supported");
}
public RecurringPaymentTypeEnum SupportRecurringPayments
{
get
{
return RecurringPaymentTypeEnum.NotSupported;
}
}
public void Void(Order order, ref CancelPaymentResult cancelPaymentResult)
{
throw new NopException("Void method not supported");
}
#endregion
}
}