Last active
October 29, 2019 07:33
-
-
Save unicodeveloper/079a845d7d6d8fd95d1e9e0582b7b31b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
$payload = [ | |
'event' => 'customer.created', | |
'data' => [ | |
'full_name' => 'Mark Fish', | |
'email' => '[email protected]' | |
] | |
]; | |
$payloadJson = json_encode($payload); | |
$secret = env('EDEN_FIBRE_SECRET_KEY'); | |
$signature = hash_hmac('sha512', $payloadJson, $secret); | |
$curl = curl_init(); | |
curl_setopt_array($curl, array( | |
CURLOPT_URL => "https://edenbackend-staging.herokuapp.com/api/fibre/discount", | |
CURLOPT_RETURNTRANSFER => true, | |
CURLOPT_HTTPHEADER => [ | |
"X-Fibre-Signature: {$signature}", | |
"accept: application/json" | |
], | |
CURLOPT_POSTFIELDS => $payloadJson | |
)); | |
$response = curl_exec($curl); | |
$err = curl_error($curl); | |
if($err){ | |
// there was an error contacting the API | |
return response()->json([ | |
'status' => false, | |
'response' => $err, | |
], 500); | |
} | |
$tranx = json_decode($response, true); | |
return response()->json([ | |
'status' => true, | |
'response' => $tranx | |
], 200); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment