public function testAll() { // 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(); // Update customer profile $customerProfile->description = "New description"; $customerProfile->email = "*****@*****.**"; $response = $request->updateCustomerProfile($customerProfileId, $customerProfile); $this->assertTrue($response->isOk()); // Add payment profile. $paymentProfile = new AuthorizeNetPaymentProfile; $paymentProfile->customerType = "individual"; $paymentProfile->payment->creditCard->cardNumber = "4111111111111111"; $paymentProfile->payment->creditCard->expirationDate = "2015-10"; $response = $request->createCustomerPaymentProfile($customerProfileId, $paymentProfile); $this->assertTrue($response->isOk()); $paymentProfileId = $response->getPaymentProfileId(); // Update payment profile. $paymentProfile->payment->creditCard->cardNumber = "4111111111111111"; $paymentProfile->payment->creditCard->expirationDate = "2017-11"; $response = $request->updateCustomerPaymentProfile($customerProfileId,$paymentProfileId, $paymentProfile); $this->assertTrue($response->isOk()); // Add plugins_shipping address. $address = new AuthorizeNetAddress; $address->firstName = "john"; $address->lastName = "Doe"; $address->company = "John Doe Company"; $address->address = "1 Main Street"; $address->city = "Boston"; $address->state = "MA"; $address->zip = "02412"; $address->country = "USA"; $address->phoneNumber = "555-555-5555"; $address->faxNumber = "555-555-5556"; $response = $request->createCustomerShippingAddress($customerProfileId, $address); $this->assertTrue($response->isOk()); $customerAddressId = $response->getCustomerAddressId(); // Update plugins_shipping address. $address->address = "2 First Street"; $response = $request->updateCustomerShippingAddress($customerProfileId, $customerAddressId, $address); $this->assertTrue($response->isOk()); // Create Auth & Capture Transaction $transaction = new AuthorizeNetTransaction; $transaction->amount = "9.79"; $transaction->customerProfileId = $customerProfileId; $transaction->customerPaymentProfileId = $paymentProfileId; $transaction->customerShippingAddressId = $customerAddressId; $lineItem = new AuthorizeNetLineItem; $lineItem->itemId = "4"; $lineItem->name = "Cookies"; $lineItem->description = "Chocolate Chip"; $lineItem->quantity = "4"; $lineItem->unitPrice = "1.00"; $lineItem->taxable = "true"; $lineItem2 = new AuthorizeNetLineItem; $lineItem2->itemId = "4"; $lineItem2->name = "Cookies"; $lineItem2->description= "Peanut Butter"; $lineItem2->quantity = "4"; $lineItem2->unitPrice = "1.00"; $lineItem2->taxable = "true"; $transaction->lineItems[] = $lineItem; $transaction->lineItems[] = $lineItem2; $response = $request->createCustomerProfileTransaction("AuthCapture", $transaction); $this->assertTrue($response->isOk()); $transactionResponse = $response->getTransactionResponse(); $this->assertTrue($transactionResponse->approved); $transactionId = $transactionResponse->transaction_id; // Void the transaction $transaction = new AuthorizeNetTransaction; $transaction->transId = $transactionId; $response = $request->createCustomerProfileTransaction("Void", $transaction); $this->assertTrue($response->isOk()); $transactionResponse = $response->getTransactionResponse(); $this->assertTrue($transactionResponse->approved); // Delete Shipping Address $response = $request->deleteCustomerShippingAddress($customerProfileId, $customerAddressId); $this->assertTrue($response->isOk()); // Delete payment profile. $response = $request->deleteCustomerPaymentProfile($customerProfileId, $paymentProfileId); $this->assertTrue($response->isOk()); // Delete the profile id for future testing. $response = $request->deleteCustomerProfile($customerProfileId); $this->assertTrue($response->isOk()); }
function deleteShip($id) { $tmpcim = new AuthorizeNetCIM(); $response = $tmpcim->deleteCustomerShippingAddress($this->CIM_ID, $id); if ($response->isOk) { return false; } else { return $response->getErrorMessage(); } }