我想使用“付款”的Shopify API

时间:2020-07-31 05:06:46

标签: api shopify

感谢您浏览。

我要使用此API的“创建新付款”。

https://shopify.dev/docs/admin-api/rest/reference/sales-channels/payment?api[version]=2020-07

但是,我在“ POSTMAN”上获得了HTML。

详细信息如下。


网址

https://XXXXXXXXXXXX.myshopify.com/admin/api/2020-07/checkouts/0076fd26194e9a11e1ad2fef27e6d369/payments.json

身体

{
  "payment": {
    "request_details": {
      "ip_address": "114.179.82.76",
      "accept_language": "en-US,en;q=0.8,fr;q=0.6",
      "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36"
    },
    "amount": "11000.00",    
    "session_id": "east-a2fe97e4239a2141004a2586da22babd",
    "unique_token": "7d80c851451dcbe1d36af87c55c573a3"
  }
}

结果

<html>
<body>
    <noscript>
        <a
            href="https://accounts.shopify.com/oauth/authorize?client_id=7ee65a63608843c577db8b23c4d7316ea0a01bd2f7594f8a9c06ea668c1b775c&amp;destination_uuid=194909e9-a17a-40dd-bfb7-61a6a8739c9c&amp;nonce=28f174d1a0c3dcad2ee819c1ab6772eb&amp;prompt=merge&amp;redirect_uri=https%3A%2F%2Fdrupal-integration.myshopify.com%2Fadmin%2Fauth%2Fidentity%2Fcallback&amp;response_type=code&amp;scope=email%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fdestinations.readonly%20openid%20profile%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.collaborator-relationships.readonly%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fbanking.manage&amp;state=0ed03b89f02f335f13bdc36f4813a822&amp;ui_locales=en&amp;ux=shop">Continue</a>
    </noscript>
    <script type="text/javascript" defer>
        window.location = "https:\/\/accounts.shopify.com\/oauth\/authorize?client_id=7ee65a63608843c577db8b23c4d7316ea0a01bd2f7594f8a9c06ea668c1b775c\u0026destination_uuid=194909e9-a17a-40dd-bfb7-61a6a8739c9c\u0026nonce=28f174d1a0c3dcad2ee819c1ab6772eb\u0026prompt=merge\u0026redirect_uri=https%3A%2F%2Fdrupal-integration.myshopify.com%2Fadmin%2Fauth%2Fidentity%2Fcallback\u0026response_type=code\u0026scope=email%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fdestinations.readonly%20openid%20profile%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.collaborator-relationships.readonly%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fbanking.manage\u0026state=0ed03b89f02f335f13bdc36f4813a822\u0026ui_locales=en\u0026ux=shop";
    </script>
</body>
</html>

enter image description here


我不知道我在做什么错。但是,我认为以下情况可疑。

我在URL“ 0076fd26194e9a11e1ad2fef27e6d369”上使用了令牌。这是“ web_url”。我在“创建结帐”处获得了令牌。

https://shopify.dev/docs/admin-api/rest/reference/sales-channels/checkout?api[version]=2020-07#create-2020-07

我在主体上使用了“ session_id”的参数。我在“在卡库中存储信用卡”中得到它。

https://shopify.dev/docs/admin-api/rest/reference/sales-channels/payment?api[version]=2020-07#create_payment_session-2020-07

我在身上使用了“ unique_token”参数。我是这样子的。

I want to use Shopify API of "payment" but I didn't understand parameter of "unique token"

对不起,我的英语不好,但我需要帮助。

1 个答案:

答案 0 :(得分:2)

您的API调用在API身份验证步骤遇到问题。当您通过POST请求发送cookie时,会出现此问题。

Shopify documentation

Shopify阻止具有cookie的HTTP Basic Auth POST请求, 这可能会导致POST调用失败。如果您的POST呼叫失败,那么您 应该尝试清除您的Cookie。

要清除cookie,请使用Postman应用程序中的cookie管理器,可使用位于“发送”和“保存”按钮下方的“ cookies”按钮访问它。

Clearing Cookies in Postman

对于发送身份验证信息,Shopify使用基本身份验证。您可以在Shopify Docs for Authetication上了解有关生成凭据和发送请求的更多信息。