Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@unicodeveloper
Last active October 29, 2019 07:33
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 unicodeveloper/079a845d7d6d8fd95d1e9e0582b7b31b to your computer and use it in GitHub Desktop.
Save unicodeveloper/079a845d7d6d8fd95d1e9e0582b7b31b to your computer and use it in GitHub Desktop.
<?php
$payload = [
'event' => 'customer.created',
'data' => [
'full_name' => 'Mark Fish',
'email' => 'takeit@chairman.com'
]
];
$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