SagePay .Net Integration Kit - Error when returning NOTAVAILABLE value for 3dSecureStatus

爱⌒轻易说出口 提交于 2019-11-30 17:49:02

问题


I have implemented SagePay payment using the Form Integration. My implementation is based on the .Net integration kit supplied by SagePay which has all been good.

Recently we have enabled 3D Secure and have encountered an issue when the value of 3DSecureStatus returns a value of NOTAVAILABLE.

It would seem that when the NOTAVAILABLE value is returned, an error is thrown within the call to the ConvertToSagePayMessage() method on the SagePayIntegration class within the assembly SagePay.IntegrationKit.DotNet.dll.

Specifically, this error occurs when the value is being parsed to the ThreeDSecureStatus enum. This enum does not have a value for NOTAVAILABLE to be able to parse to, hence the error.

I have put a fix in for this for the moment to get this working for now. This fix replaces the NOTAVAILABLE value with NONE, so this now parse to a valid enum value. This is done just before the call to ConvertToSagePayMessage()

cryptDecoded = cryptDecoded.Replace("3DSecureStatus=NOTAVAILABLE", "3DSecureStatus=NONE");

I was just wondering why the ThreeDSecureStatus enum does not have a value for NOTAVAILABLE, as NOTAVAILABLE is one of the values that it is expected to return, which is outlined in the Form Integration Protocol guide supplied by SagePay. And was hoping to implement a more robust fix, rather than the string replace.


回答1:


The problem is that the integration kit contains a bug in that the enum for the 3DSecure status is missing a value for NOTAVAILABLE. SagePay have even told me this:

Unfortunately this is a known issue with the .NET kit but there is no fix as of yet.

So there are three possible ways to fix this.

  1. Either modify the decoded response from the server to change the value of the 3DSecureStatus value to NONE (as written in the question.)
  2. Use a version of the Integration Kit that has had the fix applied. You can ask SagePay for the code (they seem perfectly willing to provide it free of charge) and add in NOTAVAILABLE as an enum value in the ThreeDSecureStatus.cs file:

    public enum ThreeDSecureStatus
    {
        NONE,
        OK,
        NOAUTH,
        CANTAUTH,
        NOTAUTHED,
        ATTEMPTONLY,
        NOTCHECKED,
        INCOMPLETE,
        MALFORMED,
        INVALID,
        ERROR,
        NOTAVAILABLE //<--- Add this
    }
    
  3. I have already gone through the process of fixing the bug and have uploaded it to a GitHub repository. Feel free to take the code from there. I have also updated the project to use C#6 and as such you will need to use Visual Studio 2015 or higher to use it. If you do need to use an older version, you could start with the original files from the first commit to the repository.



来源:https://stackoverflow.com/questions/29142334/sagepay-net-integration-kit-error-when-returning-notavailable-value-for-3dsec

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!