Skip to content

Instantly share code, notes, and snippets.

@ProdigyView
Created January 7, 2019 03:59
Show Gist options
  • Save ProdigyView/40cadb73009d36b334833ffa2b8a757f to your computer and use it in GitHub Desktop.
Save ProdigyView/40cadb73009d36b334833ffa2b8a757f to your computer and use it in GitHub Desktop.
<?php
Router::post('/products/purchase', array('callback'=>function(Request $request){
$response = array();
//RETRIEVE Data From The Request
$data = $request->getRequestData('array');
if ($data) {
$data['type']='charge';
//Send The Message
$result = sendToPurchaseService($data);
//Create a response from the microservice
$response = array('status' => $result);
} else {
$response = array('status' => 'Unable To Send Email');
}
//Send response to client who accessed the API
sendResponse(json_encode($response));
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment