diff --git a/doc/AIM.markdown b/doc/AIM.markdown index 2ae1541..f64b942 100644 --- a/doc/AIM.markdown +++ b/doc/AIM.markdown @@ -12,32 +12,45 @@ to the results of the transaction. Including the SDK ----------------- - +``` require_once 'anet_php_sdk/AuthorizeNet.php'; +``` Setting Merchant Credentials ---------------------------- The easiest way to set credentials is to define constants which the SDK uses: + +``` define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN"); define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY"); +``` You can also set credentials manually per request like so: +``` $sale = new AuthorizeNetAIM("YOUR_API_LOGIN_ID","YOUR_TRANSACTION_KEY"); - +``` Setting the Transaction Post Location ------------------------------------- To post transactions to the live Authorize.Net gateway: + +``` define("AUTHORIZENET_SANDBOX", false); +``` To post transactions to the Authorize.Net test server: + +``` define("AUTHORIZENET_SANDBOX", true); +``` You can also set the location manually per request: -$sale->setSandbox(false); +``` +$sale->setSandbox(false); +``` Setting Fields -------------- @@ -47,17 +60,22 @@ allows you to set these fields in a few different ways depending on your preference. Note: to make things easier on the developer, the "x_" prefix attached to each -field in the AIM API has been removed. Thus, instead of setting $sale->x_card_num, -set $sale->card_num instead. +field in the AIM API has been removed. Thus, instead of setting `$sale->x_card_num`, +set `$sale->card_num` instead. 1.) By Setting Fields Directly: + +``` $sale = new AuthorizeNetAIM; $sale->amount = "1999.99"; $sale->card_num = '6011000000000012'; $sale->exp_date = '04/15'; $response = $sale->authorizeAndCapture(); +``` 2.) By Setting Multiple Fields at Once: + +``` $sale = new AuthorizeNetAIM; $sale->setFields( array( @@ -66,12 +84,15 @@ $sale->setFields( 'exp_date' => '0415' ) ); +``` 3.) By Setting Special Items To add line items or set custom fields use the respective functions: Line Items: + +``` $sale->addLineItem( 'item1', // Item Id 'Golf tees', // Item Name @@ -80,14 +101,18 @@ $sale->addLineItem( '5.00', // Item Unit Price 'N' // Item taxable ); +``` Custom Fields: + +``` $sale->setCustomField("coupon_code", "SAVE2011"); +``` 4.) By Passing in Objects - Each property will be copied from the object to the AIM request. +``` $sale = new AuthorizeNetAIM; $customer = (object)array(); $customer->first_name = "Jane"; @@ -104,17 +129,20 @@ $customer->email = "foo@example.com"; $customer->cust_id = "55"; $customer->customer_ip = "98.5.5.5"; $sale->setFields($customer); +``` Submitting Transactions ----------------------- To submit a transaction call one of the 7 methods: +``` -authorizeAndCapture() -authorizeOnly() -priorAuthCapture() -void() -captureOnly() -credit() +``` Each method has optional parameters which highlight the fields required by the Authorize.Net API for that transaction type. @@ -125,6 +153,7 @@ eCheck To submit an electronic check transaction you can set the required fields individually or simply use the setECheck method: +``` $sale = new AuthorizeNetAIM; $sale->amount = "45.00"; $sale->setECheck( @@ -136,6 +165,7 @@ $sale->setECheck( 'WEB' // echeck_type ); $response = $sale->authorizeAndCapture(); +``` Partial Authorization Transactions @@ -143,18 +173,22 @@ Partial Authorization Transactions To enable partial authorization transactions set the partial_auth flag to true: +``` $sale->allow_partial_auth = true; +``` You should receive a split tender id in the response if a partial auth is made: +``` $split_tender_id = $response->split_tender_id; - +``` Itemized Order Information -------------------------- To add itemized order information use the addLineItem method: +``` $auth->addLineItem( 'item1', // Item Id 'Golf tees', // Item Name @@ -163,15 +197,16 @@ $auth->addLineItem( '5.00', // Item Unit Price 'N' // Item taxable ); - +``` Merchant Defined Fields ----------------------- You can use the setCustomField method to set any custom merchant defined field(s): +``` $sale->setCustomField("entrance_source", "Search Engine"); $sale->setCustomField("coupon_code", "SAVE2011"); - +``` Transaction Response -------------------- @@ -179,9 +214,10 @@ When you submit an AIM transaction you receive an AuthorizeNetAIM_Response object in return. You can access each name/value pair in the response as you would normally expect: +``` $response = $sale->authorizeAndCapture(); $response->response_code; $response->response_subcode; $response->response_reason_code; $response->transaction_id; - +``` \ No newline at end of file diff --git a/doc/ARB.markdown b/doc/ARB.markdown index 1d4bb92..39073b9 100644 --- a/doc/ARB.markdown +++ b/doc/ARB.markdown @@ -7,12 +7,11 @@ Basic Overview The AuthorizeNetARB class creates a request object for submitting transactions to the AuthorizeNetARB API. - Creating/Updating Subscriptions ------------------------------- - To create or update a subscription first create a subscription object: +``` $subscription = new AuthorizeNet_Subscription; $subscription->name = "Short subscription"; $subscription->intervalLength = "1"; @@ -25,16 +24,21 @@ $subscription->creditCardExpirationDate = "2018-10"; $subscription->creditCardCardCode = "123"; $subscription->billToFirstName = "john"; $subscription->billToLastName = "doe"; +``` Then create an AuthorizeNetARB object and call the appropriate method passing in your subscription object: +``` $request = new AuthorizeNetARB; $response = $request->createSubscription($subscription); +``` - or for updating a subscription: +or for updating a subscription: +``` $response = $request->updateSubscription($subscription_id, $subscription); +``` Getting Subscription Status --------------------------- @@ -42,11 +46,15 @@ Getting Subscription Status Create a new AuthorizeNetARB object and call the getSubscriptionStatus method with the subscription_id you want the status of as the parameter: +``` $status_request = new AuthorizeNetARB; $status_response = $status_request->getSubscriptionStatus($subscription_id); +``` Canceling a Subscription ------------------------ +``` $cancellation = new AuthorizeNetARB; $cancel_response = $cancellation->cancelSubscription($subscription_id); +``` \ No newline at end of file diff --git a/doc/CIM.markdown b/doc/CIM.markdown index bbe8a3b..82aca6e 100644 --- a/doc/CIM.markdown +++ b/doc/CIM.markdown @@ -14,14 +14,17 @@ Creating a Customer Profile To create a new cusomter profile, first create a new AuthorizeNetCustomer object. +``` $customerProfile = new AuthorizeNetCustomer; $customerProfile->description = "Description of customer"; $customerProfile->merchantCustomerId = 123; $customerProfile->email = "user@domain.com"; +``` You can then create an add payment profiles and addresses to this customer object. +``` // Add payment profile. $paymentProfile = new AuthorizeNetPaymentProfile; $paymentProfile->customerType = "individual"; @@ -67,52 +70,66 @@ $address2->country = "USA"; $address2->phoneNumber = "555-512-5555"; $address2->faxNumber = "555-523-5556"; $customerProfile->shipToList[] = $address2; +``` Next, create an AuthorizeNetCIM object: +``` $request = new AuthorizeNetCIM; +``` Finally, call the createCustomerProfile method and pass in your customer object: +``` $response = $request->createCustomerProfile($customerProfile); +``` The response object provides some helper methods for easy access to the results of the transaction: +``` $new_customer_id = $response->getCustomerProfileId(); +``` The response object also stores the XML response as a SimpleXml element which you can access like so: +``` $new_customer_id = $response->xml->customerProfileId +``` You can also run xpath queries against the result: +``` $array = $response->xpath('customerProfileId'); $new_customer_id = $array[0]; - +``` Deleting a Customer Profile --------------------------- To delete a customer profile first create a new AuthorizeNetCIM object: +``` $request = new AuthorizeNetCIM; +``` Then call the deleteCustomerProfile method: +``` request->deleteCustomerProfile($customer_id); - +``` Retrieving a Customer Profile ----------------------------- To retrieve a customer profile call the getCustomerProfile method: +``` $response = $request->getCustomerProfile($customerProfileId); - +``` Validation Mode --------------- @@ -122,16 +139,19 @@ Validation mode allows you to generate a test transaction at the time you create To create a customer profile with Validation mode, simply pass in the a value for the validation mode parameter on the createCustomerProfile method: +``` $response = $request->createCustomerProfile($customerProfile, "testMode"); +``` You can access the validation response for each payment profile via xpath, the SimpleXML element or the getValidationResponses method: +``` $validationResponses = $response->getValidationResponses(); foreach ($validationResponses as $vr) { echo $vr->approved; } - +``` Updating a Customer Profile --------------------------- @@ -139,32 +159,34 @@ Updating a Customer Profile Call the updateCustomerProfile method with the customerProfileId and customerProfile parameters: +``` $response = $request->updateCustomerProfile($customerProfileId, $customerProfile); - +``` Adding a Payment Profile ------------------------ - +``` $paymentProfile = new AuthorizeNetPaymentProfile; $paymentProfile->customerType = "individual"; $paymentProfile->payment->creditCard->cardNumber = "4111111111111111"; $paymentProfile->payment->creditCard->expirationDate = "2015-10"; $response = $request->createCustomerPaymentProfile($customerProfileId, $paymentProfile); - +``` Updating a Payment Profile -------------------------- +``` $paymentProfile->payment->creditCard->cardNumber = "4111111111111111"; $paymentProfile->payment->creditCard->expirationDate = "2017-11"; $response = $request->updateCustomerPaymentProfile($customerProfileId,$paymentProfileId, $paymentProfile); +``` Adding a Shipping Address ------------------------- - - +``` $address = new AuthorizeNetAddress; $address->firstName = "john"; $address->lastName = "Doe"; @@ -178,18 +200,21 @@ $address->phoneNumber = "555-555-5555"; $address->faxNumber = "555-555-5556"; $response = $request->createCustomerShippingAddress($customerProfileId, $address); $customerAddressId = $response->getCustomerAddressId(); +``` Updating a Shipping Address --------------------------- +``` // Update shipping address. $address->address = "2 First Street"; $response = $request->updateCustomerShippingAddress($customerProfileId, $customerAddressId, $address); - +``` Creating Transactions --------------------- +``` // Create Auth & Capture Transaction $transaction = new AuthorizeNetTransaction; $transaction->amount = "9.79"; @@ -215,35 +240,39 @@ $lineItem2->taxable = "true"; $transaction->lineItems[] = $lineItem; $transaction->lineItems[] = $lineItem2; - - + $response = $request->createCustomerProfileTransaction("AuthCapture", $transaction); $transactionResponse = $response->getTransactionResponse(); $transactionId = $transactionResponse->transaction_id; - +``` Voiding a Transaction --------------------- +``` $transaction = new AuthorizeNetTransaction; $transaction->transId = $transactionId; $response = $request->createCustomerProfileTransaction("Void", $transaction); - +``` Deleting a Shipping Address --------------------------- +``` $response = $request->deleteCustomerShippingAddress($customerProfileId, $customerAddressId); +``` Deleting a Payment Profile -------------------------- +``` $response = $request->deleteCustomerPaymentProfile($customerProfileId, $paymentProfileId); +``` - - Getting Customer Profile IDs ---------------------------- -$response = $request->getCustomerProfileIds(); \ No newline at end of file +``` +$response = $request->getCustomerProfileIds(); +``` \ No newline at end of file diff --git a/doc/CP.markdown b/doc/CP.markdown index 96ea161..a296646 100644 --- a/doc/CP.markdown +++ b/doc/CP.markdown @@ -21,6 +21,7 @@ Setting Track Data To set Track 1 and/or Track 2 data, use the respective methods like so: +``` $sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY); $sale->setFields( array( @@ -40,4 +41,4 @@ $sale->setFields( ); $sale->setTrack2Data('4111111111111111=1803101000020000831?'); $response = $sale->authorizeAndCapture(); - +``` \ No newline at end of file diff --git a/doc/DPM.markdown b/doc/DPM.markdown index 115cc9d..19797ed 100644 --- a/doc/DPM.markdown +++ b/doc/DPM.markdown @@ -10,13 +10,13 @@ of implementing the Direct Post Method. While it is not necessary to use the AuthorizeNetDPM class to implement DPM, it may serve as a handy reference. -The AuthorizeNetDPM class extends the AuthorizeNetSIM_Form class. -See the SIM.markdown for additional documentation. +The `AuthorizeNetDPM` class extends the `AuthorizeNetSIM_Form` class. +See the [SIM.markdown](SIM.markdown) for additional documentation. Relay Response Snippet ---------------------- -The AuthorizeNetDPM class contains a getRelayResponseSnippet($redirect_url) +The AuthorizeNetDPM class contains a `getRelayResponseSnippet($redirect_url)` which generates a snippet of HTML that will redirect a user back to your site after submitting a checkout form using DPM/SIM. diff --git a/doc/SIM.markdown b/doc/SIM.markdown index ee38e59..e5cc3a4 100644 --- a/doc/SIM.markdown +++ b/doc/SIM.markdown @@ -7,7 +7,6 @@ Basic Overview The Authorize.Net PHP SDK includes classes that can speed up implementing a Server Integration Method solution. - Hosted Order/Receipt Page ------------------------- @@ -18,6 +17,7 @@ reference. The code below will generate a buy now button that leads to a hosted order page: +```
getHiddenFieldString();?>
+``` Fingerprint Generation ---------------------- To generate the fingerprint needed for a SIM transaction call the getFingerprint method: +``` $fingerprint = AuthorizeNetSIM_Form::getFingerprint($api_login_id, $transaction_key, $amount, $fp_sequence, $fp_timestamp); - +``` Relay Response -------------- @@ -63,6 +65,7 @@ http://yourdomain.com/response_handler.php and execute any logic you want when a transaction occurs. The AuthorizeNetSIM class makes it easy to verify the transaction came from Authorize.Net and parse the response: +``` $response = new AuthorizeNetSIM; if ($response->isAuthorizeNet()) { @@ -72,3 +75,4 @@ if ($response->isAuthorizeNet()) magazine_subscription_activate($response->cust_id); } } +``` \ No newline at end of file diff --git a/doc/SOAP.markdown b/doc/SOAP.markdown index a535f00..2f9e72e 100644 --- a/doc/SOAP.markdown +++ b/doc/SOAP.markdown @@ -4,7 +4,7 @@ SOAP Basic Overview -------------- -The AuthorizeNetSOAP class provides a very basic wrapper to PHP's bundled -SoapClient class. The AuthorizeNetSOAP class merely contains the WSDL, +The `AuthorizeNetSOAP` class provides a very basic wrapper to PHP's bundled +`SoapClient` class. The `AuthorizeNetSOAP` class merely contains the WSDL, Sandbox, and Live Production server urls to make it easier to connect to the Authorize.Net SOAP API. \ No newline at end of file diff --git a/doc/TD.markdown b/doc/TD.markdown index c9a1bfb..c4e5c58 100644 --- a/doc/TD.markdown +++ b/doc/TD.markdown @@ -4,52 +4,64 @@ Transaction Details API Basic Overview -------------- -The AuthorizeNetTD class creates a request object for submitting requests +The `AuthorizeNetTD` class creates a request object for submitting requests to the Authorize.Net Transaction Details API. -The AuthorizeNetTD class returns a response that uses PHP's bundled SimpleXML +The `AuthorizeNetTD` class returns a response that uses PHP's bundled `SimpleXML` class for accessing it's members. The AuthorizeNetTD response provides two ways to access response elements: 1.) A SimpleXml object: +``` $response->xml->transaction->payment->creditCard->cardType +``` 2.) Xpath: +``` $batches = $response->xpath("batchList/batch"); +``` 3.) AuthorizeNet Objects (todo) - - Get Transaction Details ----------------------- +``` $request = new AuthorizeNetTD; $response = $request->getTransactionDetails($transId); echo "Amount: {$response->xml->transaction->authAmount}"; +``` Get Settled Batch List ---------------------- + +``` $request = new AuthorizeNetTD; $response = $request->getSettledBatchList(); $batches = $response->xpath("batchList/batch"); echo "Batch 1: {$batches[0]->batchId}"; +``` Get Transaction List -------------------- + +``` $request = new AuthorizeNetTD; $response = $request->getTransactionList($batch_id); $transactions = $response->xpath("transactions/transaction") +``` There are two additional helper methods in the PHP SDK which will make multiple calls to retrieve a day's worth of transactions or a month's worth of batches: +``` getTransactionsForDay($month, $day, $year = false) getSettledBatchListForMonth($month , $year) +``` If you don't pass parameters into these methods they will default -to the current day/month. +to the current day/month. \ No newline at end of file