I'm using coinbase commerce api. What I'm trying to achieve is creating a checkout from my laravel project and passing the checkout id to my blade template to create a payment button. The checkout API is working fine and generates a new checkout ID for every purchase but when the view is loaded it returns 403 when this URL is hit https://commerce.coinbase.com/embed/checkout/a12c0cc4-9601-4e6e-bfe9-355d1b?buttonId=bwc-1a182222c583b&version=201807&origin=https%3A%2F%2Fwww.mysite.com
I'm also sharing my code here.
private function createCoinbaseCheckout($amount,$name,$description){
$client = new \GuzzleHttp\Client();
$res = $client->request('POST', 'https://api.commerce.coinbase.com/checkouts', [
'body' => '{"requested_info":[],"local_price":{"0":"P","1":"r","2":"i","3":"c","4":"e","5":" ","6":"i","7":"n","8":" ","9":"l","10":"o","11":"c","12":"a","13":"l","14":" ","15":"f","16":"i","17":"a","18":"t","19":" ","20":"c","21":"u","22":"r","23":"r","24":"e","25":"n","26":"c","27":"y","amount":'.$amount.',"currency":"USD"},"name":"'.$name.'","description":"'.$description.'","pricing_type":"fixed_price"}',
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'X-CC-Api-Key' => config('services.coinbase.api_key'),
],
]);
if($res->getStatusCode() == 201){
$response_data = json_decode($res->getBody()->getContents());
return $response_data->data->id;
}
return null;
}
This method creates checkout and returns checkout IDs. After receiving ID I pass it to the view
.
<div>
<a class="buy-with-crypto" href="https://commerce.coinbase.com/checkout/{{ $checkout_id }}">Buy with Crypto</a>
<script src="https://commerce.coinbase.com/v1/checkout.js"></script>
</div>
This is an accept payment button code when the page is loaded it sends a request to the URL mentioned above, on success it returns 200 when I'm trying but on the other hand when my client tries on his PC it returns 403. Literally I'm totally blank on what the issue is. Please help me out.