0

I'm trying to check if my webhook works, and will implement it. So that I can receive notification when charge is confirmed (charge:confirmed)

So I created php code to check my webhook,

 public function payment() {
        try {
        $user_agent = $_SERVER['HTTP_USER_AGENT'];
        $signature = hash_hmac('sha256',  $user_agent, '<SharedScreenKeyWebhook>');

        $headerName = 'x-cc-webhook-signature';

        $is_valid = hash_equals($signature, $headerName);
        

        if($is_valid) {
            return $is_valid;
        } else {
            return http_response_code(400);
        }
    } catch (\Exception $exception) {
        http_response_code(400);
        echo 'Error occured. ' . $exception->getMessage();
    }
 }

if I try to access the page, it will return me something like this

Status Code based on my php code

Status Code: 200 Means valid

This is where my Shared Secret key came from, for my webhook

enter image description here

However when I tested it on my end coinbase commerce by using send test

Coinbase Commerce Send Test Button

I am getting an error.

Please take note my shared secret key already matched to my coinbase commerce account. Also I decided not to use Coinbase Commerce wrapper for laravel framework. I just want to use typical php code to implement it

Please help me out, I was able to integrate coinbase commerce on my project however, I'm having a hard time to get callback from coinbase to monitor status of payment and update my database.

1 Answer 1

0

I was able to solve this,

Just in case you are here. Please create an API Endpoint on your project using POST

method with

X-Cc-Webhook-Signature equivalent to your Shared API Secret Key

User-Agent currently I'm using weipay-webhooks (as per documentation)

and submit your json data for checkout

On my end I used postman to test my api end point.

enter image description here

Your PHP Code must accept X-Cc-Webhook-Signature and automatically the coinbase commerce will use your webhook link when someone purchased.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.