Serving Placer, Sacramento, and El Dorado counties & beyond

Serving Placer, Sacramento, and El Dorado counties & beyond

fbgoogle1linkedin white

fbgoogle1linkedin white

setName(\SampleCodeConstants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); // Create a Customer Profile Request // 1. (Optionally) create a Payment Profile // 2. (Optionally) create a Shipping Profile // 3. Create a Customer Profile (or specify an existing profile) // 4. Submit a CreateCustomerProfile Request // 5. Validate Profile ID returned // Set credit card information for payment profile $creditCard = new AnetAPI\CreditCardType(); $creditCard->setCardNumber("4242424242424242"); $creditCard->setExpirationDate("2038-12"); $creditCard->setCardCode("142"); $paymentCreditCard = new AnetAPI\PaymentType(); $paymentCreditCard->setCreditCard($creditCard); // Create the Bill To info for new payment type $billTo = new AnetAPI\CustomerAddressType(); $billTo->setFirstName("Ellen"); $billTo->setLastName("Johnson"); $billTo->setCompany("Souveniropolis"); $billTo->setAddress("14 Main Street"); $billTo->setCity("Pecan Springs"); $billTo->setState("TX"); $billTo->setZip("44628"); $billTo->setCountry("USA"); $billTo->setPhoneNumber("888-888-8888"); $billTo->setfaxNumber("999-999-9999"); // Create a customer shipping address $customerShippingAddress = new AnetAPI\CustomerAddressType(); $customerShippingAddress->setFirstName("James"); $customerShippingAddress->setLastName("White"); $customerShippingAddress->setCompany("Addresses R Us"); $customerShippingAddress->setAddress(rand() . " North Spring Street"); $customerShippingAddress->setCity("Toms River"); $customerShippingAddress->setState("NJ"); $customerShippingAddress->setZip("08753"); $customerShippingAddress->setCountry("USA"); $customerShippingAddress->setPhoneNumber("888-888-8888"); $customerShippingAddress->setFaxNumber("999-999-9999"); // Create an array of any shipping addresses $shippingProfiles[] = $customerShippingAddress; // Create a new CustomerPaymentProfile object $paymentProfile = new AnetAPI\CustomerPaymentProfileType(); $paymentProfile->setCustomerType('individual'); $paymentProfile->setBillTo($billTo); $paymentProfile->setPayment($paymentCreditCard); $paymentProfiles[] = $paymentProfile; // Create a new CustomerProfileType and add the payment profile object $customerProfile = new AnetAPI\CustomerProfileType(); $customerProfile->setDescription("Customer 2 Test PHP"); $customerProfile->setMerchantCustomerId("M_" . time()); $customerProfile->setEmail($email); $customerProfile->setpaymentProfiles($paymentProfiles); $customerProfile->setShipToList($shippingProfiles); // Assemble the complete transaction request $request = new AnetAPI\CreateCustomerProfileRequest(); $request->setMerchantAuthentication($merchantAuthentication); $request->setRefId($refId); $request->setProfile($customerProfile); // Create the controller and get the response $controller = new AnetController\CreateCustomerProfileController($request); $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) { echo "Succesfully created customer profile : " . $response->getCustomerProfileId() . "\n"; $paymentProfiles = $response->getCustomerPaymentProfileIdList(); echo "SUCCESS: PAYMENT PROFILE ID : " . $paymentProfiles[0] . "\n"; } else { echo "ERROR : Invalid response\n"; $errorMessages = $response->getMessages()->getMessage(); echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; } return $response; } if (!defined('DONT_RUN_SAMPLES')) { createCustomerProfile("This email address is being protected from spambots. You need JavaScript enabled to view it."); }

Remote Support | Contact Us | Privacy Policy | Web solutions by CitrusKiwi  |  Sitemap

Copyright © 2010 - 2020. Gravity IT Solutions. All rights reserved. | Staff login