$username = '******'; $password = '******'; $API = new ChargeOverAPI($url, $authmode, $username, $password); $Customer = new ChargeOverAPI_Object_Customer(); $Customer->setEmail('*****@*****.**'); $Customer->setCompanyName('Test Company Name'); $Customer->setBillAddr1('Test bill adderess 1'); $Customer->setBillPostCode('48858'); print_r($Customer); print "\n\n\n"; print 'email: ' . $Customer->getEmail() . "\n"; print 'company name: ' . $Customer->getCompanyName() . "\n"; print 'bill addr 1: ' . $Customer->getBillAddr1() . "\n"; print 'bill post code: ' . $Customer->getBillPostCode() . "\n"; print "\n\n\n"; print 'method for "company_name": ' . ChargeOverAPI_Object::transformFieldToMethod('company_name') . "\n"; print 'method for "email": ' . ChargeOverAPI_Object::transformFieldToMethod('email') . "\n"; print 'method for "bill_addr1": ' . ChargeOverAPI_Object::transformFieldToMethod('bill_addr1') . "\n"; exit; $resp = $API->create($Customer); if (!$API->isError($resp)) { $customer_id = $resp->response->id; print 'SUCCESS! Customer # is: ' . $customer_id; } else { print 'error saving customer via API'; print "\n\n\n\n"; print $API->lastRequest(); print "\n\n\n\n"; print $API->lastResponse(); print "\n\n\n\n"; }
public function __call($name, $args) { if (substr($name, 0, 3) == 'set') { $field = ChargeOverAPI_Object::transformMethodToField($name); //$this->_arr[$field] = current($args); $this->{$field} = current($args); return true; } else { if (substr($name, 0, 3) == 'get') { $field = ChargeOverAPI_Object::transformMethodToField($name); //print('transformed [' . $name . ' to ' . $field . ']' . "\n"); if (array_key_exists(0, $args) and is_numeric($args[0])) { //if (!empty($this->_arr[$field][$args[0]])) if (!empty($this->{$field}[$args[0]])) { return $this->{$field}[$args[0]]; //return $this->_arr[$field][$args[0]]; } return null; } else { if (property_exists($this, $field)) { return $this->{$field}; //return $this->_arr[$field]; } } return null; } else { if (substr($name, 0, 3) == 'add') { $field = ChargeOverAPI_Object::transformMethodToField($name); //if (!isset($this->_arr[$field])) if (!isset($this->{$field})) { //$this->_arr[$field] = array(); $this->{$field} = array(); } $Obj = current($args); //$this->_arr[$field][] = $Obj; array_push($this->{$field}, $Obj); } } } }