<?php 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/GoCoin.php'; //pick a token $token = $TOKENS['full_access']; //echo an HTML block echo '<html><head><title>GoCoin Merchant Test</title></head><body>' . "\n"; echo '<h3 style="color:blue">Merchant</h3>'; //get a merchant $merchant = GoCoin::getMerchant($token, MERCHANT_ID); showObject($merchant, FALSE); //update merchant tests $UPDATE = FALSE; if ($UPDATE) { //create an array of fields to update, NOTE: id is required $name = $merchant->name; $updates = array('id' => $merchant->id, 'name' => $name . ' (UPDATED)'); //update the merchant $updated = GoCoin::updateMerchant($token, $updates); //show the updates echo '<h3 style="color:blue">Updated Merchant</h3>'; showObject($updated, FALSE); //reset the name $updates['name'] = $name; GoCoin::updateMerchant($token, $updates); } echo '<hr/>' . "\n";
public function testUpdateMerchant() { if (!$this->doTest(__FUNCTION__)) { return; } //perform assertion $this->assertEquals(GoCoin::getApiMode(), 'test'); $this->assertNotEmpty(TOKEN); //get a merchant $merchant = GoCoin::getMerchant(TOKEN, MERCHANT_ID); $this->assertEquals($merchant->id, MERCHANT_ID); //create an array of fields to update, NOTE: id is required $name = $merchant->name; $updates = array('id' => $merchant->id, 'name' => $name . ' (UPDATED)'); //update the merchant $updated = GoCoin::updateMerchant(TOKEN, $updates); //make sure we got a successful response back $this->assertTrue(property_exists($updated, 'name')); //show the results echo '[DEBUG]: Updated name: ' . $updated->name . "\n"; //perform assertion $this->assertEquals($updated->name, $name . ' (UPDATED)'); //reset the name $updates['name'] = $name; $updated = GoCoin::updateMerchant(TOKEN, $updates); //make sure we got a successful response back $this->assertTrue(property_exists($updated, 'name')); //show the results echo '[DEBUG]: Reset name: ' . $updated->name . "\n"; //perform assertion $this->assertEquals($updated->name, $name); echo '[DEBUG]: SUCCESS: ' . "\n"; }