Added by Torio Farazdagi, last edited by Torio Farazdagi on Aug 03, 2010  (view change)

Labels

 

Zend Framework: Zend_Service_AuthorizeNet_Cim Component Proposal

Proposed Component Name Zend_Service_AuthorizeNet_Cim
Developer Notes http://framework.zend.com/wiki/display/ZFDEV/Zend_Service_AuthorizeNet_Cim
Proposers Torio Farazdagi
Zend Liaison TBD
Revision 0.1 - 14 July 2009: Initial Proposal Draft.
0.2 - 16 July 2009: Excluded all APIs except for CIM
0.3 - 18 July 2009: All UCs provided
0.4 - 07 Aug 2009: UC refactored
0.5 - 07 Aug 2009: prepared for review (wiki revision: 29)

Table of Contents

1. Overview

Zend_Service_AuthorizeNet_Cim is an interface to Authorize.net's Customer Information Management (CIM) API. At first draft only XML implementation would be provided, with the possible SOAP inclusion at later point (no change to code, except adapter extension would be required - code layout was created with this in mind).

2. References

3. Component Requirements, Constraints, and Acceptance Criteria

  • This component will provide interface for CIM (XML).
  • This component will not provide interface for CIM (SOAP). However, all infrastructure for possible extension should be in place.

4. Dependencies on Other Framework Components

  • Zend_Http_Client
  • Zend_Http_Client_Adapter_Socket
  • Zend_Http_Response
  • Zend_Config
  • Zend_Loader
  • Zend_Service_Abstract
  • Zend_Uri_Http

5. Theory of Operation

Package would provide high-level interface for interaction with CIM API. In a nutshell, client should obtain required service adapter (XML|SOAP), and then interact with CIM API via mapped methods. There are number of container classes that abstract data required to be passed along with RPC calls. Internally, Zend_Http_Client is used as transport, with returned results provided as SimpleXml objects.

6. Milestones / Tasks

  • Milestone 1: design notes will be published here
  • Milestone 2: [DONE] Use cases for all 15 methods of CIM API should be prepared
  • Milestone 3: [DONE] Working prototype for all UCs prepared
  • Milestone 4: Unit tests exist, work, and are checked into SVN.
  • Milestone 5: Initial documentation exists.

If a milestone is already done, begin the description with "[DONE]", like this:

  • Milestone #: [DONE] Unit tests ...

7. Class Index

  • General
    • Zend_Service_AuthorizeNet_Abstract
    • Zend_Service_AuthorizeNet_Exception
  • CIM API
    • Zend_Service_AuthorizeNet_Cim - factory
    • Zend_Service_AuthorizeNet_Cim_Adapter - general service adapter
    • Zend_Service_AuthorizeNet_Cim_Adapter_Xml - XML service adapter
  • Gateway Response
    • Zend_Service_AuthorizeNet_Response
    • Zend_Service_AuthorizeNet_Cim_Response - CIM specific reponse extends base *_Response class
    • Zend_Service_AuthorizeNet_Cim_Response_Xml - XML adapter specific response
  • General Data Containers
    • Zend_Service_AuthorizeNet_Cim_Data - factory
    • Zend_Service_AuthorizeNet_Cim_Data_Abstract - base data class
    • Zend_Service_AuthorizeNet_Cim_Data_Profile - represents customer profile
    • Zend_Service_AuthorizeNet_Cim_Data_ProfileUpdate - update method requires simplier profile
    • Zend_Service_AuthorizeNet_Cim_Data_PaymentProfile - payment profile
    • Zend_Service_AuthorizeNet_Cim_Data_PaymentBankAccount
    • Zend_Service_AuthorizeNet_Cim_Data_PaymentCreditCard
    • Zend_Service_AuthorizeNet_Cim_Data_CustomerAddress - base class for representing address
  • XML Data Containers (implement abstract General Data Containers)
    • Zend_Service_AuthorizeNet_Cim_Data_Xml_Profile
    • Zend_Service_AuthorizeNet_Cim_Data_Xml_ProfileUpdate
    • Zend_Service_AuthorizeNet_Cim_Data_Xml_PaymentProfile
    • Zend_Service_AuthorizeNet_Cim_Data_Xml_CustomerAddress
    • Zend_Service_AuthorizeNet_Cim_Data_Xml_ShipToList - extends *_Cim_Data_CustomerAddress
    • Zend_Service_AuthorizeNet_Cim_Data_Xml_BillTo - extends *_Cim_Data_CustomerAddress
    • Zend_Service_AuthorizeNet_Cim_Data_Xml_PaymentBankAccount
    • Zend_Service_AuthorizeNet_Cim_Data_Xml_PaymentCreditCard
  • General Transaction Containers
    • Zend_Service_AuthorizeNet_Cim_Transaction - factory
    • Zend_Service_AuthorizeNet_Cim_Transaction_Abstract - base transaction class
    • Zend_Service_AuthorizeNet_Cim_Transaction_AuthCapture
    • Zend_Service_AuthorizeNet_Cim_Transaction_AuthOnly
    • Zend_Service_AuthorizeNet_Cim_Transaction_CaptureOnly
    • Zend_Service_AuthorizeNet_Cim_Transaction_PriorAuthCapture
    • Zend_Service_AuthorizeNet_Cim_Transaction_Refund
    • Zend_Service_AuthorizeNet_Cim_Transaction_Void
  • XML Transaction Containers (implement abstract General Containers)
    • Zend_Service_AuthorizeNet_Cim_Transaction_Xml_AuthCapture
    • Zend_Service_AuthorizeNet_Cim_Transaction_Xml_AuthOnly
    • Zend_Service_AuthorizeNet_Cim_Transaction_Xml_CaptureOnly
    • Zend_Service_AuthorizeNet_Cim_Transaction_Xml_PriorAuthCapture
    • Zend_Service_AuthorizeNet_Cim_Transaction_Xml_Refund
    • Zend_Service_AuthorizeNet_Cim_Transaction_Xml_Void
  • Auxillary Transaction Containers
    • Zend_Service_AuthorizeNet_Cim_Transaction_ExtendedAmountType - extendedAmountType in ANet schema
    • Zend_Service_AuthorizeNet_Cim_Transaction_LineItemType - lineItemType in ANet schema
    • Zend_Service_AuthorizeNet_Cim_Transaction_OrderExType - orderExType in ANet schema
  • SOAP Data Containers (not implemented)
    • Zend_Service_AuthorizeNet_Cim_Data_Soap_*

