commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / tools / extensions / org.civicrm.payment.googlecheckout / packages / Google / README
1 Sample PHP code for integration of Google Checkout with the merchant site
2 --------------------------------------------------------------------------
3 File structure and function
4 ----------------------------
5
6 There are two folders and a log file in the top level directory of
7 google-checkout-php-sample.
8
9 1. "demo" directory:
10 This contains two files cartdemo.php and responsehandlerdemo.php
11
12 a)cartdemo.php:
13 ---------------
14 This file demonstrates the steps required to add items, shipping, taxes and
15 merchant-calculations to the cart before it is posted to the Checkout server.
16 There are three use case functions defined with different settings for
17 shipping and taxes along with different button usages.
18
19 b)responsehandler.php:
20 ----------------------
21 This file will be used to handle the notifications, callbacks and order
22 processing steps.
23 The path for this file must be specified in the merchant's API callback
24 URL in Settings->Integration of the merchant's seller account.
25 This file can be used as is and modified by the merchant as per their
26 business workflow details.
27 Some of the intial steps performed in this file include collecting the
28 XML response, request that has been received and get a parsed result in a
29 PHP associative array for easy accesibility
30 (For details of parse output refer xmlparser.php which has an
31 example of how an XML maps to the object).
32 Order processing can be done using the SendProcessOrder(..) type of
33 methods provided in googleresponse.php. Some sample order processing
34 command invocations have been provided as comments in the code
35
36
37 2. "library" directory:
38 This contains the classes defined to describe the API structure so as to easily
39 define and add XML entries by defining objects of these classes.
40
41 a) googlecart.php:
42 ------------------
43 This is the main class which must be instantiated to post a cart.
44 It requires a merchant ID and key to be set and there is an option
45 to specify which server is to be used for the transactions
46 (Sandbox or Production).
47 It also has methods to add items, shipping options, tax options and
48 merchant-calculation details.
49
50 b) googleitem.php:
51 ------------------
52 This class is instantiated for every item to be added to the cart.
53 It requires the item name, description, price and quantity to be specified.
54
55 c) googleshipping.php:
56 ----------------------
57 This class is instantiated for every shipping option that is to be added to the cart.
58 It requires the shipping name type an price to be specified.
59 Other methods allow specification of the shipping restrictions.
60
61 d) googletaxrule.php:
62 ---------------------
63 This class is used to define all tax rules for the tax tables. These may be
64 rules for default or alternate tax tables. Methods have been provided to add
65 states and zip patterns for the tax rules.
66
67 e) googletaxtable.php:
68 ----------------------
69 This class is used to aggregate all the defined tax rules to define a tax table.
70 This may be a default or alternate tax table identified by the "type" value.
71
72 f) googleresponse.php:
73 ----------------------
74 An instance of this class is created in the responsehandlerdemo.php.
75 This again requires the merchant id and merchant key to be specified.
76 There are methods provided to send all the different order processing
77 commands.
78 All notifications are parsed and the merchant can take required action
79 when a particular notification is received.
80
81 g) googleresult.php:
82 --------------------
83 This class is used for merchant-calculations and is invoked for
84 each result in the merchant-calculations-result sent from the
85 merchant in response to a callback.
86
87 h) googlemerchantcalculations.php:
88 ----------------------------------
89 In order to process merchant calculations, an instance of this
90 class is created. It is used to aggregate merchant results and
91 respond with the XML response for the callback.
92
93 f) "xml-processing" directory:
94 ------------------------------
95
96 i) xmlbuilder.php:
97 -----------------
98 This class generates XML and consists of "push" and "pop"
99 methods to add open and close tags respectively.
100 This is used internally by the library classes to generate
101 XML file for posting carts.
102
103 ii)xmlparser.php:
104 -----------------
105 This class parses XML documents using the SAX parser and is
106 compatible with PHP v4 and 5. It converts them to DOM form
107 returning the XML data in a PHP associative array.
108 This is used internally by the library classes to parse
109 XML requests and responses that are received from the
110 Checkout server.
111
112 3. googlemessage.log:
113 The log file records all the notification and order processing commands that are
114 sent and received and can be useful information for debugging purposes.
115