问题
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.
- Either modify the decoded response from the server to change the value of the
3DSecureStatus
value toNONE
(as written in the question.) 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 theThreeDSecureStatus.cs
file:public enum ThreeDSecureStatus { NONE, OK, NOAUTH, CANTAUTH, NOTAUTHED, ATTEMPTONLY, NOTCHECKED, INCOMPLETE, MALFORMED, INVALID, ERROR, NOTAVAILABLE //<--- Add this }
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