簡體   English   中英

PHP cURL請求無法平衡付款

[英]PHP cURL request failing to balanced payments

我正在嘗試向平衡支付的測試市場提交cURL請求,以模擬信用卡收費,但我繼續獲得“未授權”狀態,其中“需要身份驗證”作為category_code。 我已經能夠使用他們的文檔成功提交其他請求,所以我不太確定我做錯了什么。

我正按照這些步驟在測試市場中收取信用卡費用。

我只是在第1步創建一個帳戶來關聯卡令牌,並將其稱為URI。

//all of these parameters are supplied in the documentation

$url = 'https://api.balancedpayments.com/v1/marketplaces/TEST-MP3k9AuX9cW549vxxxxxxxxxxxxxxxx/accounts';
$post_arr[] = 'username=6d2896e8e9a911e2b3cd02xxxxxxxxxxxxxx:';
$post_arr[] = 'card_uri=/v1/marketplaces/TEST-MP24GBSQWq3M2nzdEtvvnHOf/cards/CC3DSm7qtThxh6DRe6lnYNVC';
$post = implode('&',$post_arr);

//make the request
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $post); 
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 3); // 3 seconds to connect
curl_setopt ($ch, CURLOPT_TIMEOUT, 10); // 10 seconds to complete
$output = curl_exec($ch);
curl_close($ch);

print_r($output);

這是輸出

{ "status": "Unauthorized", "category_code": "authentication-required", "category_type": "permission", "_uris": {}, "description": "Not permitted to perform show on cards. Your request id is OHMefab3f08ea6711e2950a026ba7xxxxxxxxxxxxx.", "request_id": "OHMefab3f08ea6711e2950a026baxxxxxxxxxxxx", "status_code": 401 }

但是,當我使用以下參數發出請求以對進行標記時 ,它可以正常工作。

$url = 'https://api.balancedpayments.com/v1/marketplaces/TEST-MP3k9AuX9cW549vxxxxxxxxxxxxx/cards';
$post_arr[] = '6d2896e8e9a911e2b3cd026bxxxxxxxxxxxxxx:';
$post_arr[] = 'expiration_month=12';
$post_arr[] = 'security_code=123';
$post_arr[] = 'card_number=5105105105105100';
$post_arr[] = 'expiration_year=2020';
$post_arr[] = 'category_type=request';
$post = implode('&',$post_arr);

這是輸出

{ "security_code_check": "true", "_type": "card", "hash": "b7250dd4b4827a88d5e4132b67f02916bce6f8e83d4ca0d779d1351b360ff6af", "brand": "MasterCard", "expiration_month": 12, "_uris": {}, "meta": {}, "last_four": "5100", "id": "CCSBORr685LWzmR62FSKZaw", "customer": null, "account": null, "postal_code_check": "true", "name": "None", "expiration_year": 2020, "created_at": "2013-07-11T21:01:53.245948Z", "uri": "/v1/marketplaces/TEST-MP3k9AuX9cW549vd1Ao5M0OW/cards/CCSBORr685LWzmR62FSKZaw", "card_type": "mastercard", "is_valid": true, "is_verified": true }

編輯 - 我仍然可能做錯了,但我認為文檔中可能存在錯誤

我從請求中刪除了'card_uri'參數,但它成功了。 簽出退回的JSON后,我注意到它是'cards_uri'而不是'card_uri'。 也許我仍然沒有正確地做某事,但當我將我的初始請求改為'cards_uri'時,它就成功了。

這是現在的輸出

{ "_type": "account", "_uris": { "holds_uri": { "_type": "page", "key": "holds" }, "bank_accounts_uri": { "_type": "page", "key": "bank_accounts" }, "refunds_uri": { "_type": "page", "key": "refunds" }, "customer_uri": { "_type": "customer", "key": "customer" }, "debits_uri": { "_type": "page", "key": "debits" }, "transactions_uri": { "_type": "page", "key": "transactions" }, "credits_uri": { "_type": "page", "key": "credits" }, "cards_uri": { "_type": "page", "key": "cards" } }, "bank_accounts_uri": "/v1/marketplaces/TEST-MP24GBSQWq3M2nzdEtvvnHOf/accounts/AC2A9aCbuzUWalMNX7JXbhrk/bank_accounts", "meta": {}, "transactions_uri": "/v1/marketplaces/TEST-MP24GBSQWq3M2nzdEtvvnHOf/accounts/AC2A9aCbuzUWalMNX7JXbhrk/transactions", "email_address": null, "id": "AC2A9aCbuzUWalMNX7JXbhrk", "credits_uri": "/v1/marketplaces/TEST-MP24GBSQWq3M2nzdEtvvnHOf/accounts/AC2A9aCbuzUWalMNX7JXbhrk/credits", "cards_uri": "/v1/marketplaces/TEST-MP24GBSQWq3M2nzdEtvvnHOf/accounts/AC2A9aCbuzUWalMNX7JXbhrk/cards", "holds_uri": "/v1/marketplaces/TEST-MP24GBSQWq3M2nzdEtvvnHOf/accounts/AC2A9aCbuzUWalMNX7JXbhrk/holds", "name": null, "roles": [], "created_at": "2013-07-11T21:24:55.567233Z", "uri": "/v1/marketplaces/TEST-MP24GBSQWq3M2nzdEtvvnHOf/accounts/AC2A9aCbuzUWalMNX7JXbhrk", "refunds_uri": "/v1/marketplaces/TEST-MP24GBSQWq3M2nzdEtvvnHOf/accounts/AC2A9aCbuzUWalMNX7JXbhrk/refunds", "customer_uri": "/v1/customers/AC2A9aCbuzUWalMNX7JXbhrk", "debits_uri": "/v1/marketplaces/TEST-MP24GBSQWq3M2nzdEtvvnHOf/accounts/AC2A9aCbuzUWalMNX7JXbhrk/debits" } 

你沒有進行身份驗證。 嘗試添加

curl_setopt('6d2896e8e9a911e2b3cd026ba7f8ec28:', CURLOPT_USERPWD)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM