Skip to content

Instantly share code, notes, and snippets.

@ProdigyView
Created January 6, 2019 22:17
Show Gist options
  • Save ProdigyView/e9a7e252edf9a32ca18bda8cd32d7b77 to your computer and use it in GitHub Desktop.
Save ProdigyView/e9a7e252edf9a32ca18bda8cd32d7b77 to your computer and use it in GitHub Desktop.
<?php
if (isset($data['token']) && AuthBearer::hasAccess($data['token'], $type)) {
if($type == 'charge' && checkNounce($data['nounce'], $nounces)) {
$id = charge($data['amount'], $data['nounce'], array('product' => 'Shoes'), $charges);
$response = array('status' => 'success', 'message' => $id);
}else if($type == 'charge') {
$response = array('status' => 'error', 'message' => 'Invalid Nounce');
} else if($type == 'refund' && refund($data['id'], $charges)) {
$response = array('status' => 'success', 'message' => 'Refund Successful');
} else if($type == 'refund') {
$response = array('status' => 'error', 'message' => 'Unable To Peform Refund');
}
} else{
$response = array('status' => 'error', 'message' => 'Invalid Token On Purchase');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment