I am having been struggling to set up my first payment gateway in Merchello...
My client has gone for SagePay (Form Integration), and I have been attempting to work from the posts here and here (Thanks Barry, Chris & Gordon!) in order to get my checkout process complete.
Thus far I have:
Installed Merchello.SagePay into my project and configured it in the backoffice with my test account details.
Added a Payment button to my checkout page.
Saved the payment method to my BasketSalePreparation.
After this, I attempt AuthorizePayment, and I receive an error message that says:
SagePay: request initialization error: Specified initialization vector (IV) does not match the block size for this algorithm.
I also am not sure how to validate the payment after the user has completed their checkout on SagePay. I presume there is a callback URL, we have to receive the Invoice Key back from the return call and mark it as paid? I can't find anything that shows how to do this...
Any help much appreciated! :)
Here is my controller code:
[HttpPost]
public ActionResult ConfirmSagePayPayment()
{
var preparation = Basket.SalePreparation();
preparation.RaiseCustomerEvents = false;
// PAYMENT - Only one payment method so auto-select it (SagePay)
var paymentGatewayMethod = MerchelloContext.Current.Gateways.Payment.GetPaymentGatewayMethods().FirstOrDefault();
var paymentMethod = Payment.GetPaymentGatewayMethodByKey(paymentGatewayMethod.PaymentMethod.Key).PaymentMethod;
preparation.SavePaymentMethod(paymentMethod);
// AuthorizePayment will save the invoice with an Invoice Number.
var attempt = PerformProcessPayment(preparation, paymentMethod);
if (!attempt.Payment.Success)
{
return CurrentUmbracoPage();
}
// store the invoice key in the CustomerContext for use on the receipt page.
CustomerContext.SetValue("invoiceKey", attempt.Invoice.Key.ToString());
if (attempt.Payment.Result.ExtendedData != null && attempt.Payment.Result.ExtendedData.ContainsKey("SagePayPaymentUrl"))
return new RedirectResult(attempt.Payment.Result.ExtendedData["SagePayPaymentUrl"]);
var nullref = new NullReferenceException("SagePay payment URL not found in extended data");
LogHelper.Error<CheckoutController>("SagePay payment URL not found in extended data", nullref);
throw nullref;
}
protected IPaymentResult PerformProcessPayment(SalePreparationBase preparation, IPaymentMethod paymentMethod)
{
return preparation.AuthorizePayment(paymentMethod.Key);
}
Merchello.SagePay Checkout
I am having been struggling to set up my first payment gateway in Merchello...
My client has gone for SagePay (Form Integration), and I have been attempting to work from the posts here and here (Thanks Barry, Chris & Gordon!) in order to get my checkout process complete.
Thus far I have:
After this, I attempt AuthorizePayment, and I receive an error message that says:
I also am not sure how to validate the payment after the user has completed their checkout on SagePay. I presume there is a callback URL, we have to receive the Invoice Key back from the return call and mark it as paid? I can't find anything that shows how to do this...
Any help much appreciated! :)
Here is my controller code:
This is resolved now. I downloaded the source for Merchello.Plugin.Payments..SagePay and went into debug...
Turns out I had an incorrect encryption password in my backoffice settings 😳
Major Sigh
So, if anyone else has this same error message... check your encryption password in the back office settings!
is working on a reply...