OLD | NEW |
---|---|
(Empty) | |
1 <h1>In-App Payments Service</h1> | |
2 | |
3 <p class="warning"> | |
4 This service is currently available to Chrome users on the | |
5 <a href="http://www.chromium.org/getting-involved/dev-channel">dev channel</a>. | |
6 </p> | |
7 | |
8 <table class="intro"> | |
9 <tr> | |
10 <th scope="col"></th> | |
11 <th scope="col"></th> | |
12 </tr> | |
not at google - send to devlin
2013/07/09 14:57:36
Is the blank row necessary?
Andy
2013/07/09 20:46:53
Blank row removed. (I copied the table from one o
| |
13 <tr> | |
14 <td><strong>Description:</strong></td> | |
15 <td>Use the In-App Payments Service to sell digital and virtual goods within a Chrome app.</td> | |
16 </tr> | |
17 <tr> | |
18 <td><strong>Availability:</strong></td> | |
19 <td>Chrome 29 or later</td> | |
not at google - send to devlin
2013/07/09 14:57:36
This brings up an interesting point. Since we're g
Andy
2013/07/09 20:46:53
I noticed the inconsistency between the docs. I a
| |
20 </tr> | |
21 <tr> | |
22 <td><strong>Sample:</strong></td> | |
23 <td><a href="https://github.com/GoogleChrome/chrome-app-samples/tree/master/ in-app-payments">in-app-payments</a></td> | |
24 </tr> | |
25 <tr> | |
26 <td><strong>Learn more:</strong></td> | |
27 <td> | |
28 <a href="https://support.google.com/chrome_webstore/answer/1053354">Google W allet</a>; <br> | |
29 <a href="https://developers.google.com/commerce/wallet/digital/docs/">Google Wallet for Digital Goods</a></td> | |
30 </tr> | |
31 </table> | |
32 | |
33 <h2 id="overview">Overview</h2> | |
34 | |
35 <p> | |
36 You can use the In-App Payments Service to sell digital and virtual goods within your app. | |
37 When you use the In-App Payments Service, the Chrome Wallet App, which is embedd ed in Chrome, communicates with the | |
38 <a href="https://support.google.com/chrome_webstore/answer/1053354">Google Walle t</a> | |
39 servers and handles all the required checkout details, so your app does not have to process any financial transactions. | |
40 The In-App Payments Service requires you to package a JavaScript file, buy.js, w ith your app to trigger the purchase flow. | |
not at google - send to devlin
2013/07/09 14:57:36
can you link to buy.js here? Might as well. Just t
Andy
2013/07/09 20:46:53
Done.
| |
41 </p> | |
42 | |
43 <h2 id="flow">Purchase flow</h2> | |
44 | |
45 <p> | |
46 When a customer clicks a Buy button in your app to make a purchase, the Chrome W allet App displays a payment processing window | |
47 on top of your application window: | |
48 </p> | |
49 | |
50 <img src="{{static}}/images/in-app-payments-review.png" | |
51 width="569" | |
52 alt="screenshot: in-app-payments review dialog"> | |
53 | |
54 <p> | |
55 When the user clicks the "Buy" button, the Google Wallet server processes the pa yment and displays a purchase confirmation dialog | |
not at google - send to devlin
2013/07/09 14:57:36
You have
the "Buy"
here and
a Buy
above. Can it be
Andy
2013/07/09 20:46:53
Done.
| |
56 to the user, as shown below. The success or failure callback in your app is invo ked appropriately. | |
57 </p> | |
58 | |
59 <img src="{{static}}/images/in-app-payments-confirmation.png" | |
60 width="563" | |
61 alt="screenshot: in-app-payments confirmation dialog"> | |
62 | |
63 <p> | |
64 If the user is not signed up for Google Wallet, the Chrome Wallet App takes the user through the sign-up flow: | |
65 </p> | |
66 | |
67 <img src="{{static}}/images/in-app-payments-set-up.png" | |
68 width="565" | |
69 alt="screenshot: Google wallet set up dialog"> | |
70 | |
71 <h2 id="sample-code">Sample code</h2> | |
72 | |
73 <p> | |
74 The following code snippet illustrates how to initiate the purchase flow in an a pp. | |
75 The parameters for the <code>buy()</code> method are described below. | |
76 </p> | |
77 | |
78 <pre> | |
79 google.payments.inapp.buy({ | |
80 parameters: {}, | |
81 jwt: 'eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIxNDIwNDk' + | |
82 '1MzA5NDM1MjE2ODU3MSIsImF1ZCI6Ikdvb2dsZSI' + | |
83 'sInR5cCI6Imdvb2dsZS9wYXltZW50cy9pbmFwcC9' + | |
84 'zdWJzY3JpcHRpb24vdjEiLCJpYXQiOjEzNTg0NTc' + | |
85 'yNjksImV4cCI6MjM1ODQxMjMzNDMsInJlcXVlc3Q' + | |
86 'iOnsiaW5pdGlhbFBheW1lbnQiOnsicHJpY2UiOiI' + | |
87 'xMC41MCIsImN1cnJlbmN5Q29kZSI6IlVTRCIsInB' + | |
88 'heW1lbnRUeXBlIjoicHJvcmF0ZWQifSwicmVjdXJ' + | |
89 'yZW5jZSI6eyJwcmljZSI6IjQuOTkiLCJjdXJyZW5' + | |
90 'jeUNvZGUiOiJVU0QiLCJzdGFydERhdGUiOiIxMzU' + | |
91 '4NDYzMjY5IiwiZnJlcXVlbmN5IjoibW9udGhseSI' + | |
92 'sIm51bVJlY3VycmVuY2VzIjoiMTIifSwibmFtZSI' + | |
93 '6IlBpZWNlIG9mIENha2UiLCJkZXNjcmlwdGlvbiI' + | |
94 '6IkEgZGVsaWNpb3VzIHBpZWNlIG9mIHZpcnR1YWw' + | |
95 'gY2FrZSIsInNlbGxlckRhdGEiOiJZb3VyIERhdGE' + | |
96 'gSGVyZSJ9fQ.sXd39R7MNNfDFa-jnlTNu2C2te-_' + | |
97 'x9--87Phfdr5GrE', | |
98 success: logSuccess, | |
99 failure: logFailure | |
100 }); | |
101 </pre> | |
102 | |
103 <h2 id="how-to">How to use the Service</h2> | |
104 | |
105 <p>Using the In-App Payments Service in an app is similar to using the | |
106 <a href="https://developers.google.com/commerce/wallet/digital/docs/">Google Wal let for Digital Goods API</a> in a web site. | |
107 The integration steps below are based on the | |
108 <a href="https://developers.google.com/commerce/wallet/digital/docs/tutorial">Go ogle Wallet for Digital Goods Tutorial</a>, | |
109 but there are a few key differences for Apps. These differences are summarized b elow and described in detail in the | |
110 integration steps. | |
111 </p> | |
112 | |
113 <ul> | |
114 <li>You can use pre-generated JSON Web Tokens (JWTs) in your app, rather than using a server to generate the tokens.</li> | |
115 | |
116 <li>You must package the <code>buy.js</code> library with your app, and load t he library from its location in your package.</li> | |
not at google - send to devlin
2013/07/09 14:57:36
prefer the same <a> than <code> here.
Andy
2013/07/09 20:46:53
Done.
| |
117 | |
118 <li>You must call the <code>buy()</code> method with an extra parameter called <code>parameters</code>.</li> | |
119 | |
120 <li>The UI to process payments is displayed in a separate window on top of you r application window, rather than in an iframe.</li> | |
121 </ul> | |
122 | |
123 <p>Follow these steps to use the In-App Payments Service in your app:</p> | |
124 | |
125 <ol> | |
126 <li><a href="https://developers.google.com/commerce/wallet/digital/docs/tutori al#1">Generate a JSON Web Token (JWT) for each item to be purchased.</a> | |
127 <ul style="list-style-type: none;"> | |
not at google - send to devlin
2013/07/09 14:57:36
I presume this pattern is to get a little indented
Andy
2013/07/09 20:46:53
Done, but I added the style rule in site.css for r
| |
128 <li>You can generate JWTs using a server, or you can pre-generate JWTs for use in your app. | |
129 <p class="warning"> | |
130 Note: If you use pre-generated JWTs, you should generate the JWTs outside of your app, and include | |
131 the generated tokens in your app. | |
132 <strong>NEVER</strong> include the Seller secret you use to generate token s in your app. | |
133 If you need to generate JWTs dynamically, you should use a server. | |
134 </p> | |
135 </li> | |
136 </ul> | |
137 </li> | |
138 | |
139 <li>Include <a href="https://raw.github.com/GoogleChrome/chrome-app-samples/ma ster/in-app-payments/buy.js">buy.js</a> in your app. | |
140 <ul style="list-style-type: none;"> | |
141 <li>Due to the security restrictions in the | |
142 <a href="https://developer.chrome.com/extensions/contentSecurityPolicy.htm l">Content Security Policy</a> for Chrome apps, | |
143 you cannot include the <code>buy.js</code> library from an external locati on. Instead, you must package | |
144 <code>buy.js</code> with your app, and load the library from the packaged location.</li> | |
not at google - send to devlin
2013/07/09 14:57:36
ditto here and above, though maybe linking to it 3
Andy
2013/07/09 20:46:53
Done.
| |
145 </li> | |
146 </ul> | |
147 </li> | |
148 | |
149 <li><a href="https://developers.google.com/commerce/wallet/digital/docs/tutori al#3">Create success and failure callback handlers.</a> | |
150 <ul style="list-style-type: none;"> | |
151 <li>Success and failure callback handlers let your app react to the purcha se flow's completion.</li> | |
152 </ul> | |
153 </li> | |
154 | |
155 <li><a href="https://developers.google.com/commerce/wallet/digital/docs/tutori al#4">Call buy().</a> | |
156 <ul style="list-style-type: none;"> | |
157 <li>When a customer clicks the Buy button in your app, call <code>buy()</c ode> to initiate the purchase flow. | |
158 <p> | |
159 For Apps, you must call <code>buy()</code> with an extra parameter called <code>parameters</code>. | |
160 This parameter currently has one field, <code>env</code>, which specifies the environment in which to process a payment. | |
161 You can set this field to either <code>prod</code> (production server that accepts real credit cards), or | |
162 <code>sandbox</code> (test server that accepts test credit cards to simula te transactions). | |
163 The default setting is <code>sandbox</code>. | |
164 </p> | |
165 </li> | |
166 </ul> | |
167 </li> | |
168 | |
169 <li>(Optional) <a href="https://developers.google.com/commerce/wallet/digital/ docs/tutorial#5">Acknowledge purchase notification.</a> | |
170 <ul style="list-style-type: none;"> | |
171 <li>You can specify a postback URL to make sure that the customer has paid for an item.</li> | |
172 </ul> | |
173 </li> | |
174 | |
175 <li><a href="https://developers.google.com/commerce/wallet/digital/docs/tutori al#6">Get set up as a seller on Google Wallet.</a> | |
176 <ul style="list-style-type: none;"> | |
177 <li>You must sign up for Google Wallet for digital goods in order to use t he In-App Payments Service.</li> | |
178 </ul> | |
179 </li> | |
180 | |
181 <li><a href="https://developers.google.com/commerce/wallet/digital/docs/tutori al#7">Switch to the production server.</a> | |
182 <ul style="list-style-type: none;"> | |
183 <li>Switch from the sandbox server to the production server and test your app using real credit cards.</li> | |
184 </ul> | |
185 </li> | |
186 </ol> | |
187 | |
188 <h2 id="recurring">Recurring billing</h2> | |
189 | |
190 <p>The In-App Payments Service supports automated recurring billing. To set up r ecurring billing, follow the | |
191 instructions for setting up | |
192 <a href="https://developers.google.com/commerce/wallet/digital/docs/subscription s">subscriptions</a> | |
193 for the Google Wallet for Digital Goods API, | |
194 but note again the differences described above (you can use pre-generated JWT to kens; | |
195 you must package buy.js with your app; and you must specify an additional parame ter in the call to <code>buy()</code>). | |
not at google - send to devlin
2013/07/09 14:57:36
link or some common style here too?
Andy
2013/07/09 20:46:53
Done.
| |
196 | |
197 <h2 id="sample-app">Sample app</h2> | |
198 | |
199 <p> | |
200 For a simple app that demonstrates how to use the In-App Payments Service, see: | |
201 </p> | |
202 | |
203 </ul> | |
204 <li><a href="https://github.com/GoogleChrome/chrome-app-samples/tree/master/in -app-payments">source code</a></li> | |
205 <li><a href="https://chrome.google.com/webstore/detail/moldiohggmfllblgmikpeoa gipenlcae">published app</a> (requires Chrome 29 or higher)</li> | |
206 </ul> | |
207 | |
208 <p> | |
209 You can install and run the published app from the Chrome Web Store to try out t he in-app payment purchase flow. | |
210 The app has options to use either the production server or the sandbox server. W hen testing with the sandbox server, | |
211 use these <a href="https://developers.google.com/commerce/wallet/digital/docs/te sting">test credit card numbers</a>, | |
212 which pass basic checks by the Google Wallet for Digital Goods system. | |
213 </p> | |
OLD | NEW |