首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当我试图向Paysafe发送请求时,我一直从API中得到以下响应

当我试图向Paysafe发送请求时,我一直从API中得到以下响应
EN

Stack Overflow用户
提问于 2016-11-16 09:34:37
回答 1查看 557关注 0票数 0

这是我用来提出请求的代码。

代码语言:javascript
复制
   {
    "total_amount": "1000",
    "currency_code": "USD",
    "merchant_ref_num": "12345678",
    "customer_notification_email": "test@test.com",
    "profile": {
        "firstName": "Test",
        "lastName": "Sample",
        "merchantCustomerId": "12345678"
    },
    "billingDetails": {
        "city": "Montreal",
        "country": "CA",
        "street": "123 Main Apt 200",
        "zip": "H1H1H1",
        "state": "QC",
        "phone": "555-555-5555"
    },
    "extendedOptions": [
        {
            "key": "authType",
            "value": "auth"
        },
        {
            "key": "orderTimeout",
            "value": 2592000
        },
        {
            "key": "suppressCustomerEmail",
            "value": true
        },
      {
            "key": "silentPost",
            "value": false
        }
    ],
    "callback": [
        {
            "format": "get",
            "rel": "on_success",
            "uri": "https://secure4137.hostgator.com/~cmedei/optimal/callbacks/callback.php",
            "returnKeys": [
                "id",
                "profile.paymentToken",
                "profile.id",
                "transaction.errorCode",
                "transaction.errorMessage",
                "transaction.confirmationNumber",
                "transaction.amount",
                "transaction.authType",
                "transaction.status",
                "transaction.currencyCode",
                "transaction.merchantRefNum",
                "transaction.card.brand",
                "transaction.card.country",
                "transaction.card.expiry",
                "transaction.card.lastDigits",
                "transaction.card.threeDEnrolment",
                "transaction.card.threeDResult",
                "transaction.card.type",
                "transaction.paymentType",
                "transaction.prepaidcard.lastDigits"
            ],
            "retries": 3,
            "synchronous": true
        },
        {
            "format": "get",
            "rel": "on_decline",
            "uri": "https://secure4137.hostgator.com/~cmedei/optimal/callbacks/callback.php",
            "returnKeys": [
                "id",
                "profile.paymentToken",
                "profile.id",
                "transaction.errorCode",
                "transaction.errorMessage",
                "transaction.confirmationNumber",
               "transaction.amount",
                "transaction.authType",
                "transaction.status",
                "transaction.currencyCode",
                "transaction.merchantRefNum",
                "transaction.card.brand",
                "transaction.card.country",
                "transaction.card.expiry",
                "transaction.card.lastDigits",
                "transaction.card.threeDEnrolment",
                "transaction.card.threeDResult",
                "transaction.card.type",
                "transaction.paymentType",
                "transaction.prepaidcard.lastDigits"
            ],
            "retries": 3,
            "synchronous": true
        }
    ],
    "redirect": [
        {
            "rel": "on_success",
            "uri": "http://localhost:8080/hosted_api/main/success/",
            "returnKeys": [
                "id",
                "transaction.confirmationNumber",
                "transaction.amount",
                "transaction.status",
                "transaction.errorCode",
                "transaction.errorMessage",
                "transaction.riskReasonCode",
                "transaction.card.lastDigits",
                "transaction.card.brand",
                "transaction.card.type"
            ]
        },
        {
            "rel": "on_decline",
            "uri": "http://localhost:8080/hosted_api/main/failure/",
            "returnKeys": [
                "id",
                "transaction.confirmationNumber",
                "transaction.amount",
                "transaction.status",
                "transaction.errorCode",
                "transaction.errorMessage",
                "transaction.riskReasonCode",
                "transaction.card.lastDigits",
                "transaction.card.brand",
                "transaction.card.type"
            ]
        },
        {
            "rel": "on_error",
            "uri": "http://localhost:8080/hosted_api/main/error/",
            "returnKeys": [
                "id",
                "transaction.confirmationNumber",
                "transaction.amount",
                "transaction.status",
                "transaction.errorCode",
                "transaction.errorMessage",
                "transaction.riskReasonCode",
                "transaction.card.lastDigits",
                "transaction.card.brand",
                "transaction.card.type"
            ]
        },
        {
            "rel": "on_timeout",
            "uri": "http://localhost:8080/hosted_api/main/timeout/",
            "returnKeys": [
                "id",
                "transaction.confirmationNumber",
                "transaction.amount",
                "transaction.status",
                "transaction.errorCode",
                "transaction.errorMessage",
                "transaction.riskReasonCode",
                "transaction.card.lastDigits",
                "transaction.card.brand",
                "transaction.card.type"
            ]
        },
        {
            "rel": "on_hold",
            "uri": "http://localhost:8080/hosted_api/main/onhold/",
            "returnKeys": [
                "id",
                "transaction.confirmationNumber",
                "transaction.amount",
                "transaction.status",
                "transaction.errorCode",
                "transaction.errorMessage",
                "transaction.riskReasonCode",
                "transaction.card.lastDigits",
                "transaction.card.brand",
                "transaction.card.type"
            ]
        }
    ],
    "shoppingCart": [
        {
            "amount": "1000",
            "quantity": "1",
            "description": "Fast Order"
        }
    ]
}

以下是我得到的回应

代码语言:javascript
复制
{
  "error": {
    "code": 401,
    "message": "Not authorised"
  }
}

即使删除JSON代码,也会收到相同的错误。所以我假设我的证书是不正确的。

代码语言:javascript
复制
    <?php
header("Content-type:application/json");
header("Authorization:application/Basic Og==");

?>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-11-16 12:39:12

你提供的信息似乎是不正确的。PHP头中的授权似乎很短。可能有几个原因。

您应该对您的密钥使用Base64编码。这是在头中传递信息所需要的。

代码语言:javascript
复制
base64_encode($APIKey)

一旦您这样做,信息将被正确地传递进来。应该是这样的。

代码语言:javascript
复制
<?php
header("Content-type:application/json");
header("Authorization:application/Basic cTRlajZHRW5YWXJkUk9pS3JySEo6UEFBMGViNmU0M2Q2MmFkNTk5OTg");
?>

还有一件事。

我不确定您使用的是哪个端点,但请确保指向正确的位置。原因是,当您发送到错误的地方时,它无法验证密钥,系统将只是不知道您正在发送什么。

希望这能帮上忙!

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

https://stackoverflow.com/questions/40628480

复制
相关文章

相似问题

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