Skip to content

Instantly share code, notes, and snippets.

@jeffreyroberts
Created December 9, 2017 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffreyroberts/e71be43e524148ac6b506157d782d4ed to your computer and use it in GitHub Desktop.
Save jeffreyroberts/e71be43e524148ac6b506157d782d4ed to your computer and use it in GitHub Desktop.
Gist for Mohd
public function receive()
{
// https://developer.authorize.net/api/reference/features/webhooks.html#Event_Types_and_Payloads
}
public function createWebHook()
{
$omh_webhook_api_endpoint = 'https://{yourserver.com}/webhooks/receive';
$json = '
{
"name": "My New Webhook",
"url": "' . $omh_webhook_api_endpoint . '",
"eventTypes": [
"net.authorize.payment.authcapture.created",
"net.authorize.customer.created",
"net.authorize.customer.paymentProfile.created",
"net.authorize.customer.subscription.expiring"
],
"status": "active"
}
';
$response = $this->post_data('https://apitest.authorize.net/rest/v1/webhooks', $json);
$response_decoded = json_decode($response);
print_r($response_decoded); die();
}
public function post_data($url, $json)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
return $server_output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment