在PHP中集成Coinbase商务

在PHP中集成Coinbase商务,php,curl,coinbase-api,Php,Curl,Coinbase Api,我想在我的一个web应用程序中集成Coinbase Commerce API。我已经参考了这个链接,并在本地服务器上创建了一个演示。我成功地获得了以下输出 屏幕下 现在,我想知道在得到最后一个屏幕后,它给了我地址如何处理该代码。我是否需要在任何特定的应用程序中打开它,或者我必须在代码中使用它。如果我需要在代码中使用,请提供示例代码 此外,我还尝试使用以下代码发出“创建费用”的curl请求,但没有得到任何响应 $metadata = array( 'customer_id' => '12

我想在我的一个web应用程序中集成Coinbase Commerce API。我已经参考了这个链接,并在本地服务器上创建了一个演示。我成功地获得了以下输出

屏幕下

现在,我想知道在得到最后一个屏幕后,它给了我地址如何处理该代码。我是否需要在任何特定的应用程序中打开它,或者我必须在代码中使用它。如果我需要在代码中使用,请提供示例代码

此外,我还尝试使用以下代码发出“创建费用”的curl请求,但没有得到任何响应

$metadata = array(
'customer_id' => '123456',
'customer_name' => 'adarsh bhatt'
);
   $request_body = array(
    'X-CC-Api-Key' => 'd59xxxxxxxxxxxxxxb8',
    'X-CC-Version' => '2018-03-22',
    'pricing_type' => 'fixed_price',
    'name' => 'Adarsh',
    'description' => ' This is test donation',
     'local_price' => array(
    'amount' => '100.00',
    'currency' => 'USD'
   ),
    'metadata' => $metadata
);
$req = curl_init('https://api.commerce.coinbase.com/charges');
curl_setopt($req, CURLOPT_RETURNTRANSFER, false);    
curl_setopt($req, CURLOPT_POST, true);
curl_setopt($req, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($req, CURLOPT_HTTPHEADER, array('Content-Type:   application/json', 'Content-Length: ' . strlen(json_encode($request_body))));
curl_setopt($req, CURLOPT_POSTFIELDS, http_build_query($request_body));
$respCode = curl_getinfo($req, CURLINFO_HTTP_CODE);
$resp = json_decode(curl_exec($req), true);
curl_close($req);
echo '<pre>';
print_r($output);
exit;
$metadata=数组(
'客户id'=>'123456',
“客户名称”=>“adarsh bhatt”
);
$request\u body=数组(
“X-CC-Api-Key”=>“D59XXXXXXXXXXXXXXXXB8”,
“X-CC-Version”=>“2018-03-22”,
'定价类型'=>'固定价格',
'name'=>'Adarsh',
'description'=>'这是测试捐赠',
“本地价格”=>数组(
“金额”=>“100.00”,
“货币”=>“美元”
),
“元数据”=>$metadata
);
$req=curl\u init('https://api.commerce.coinbase.com/charges');
curl_setopt($req,CURLOPT_RETURNTRANSFER,false);
curl_setopt($req,CURLOPT_POST,true);
curl_setopt($req,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($req,CURLOPT_HTTPHEADER,array('Content-Type:application/json','Content-Length:'。strlen(json_encode($request_body)));
curl_setopt($req,CURLOPT_POSTFIELDS,http_build_query($request_body));
$respCode=curl\u getinfo($req,CURLINFO\u HTTP\u代码);
$resp=json_decode(curl_exec($req),true);
卷曲关闭($req);
回声';
打印(输出);
出口

您可以这样尝试。这是我的工作

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.commerce.coinbase.com/charges/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$post = array(
    "name" => "E currency exchange",
    "description" => "Exchange for Whatever",
    "local_price" => array(
        'amount' => 'AMOUNT',
        'currency' => 'USD'
    ),
    "pricing_type" => "fixed_price",
    "metadata" => array(
        'customer_id' => 'customerID',
        'name' => 'ANY NAME'
    )
);

$post = json_encode($post);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_POST, 1);

$headers = array();
$headers[] = "Content-Type: application/json";
$headers[] = "X-Cc-Api-Key: YOUR-API-KEY";
$headers[] = "X-Cc-Version: 2018-03-22";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
curl_close ($ch);
$response = json_decode($result);
return $response->data->hosted_url;

你可以这样试试。这是我的工作

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.commerce.coinbase.com/charges/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$post = array(
    "name" => "E currency exchange",
    "description" => "Exchange for Whatever",
    "local_price" => array(
        'amount' => 'AMOUNT',
        'currency' => 'USD'
    ),
    "pricing_type" => "fixed_price",
    "metadata" => array(
        'customer_id' => 'customerID',
        'name' => 'ANY NAME'
    )
);

$post = json_encode($post);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_POST, 1);

$headers = array();
$headers[] = "Content-Type: application/json";
$headers[] = "X-Cc-Api-Key: YOUR-API-KEY";
$headers[] = "X-Cc-Version: 2018-03-22";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
curl_close ($ch);
$response = json_decode($result);
return $response->data->hosted_url;

以下应该是创建费用并返回托管URL的有效请求:

use CoinbaseCommerce\Resources\Charge;
use CoinbaseCommerce\ApiClient;

ApiClient::init('PUT_YOUR_API_KEY');


$chargeData = [
    'name' => 'The Sovereign Individual',
    'description' => 'Mastering the Transition to the Information Age',
    'local_price' => [
        'amount' => '100.00',
        'currency' => 'USD'
    ],
    'pricing_type' => 'fixed_price'
];
$chargeObj = Charge::create($chargeData);

var_dump($chargeObj);
var_dump($chargeObj->hosted_url);

以下应该是创建费用并返回托管URL的有效请求:

use CoinbaseCommerce\Resources\Charge;
use CoinbaseCommerce\ApiClient;

ApiClient::init('PUT_YOUR_API_KEY');


$chargeData = [
    'name' => 'The Sovereign Individual',
    'description' => 'Mastering the Transition to the Information Age',
    'local_price' => [
        'amount' => '100.00',
        'currency' => 'USD'
    ],
    'pricing_type' => 'fixed_price'
];
$chargeObj = Charge::create($chargeData);

var_dump($chargeObj);
var_dump($chargeObj->hosted_url);

您好,您可以将php sdk用于coinbase commerce

作曲家需要coinbase/coinbase商务


您好,您可以将php sdk用于coinbase commerce

作曲家需要coinbase/coinbase商务