Introduction
Step 1
First, we need to insert the Coinbase Commerce API on our checkout/payments page, the below code should be placed at the top of our html file.
Checkout.html
use CoinbaseCommerce\ApiClient;
use CoinbaseCommerce\Resources\Charge;
?>
Now we will create the 'Charge' which will generate the link (hosted_url) to make payment.
Checkout.html
'My-Business-Name', 'description' => $fetch['product'] . " in " . $fetch['color'], 'local_price' => array ('amount' => $fetch['price'], 'currency' => 'GBP',), 'pricing_type' => 'fixed_price', 'metadata' => array ('customer_id' => $fetch['uid'],'customer_name' => $_SESSION['usr_name'],),'redirect_url' => 'https://www.my-site.co.uk/Checkout/payment_successful.html','cancel_url' => 'https://www.my-site.co.uk/Checkout/payment_cancelled.html',)));$headers = array();$headers[] = 'Content-Type: application/json';$headers[] = 'X-Cc-Api-Key: MY-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, true);$lets_see = $response['data']['hosted_url']; echo "Pay with Crypto?";?>