public function createProfile($profile) { $this->loadCreds(); $request = new AuthorizeNetCIM(); $profile = $request->createCustomerProfile($profile)->xml->profile->customerProfileID; return $profile; }
/** * Creates the customer profile. * * @param array $data The data to us to create the profile. * * @return bool */ public function create(array $data) { if (!($customer = Arr::get($data, 'customer'))) { return false; } if (!($contact = Arr::get($data, 'contact'))) { return false; } $request = new AuthorizeNetCIM(); $profile = new AuthorizeNetCustomer(); $profile->merchantCustomerId = $customer->id; $profile->email = $contact->email; $response = $request->createCustomerProfile($profile); if (!$response->isOk()) { preg_match('/A duplicate record with ID ([0-9]+) already exists./i', $response->getMessageText(), $matches); if (isset($matches[1])) { return $matches[1]; } Log::error('Unable to create Authorize.net customer profile.'); return false; } return $response->getCustomerProfileId(); }
public function testGetCustomerProfileIds() { // Create new customer profile $request = new AuthorizeNetCIM; $customerProfile = new AuthorizeNetCustomer; $customerProfile->description = "Description of customer"; $customerProfile->merchantCustomerId = time().rand(1,10); $customerProfile->email = "*****@*****.**"; $response = $request->createCustomerProfile($customerProfile); $this->assertTrue($response->isOk()); $customerProfileId = $response->getCustomerProfileId(); $response = $request->getCustomerProfileIds(); $this->assertTrue($response->isOk()); $this->assertTrue(in_array($customerProfileId, $response->getCustomerProfileIds())); }
$paymentProfile = new AuthorizeNetPaymentProfile(); $paymentProfile->payment->creditCard->cardNumber = $subCardnumber; $paymentProfile->payment->creditCard->expirationDate = $subCardExpDate; $paymentProfile->billTo->firstName = $subFName; $paymentProfile->billTo->lastName = $subLName; $paymentProfile->billTo->address = $subAddress; $paymentProfile->billTo->city = $subCity; $paymentProfile->billTo->state = $subState; $paymentProfile->billTo->zip = $subZip; // creates the Authorize.net customer profile $customerProfile = new AuthorizeNetCustomer(); $customerProfile->email = $fldEmail; // fldEmail initiated in subscribe.php $customerProfile->paymentProfiles[] = $paymentProfile; $request = new AuthorizeNetCIM(); $response = $request->createCustomerProfile($customerProfile); if (ANet_Response_getResultCode($response) == 'Error') { $e = ANet_Response_getMessageCode($response) . ': ' . ANet_Response_getMessageText($response); throw new Exception($e); } // gets the customer profile ID and payment profile ID from the response $customerProfileId = $response->getCustomerProfileId(); $paymentProfileId = $response->getCustomerPaymentProfileIds(); // updates the database with the new Authorize.net customer profile ID $tbl = TBL_COLLEGE_COACH_REGISTER; $data = array('fldANetCustomerProfileId' => $customerProfileId); $where = 'fldId=' . $fldId; $affectedRows = $db1->updateRec($tbl, $data, $where); } else { // gets all existing payment profiles associated with the customer profile $request = new AuthorizeNetCIM();
public function testGetCustomerProfileIds() { // A valid response should be received when a merchant has zero customer profiles... // Hence, first testing using specific credentials for a merchant which has zero customer profiles... $request = new AuthorizeNetCIM('5KP3u95bQpv', '4Ktq966gC55GAX7S'); $response = $request->getCustomerProfileIds(); // Create new customer profile $request = new AuthorizeNetCIM(); $customerProfile = new AuthorizeNetCustomer(); $customerProfile->description = "Description of customer"; $customerProfile->merchantCustomerId = time() . rand(1, 100); $customerProfile->email = "*****@*****.**"; $response = $request->createCustomerProfile($customerProfile); $this->assertTrue($response->isOk()); $customerProfileId = $response->getCustomerProfileId(); $response = $request->getCustomerProfileIds(); $this->assertTrue($response->isOk()); $this->assertTrue(in_array($customerProfileId, $response->getCustomerProfileIds())); }