Created
December 9, 2017 12:39
-
-
Save jeffreyroberts/e71be43e524148ac6b506157d782d4ed to your computer and use it in GitHub Desktop.
Gist for Mohd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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