首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Opayo API -无法验证签名

Opayo API -无法验证签名
EN

Stack Overflow用户
提问于 2021-05-06 16:53:54
回答 1查看 103关注 0票数 0

我一直在尝试连接到Opayo的'Reporting & Admin API‘并使用'getTransactionDetail’(https://developer-eu.elavon.com/docs/opayo-reporting-api/reporting-commands/gettransactiondetail)命令,但总是返回错误0010,这表明该接口无法验证签名值。我们已经能够使用我们的Vendor/用户名/密码组合登录,验证它们都是正确的。

我们在向API发送帖子时使用的代码如下--出于安全考虑,某些元素被屏蔽了。

代码语言:javascript
复制
using System;
using System.Collections.Specialized;
using System.Security.Cryptography;
using System.Text;
using System.Net;

public partial class test : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string signature = "<command>getTransactionDetail</command><vendor>[Vendor]</vendor><user>[User]</user><vendortxcode>[VendorTXCode]</vendortxcode><password>[Password]</password>";

        using (MD5 md5 = MD5.Create())
        {
            byte[] inputBytes = Encoding.Unicode.GetBytes(signature);
            byte[] hashBytes = md5.ComputeHash(inputBytes);

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < hashBytes.Length; i++)
            {
                sb.Append(hashBytes[i].ToString("X2"));
            }
            signature = sb.ToString();
        }

        string xmlToPost = "<vspaccess><command>getTransactionDetail</command><vendor>[Vendor]</vendor><user>[User]</user><vendortxcode>[VendorTXCode]</vendortxcode><signature>" + signature + "</signature></vspaccess>";

        using (WebClient client = new WebClient())
        {
            client.BaseAddress = "https://test.sagepay.com";
            client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
            client.Encoding = Encoding.UTF8;

            var content = new NameValueCollection()
            {
                { "XML", xmlToPost }
            };

            string response = Encoding.UTF8.GetString(client.UploadValues("/access/access.htm", content));
        }
    }
}

任何帮助解决这个问题的人都将不胜感激!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-06-29 22:00:23

事实证明,由于我们使用表单集成进行初始付款,所以我们不得不使用以下API文档:https://developer-eu.elavon.com/docs/opayo/spec/api-reference

更具体地说,这部分与重复有关:https://developer-eu.elavon.com/docs/opayo/spec/api-reference#operation/createTransaction

请注意右侧的代码示例!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67414857

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档