Webhook Product Setup

            1. Create Secret key for the Webhook

            This secret key is to verify that the webhook data comes from our system and not from an unknown party.

            Make very sure to keep this key secure and do NOT share it with anybody.

            When you click 'Generate Key' the key will change, When you save the new key you must also change it on your side.



            2. Setup Webhook url

            This is the URL where our system will send the webhook data

            You can test webhook by clicking on "Test Webhook"



            Sample code to handle webhook is given below

            $kyvioSecretKey = 'YourKEY';
            $response = [
            'success' => false,
            'message' => 'not a valid request'
            ];
            if(!empty($_SERVER['HTTP_AUTHORIZATION']) && $_SERVER['HTTP_AUTHORIZATION'] == 'kyvio_secret '.$kyvioSecretKey){ // Check if request coming from kyvio
            // Get webhook JSON
            $webhookData = json_decode(file_get_contents("php://input"), true);
            $response['success'] = true;
            $response['message'] = 'Webhook handled';
            if(!empty($webhookData)){
            $integrationType = $webhookData['integration_type'];
            switch ($integrationType) {
            case 'paypal':
            $email = $webhookData['customer_email']; // Handle everything here
            break;
            case 'clickbank':
            $customer = $webhookData['customer'];
            $billing = $customer['billing'];
            $email = isset($billing['email']) ? $billing['email'] : ''; // Handle everything here

            break;
            case 'thrivecart':
            $email = $webhookData['customer']['email']; // Handle everything here

            break;
            case 'jvzoo':
            $email = $webhookData['ccustemail']; // Handle everything here
            break;
            case 'zaxaa':
            $email = !empty($webhookData['cust_paypal_email']) ? $webhookData['cust_paypal_email'] : ''; // Handle everything here
            break;
            case 'wsoproadvanced':
            $email = $webhookData['WP_BUYER_EMAIL']; // Handle everything here
            break;
            case 'paddle':
            $email = $webhookData['email']; // Handle everything here
            break;
            case 'digistore':
            $email = $webhookData['email']; // Handle everything here
            break;
            case 'stripe':
            $email = $webhookData['email']; // Handle everything here
            break;
            default:
            $response['success'] = false;
            $response['message'] = 'Can\'t find provider';
            break;
            }
            }
            }
            echo json_encode($response);
            exit();



            Helpful?  
            Help us to make this article better
            0 0