8. Use Cases

UC-01 Obtaining service adapter

UC-02 Obtaining service adapter via factory
UC-03 Clarifying adapter mode
UC-04 Using Data Containers

Each API method expects data object as input, you have several options of initializing data containers (which are wrappers objects for data which implement __toString() - thus they are able to transform raw data into XML|SOAP representation).

You can create data container by using Zend_Service_AuthorizeNet_Cim_Data::factory() directly:

The obvious drawback of this method is that you have to remember name of container ('Profile' in this case), even if we have class constant we would still be left with an issue: factory method returns object of abstract class (Zend_Service_AuthorizeNet_Cim_Data_Abstract) so your editor auto-completion features would not be accessible (exact type of returned object is known only at run-time).
To resolve this issue, Zend_Service_AuthorizeNet_Cim_Data provides helper methods, for eg in order to create Profile data container:

Now, when exact type of $profile is known, you can use editor auto-complete. The reason I am so pre-occupied with object reflection is simple - you can not only pass data as array into constructor, but use wrapper's getters/setters to manipulate content (so you don't have to remember the exact names of gateway parameters):

UC-05 Processing request responses

All request return SimpleXml object as response (probably should return arrays or dedicated object?).

UC-06 Create simple customer profile - createCustomerProfileRequest()

Using setters:

UC-07 Create full customer profile - createCustomerProfileRequest()

Using setters:

UC-08 Create payment profile for an existing customer profile - createCustomerPaymentProfileRequest()

Using setters:

UC-09 Create shipping address for an existing customer profile - createCustomerShippingAddressRequest()

Using setters:

UC-10 Create transaction (AUTH_ONLY, using config array)

Using setters:

UC-11 Create AUTH_CAPTURE transaction
UC-12 Create CAPTURE_ONLY transaction
UC-13 Create PRIOR_AUTH_CAPTURE transaction
UC-14 Create VOID (cancel) transaction
UC-15 Create CREDIT (refund) transaction
UC-16 Delete customer profile and all associated data - deleteCustomerProfileRequest()
UC-17 Delete a customer payment profile from an existing customer profile - deleteCustomerPaymentProfileRequest()
UC-18 Delete a customer shipping address from an existing customer profile - deleteCustomerShippingAddressRequest()
UC-19 List all customer profile ids - getCustomerProfileIdsRequest()
UC-20 Get customer profile data - getCustomerProfileRequest()
UC-21 Get customer's payment profile data - getCustomerPaymentProfileRequest()
UC-22 Get customer's shipping address data - getCustomerShippingAddressRequest()
UC-23 Update customer profile - updateCustomerProfileRequest()

Using setters:

UC-24 Update payment profile - updateCustomerPaymentProfileRequest()

Using setters:

UC-25 Update shipping data

Using setters:

UC-26 Validate customer profile

9. Class Skeletons

Working prototype - http://www.phpmag.ru/AuthorizeNet.tar.gz