ini_set('display_errors', 1); //include the config and the gocoin api require_once __DIR__ . '/../includes/config.php'; require_once __DIR__ . '/../includes/functions.php'; require_once __DIR__ . '/../../src/GoCoinAdmin.php'; //pick a token $token = $TOKENS['full_access']; //echo an HTML block echo '<html><head><title>GoCoin Admin Merchant User Test</title></head><body>' . "\n"; echo '<h3 style="color:blue">Merchant Users</h3>'; //get a list of all merchant users $users = GoCoin::getMerchantUsers($token, MERCHANT_ID); if (!empty($users)) { foreach ($users as $key => $user) { showObject($user); echo '<hr/>' . "\n"; //break; } //echo '<div style="color:#aa0000">NOTE: There are ' . (sizeof($users) - 1) . ' other merchant users not shown</div>'; } //add a merchant user echo '<h3 style="color:blue">Add Merchant User</h3>'; $add = GoCoinAdmin::addMerchantUser($token, MERCHANT_ID, MERCHANT_USER_ID); var_dump($add); //remove a merchant user echo '<h3 style="color:blue">Delete Merchant User</h3>'; $del = GoCoinAdmin::deleteMerchantUser($token, MERCHANT_ID, MERCHANT_USER_ID); var_dump($del); //close our HTML block echo '</body></html>' . "\n";
showObject($u); echo '<hr/>' . "\n"; break; } echo '<div style="color:#aa0000">NOTE: There are ' . (sizeof($users) - 1) . ' other users not shown</div>'; } //create user tests $CREATE = FALSE; $DELETE_ID = ''; if ($CREATE) { //create an array of fields to create a user $creates = array('email' => '*****@*****.**', 'first_name' => 'Foo', 'last_name' => 'Bar', 'password' => 'password', 'password_confirmation' => 'password'); //create the user $created = GoCoinAdmin::createUser($token, $creates); //show the created user echo '<h3 style="color:blue">Created User</h3>'; showObject($created); //get the id to delete $DELETE_ID = $created->id; } if (!empty($DELETE_ID)) { //delete the user $deleted = GoCoinAdmin::deleteUser($token, $DELETE_ID); if ($deleted) { echo '<div style="color:#008800">User deleted successfully!</div>'; } else { echo '<div style="color:#aa0000">Deletion failed!</div>'; } } //close our HTML block echo '</body></html>' . "\n";
//echo '<hr/>' . "\n"; break; } echo '<div style="color:#aa0000">NOTE: There are ' . (sizeof($merchants) - 1) . ' other merchants not shown</div>'; } //create merchant tests $CREATE = FALSE; $DELETE_ID = ''; if ($CREATE) { //create an array of fields to create a merchant $create = array('name' => 'Another Test Merchant for Aaron'); //create the merchant $created = GoCoinAdmin::createMerchant($token, $create); //show the created merchant echo '<h3 style="color:blue">Created Merchant</h3>'; showObject($created); //get the id to delete //NOTE: in the test I ran, I did not get back an id here //$DELETE_ID = $created -> id; } if (!empty($DELETE_ID)) { //delete the merchant $deleted = GoCoinAdmin::deleteMerchant($token, $DELETE_ID); if ($deleted) { echo '<div style="color:#008800">Merchant deleted successfully!</div>'; } else { echo '<div style="color:#aa0000">Deletion failed!</div>'; } } //close our HTML block echo '</body></html>' . "\n";