Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • stephen 81 posts 122 karma points
    Jun 07, 2016 @ 14:34
    stephen
    1

    Error 5006 - Sagepay

    Using the Payment Provider (SagePay), I have a payment process completing, ending in the creation of a Transaction and an email confirmation but the page continues to display the Sagepay error 5006

    The Callback is received from Sagepay (the param SagePayResponse response)

    I can then retrieve the response properties (like TxAuthNo, AVSCV2 etc)

    I then call response.GenerateSignature Then

    TeaCommerce.Api.Web.PaymentProviders.CallbackInfo mycbi = mysp.ProcessCallback(TC.GetCurrentOrder(1), myreq, settings); This results in a Transaction ID and order.Finalize

    At this point I try to redirect to the umbraco page but nothing happens.

    What i am still unsure of is what httprequest object to use to pass to the ProcessCallback

    The ProcessCallback indicates:

    public override CallbackInfo ProcessCallback(Order order, HttpRequest request, IDictionary

    So 2 questions:

    1. what httprequest to pass to ProcessCallback
    2. why is the redirect not working at the end of the process
  • Anders Burla 2560 posts 8256 karma points
    Jun 07, 2016 @ 15:04
    Anders Burla
    0

    Hi Stephen

    I cant figure out if your are doing a custom provider that doesnt quite use the flow of a normal provider in Tea Commerce or if you use the standard in Tea Commerce. From my look at your question it looks like you are making a total custom one from scratch. For it to work properly with Tea Commerce you need to use its payment provider API to build a provider - else the flow will be totally wrong and hard to debug.

    A callback in the SagePay case is a URL that their server calls server to server. The URL to call in your webshop is a "magic" Tea Commerce generated URL that does all the magic of finding which provider that shoudl make the checks etc is done in Tea Commerce core. The URL that is normally hit is the PaymentCallback REST method seen here: https://github.com/TeaCommerce/Tea-Commerce-for-Umbraco/blob/master/Source/TeaCommerce.Umbraco.Web/RestExtensions.cs

    That will route to the right provider and send the HTTP context as a parameter etc. So you dont need to think about this.

    So could you try and let me know if you are using the TC payment provider API in the way it was thought to, or if your a haxing it? :-)

    Kind regards

    Anders

  • stephen 81 posts 122 karma points
    Jun 07, 2016 @ 18:39
    stephen
    0

    I am using https://github.com/TeaCommerce/Payment-providers/blob/master/Source/TeaCommerce.PaymentProviders/Classic/SagePay.cs

    in my model

    [PaymentProvider("SagePay")]
    public class SagePay : APaymentProvider 
    {...... 
    

    So my final page in the order process instantiates a new SagePay() object and

     SagePay mysp = new SagePay();
    PaymentHtmlForm myform = mysp.GenerateHtmlForm(order, "a success url", "a fail url", "http://...path/getCallbackFromSagepay", "", settings);
    

    The Callback url (from Sagepay to website) goes to:

    public ActionResult getCallbackFromSagepay(SagePayResponse response)
        {
            Order order = TC.GetCurrentOrder(1,false);
            Dictionary<string, string> settings = new Dictionary<string, string>();
            settings["AddressResult"] = response.AddressResult;
            settings["PostCodeResult"] = response.PostCodeResult;
            settings["AVSCV2"] = response.AVSCV2;
            settings["CV2Result"] = response.CV2Result;
            settings["AddressStatus"] = response.AddressStatus;
            settings["PayerStatus"] = response.PayerStatus;
    

    and all the other SagePay response properties THEN

    string setSignature = response.GenerateSignature(order.Properties["securityKey"], "vendor name");
    
    string sig = response.VPSSignature;
    settings["vpsMySignature"] = setSignature;
    SagePay mysp = new SagePay();
    TeaCommerce.Api.Web.PaymentProviders.CallbackInfo mycbi =  mysp.ProcessCallback(TC.GetCurrentOrder(1), myreq, settings);
    

    (myreq is a url I have entered which I know is incorrect but this is where one of my questions relates)

    Now it calls the PROCESSCALLBACK in the class SagePay : APaymentProvider

    string a = mycbi.TransactionId.ToString();
    Log.Add(LogTypes.Debug, 1314, " TRANSACTION ID = " + a);
    order.Finalize(mycbi.AmountAuthorized, mycbi.TransactionId, mycbi.PaymentState);
    

    I then try to either redirect (umbracopage) or call another action (fails here)

    So all of the above uses both the

    PaymentHtmlForm GenerateHtmlForm
    public override CallbackInfo ProcessCallback( Order order, HttpRequest request, IDictionary<string, string> settings )
    

    in the SagePay payment provider.

    and I have replicated the PaymentProvider class as a model in my project.

    For now I do not make any call to

    public class RestExtensions
    

    and I have not seen any documentation which indicates how this is used with the TeaCommerce Payment Providers/SagePay.cs

    thanks

  • Anders Burla 2560 posts 8256 karma points
    Jun 08, 2016 @ 08:16
    Anders Burla
    0

    Hi Stephen

    You should not do new SagePay(); and all that. You should use the Razor API of Tea Commerce. See how its done here. That will do all the magic with the continue url, cancel url, callback etc. So no need for you to do all this hard work :)

    https://github.com/TeaCommerce/Starter-kit-for-Umbraco/blob/master/Source/Website/Views/CartStep4.cshtml

    https://documentation.teacommerce.net/razor-api/payment-provider/generatepaymentform/

  • stephen 81 posts 122 karma points
    Jun 08, 2016 @ 11:36
  • Anders Burla 2560 posts 8256 karma points
    Jun 08, 2016 @ 11:50
    Anders Burla
    0

    If you look in the code in line 155, it sets the cancel url to the action if something went wrong. It also logs it. So look in the Umbraco log files in the App_Data folder and see what the error message is. Should give you a clue about it.

    https://github.com/TeaCommerce/Payment-providers/blob/master/Source/TeaCommerce.PaymentProviders/Classic/SagePay.cs

  • stephen 81 posts 122 karma points
    Jun 08, 2016 @ 13:32
    stephen
    0

    Nearly there. Everything works except Unable to redirect to Vendor's web site. The Vendor failed to provide a RedirectionURL.

    In the back office I have tried both fully qualified url and relative url for both ContinueURL and CancelURL (also have SuccessURL and FailureURL)

    In SagePay.cs I have tried hard coding lines 104-106 with full urls (I thought the NotificationURL was the RedirectURL)

    Does the page which NotificationURL points to need to call a function in the SagePay Payment Provider to send a request back to SagePay?

    Here is log

    2016-06-08 16:28:54,385 [47] INFO umbraco.BusinessLogic.Log - [P17660/T1/D42] Redirected log call (please use Umbraco.Core.Logging.LogHelper instead of umbraco.BusinessLogic.Log) | Type: Debug | User: 0 | NodeId: 1316 | Comment: PROCESSCALLBACK FUNCTION IS HERE 2016-06-08 16:28:54,386 [47] ERROR TeaCommerce.Umbraco.Configuration.Infrastructure.Logging.LoggingProvider - [P17660/T1/D42] Sage Pay(CART-36241) - Process callback - Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.Collections.Generic.Dictionary2.get_Item(TKey key) at NorthAyrshire.Models.SagePay.ProcessCallback(Order order, HttpRequest request, IDictionary2 settings) System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.Collections.Generic.Dictionary2.get_Item(TKey key) at NorthAyrshire.Models.SagePay.ProcessCallback(Order order, HttpRequest request, IDictionary2 settings) 2016-06-08 16:28:54,407 [47] ERROR TeaCommerce.Umbraco.Configuration.Infrastructure.Logging.LoggingProvider - [P17660/T1/D42] Form:

    VPSProtocol : 3.00 TxType : PAYMENT VendorTxCode : CART-36241 VPSTxId : {1C41B209-6F2D-B4FC-92B4-6C480A26E786} Status : OK StatusDetail : 0000 : The Authorisation was Successful. TxAuthNo : 11164459 AVSCV2 : SECURITY CODE MATCH ONLY AddressResult : NOTMATCHED PostCodeResult : NOTMATCHED CV2Result : MATCHED GiftAid : 0 3DSecureStatus : NOTCHECKED CardType : VISA Last4Digits : 5559 VPSSignature : 4281D0DBFD48AD350627F7BF653774AB Surcharge : 1.01 DeclineCode : 00 ExpiryDate : 1020 BankAuthCode : 999777

    2016-06-08 16:28:54,407 [47] INFO umbraco.BusinessLogic.Log - [P17660/T1/D42] Redirected log call (please use Umbraco.Core.Logging.LogHelper instead of umbraco.BusinessLogic.Log) | Type: Debug | User: 0 | NodeId: 1316 | Comment: PROCESSCALLBACK FUNCTION IS HERE 2016-06-08 16:28:54,408 [47] ERROR TeaCommerce.Umbraco.Configuration.Infrastructure.Logging.LoggingProvider - [P17660/T1/D42] Sage Pay(CART-36241) - Process callback - Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.Collections.Generic.Dictionary2.get_Item(TKey key) at NorthAyrshire.Models.SagePay.ProcessCallback(Order order, HttpRequest request, IDictionary2 settings) System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.Collections.Generic.Dictionary2.get_Item(TKey key) at NorthAyrshire.Models.SagePay.ProcessCallback(Order order, HttpRequest request, IDictionary2 settings)

    thanks

  • Anders Burla 2560 posts 8256 karma points
    Jun 09, 2016 @ 08:33
    Anders Burla
    0

    Check the DB. Does your order have a custom property named teaCommerceContinueUrl or teaCommerceCancelUrl?

  • stephen 81 posts 122 karma points
    Jun 09, 2016 @ 11:39
    stephen
    0

    Yes there is an entry for both in [TeaCommerce_CustomOrderProperty] called teaCommerceCancelUrl and teaCommerceContinueUrl

    with a fully qualified url ending in .aspx

  • Anders Burla 2560 posts 8256 karma points
    Jun 09, 2016 @ 11:41
    Anders Burla
    0

    From the code in the provider you can see that there is some if statements before the redirect url is set in line 233 and 244. This might indicate that something is wrong and the code is logging the error. So have a look in your Umbraco log files and see for things that starts with "Sage Pay(" as in line 251 and 254

    Kind regards

    Anders

  • stephen 81 posts 122 karma points
    Jun 09, 2016 @ 15:00
    stephen
    0

    Excellent got it working. Many thanks

  • Anders Burla 2560 posts 8256 karma points
    Jun 13, 2016 @ 08:16
    Anders Burla
    0

    Hi Stephen

    SUPER! Could you try an elaborate what was wrong and how you fixed it. I could help others in the same situation in the future :)

Please Sign in or register to post replies

Write your reply to:

Draft