OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 [JavaPackage="org.chromium.payments.mojom"] | |
6 module payments.mojom; | |
7 | |
8 // The shipping address that the browser process provides to the renderer | |
9 // process. Built either by the browser or a payment app. | |
10 struct PaymentAddress { | |
11 // ISO 3166 country code. Two upper case ASCII letters. | |
12 string country; | |
13 | |
14 array<string> address_line; | |
15 string region; | |
16 string city; | |
17 string dependent_locality; | |
18 string postal_code; | |
19 string sorting_code; | |
20 | |
21 // Optional shortest ISO 639 language code. Two or three lower case ASCII | |
22 // letters. | |
23 string language_code; | |
24 | |
25 // Optional ISO 15924 script code. Four ASCII letters. The first letter is | |
26 // upper case; the rest are lower case. | |
27 string script_code; | |
28 | |
29 string organization; | |
30 string recipient; | |
31 string phone; | |
32 }; | |
33 | |
34 // The currency amount that the renderer provides to the browser process. The | |
35 // browser shows the amount in UI and forwards it on to the payment app, if it | |
36 // requires the amount. | |
37 struct PaymentCurrencyAmount { | |
38 // The most common identifiers are three-letter alphabetic codes as defined | |
39 // by [ISO4217] (for example, "USD" for US Dollars), however any string of at | |
40 // most 2048 characters is considered valid. | |
41 string currency; | |
42 | |
43 // ISO 20022 CurrencyAnd30Amount. Up to 30 total digits. Up to 10 fraction | |
44 // digits. Separated by a dot. | |
45 string value; | |
46 | |
47 // currency_system is a URL that indicates the currency system that the | |
48 // currency identifier belongs to. By default, the value is | |
49 // urn:iso:std:iso:4217 indicating that currency is defined by [ISO4217] | |
50 // (for example, USD for US Dollars). | |
51 string currency_system = "urn:iso:std:iso:4217"; | |
52 }; | |
53 | |
54 struct PaymentResponse { | |
55 string method_name; | |
56 | |
57 // Payment method specific JSON string that is built either by the browser or | |
58 // a payment app, for example Android Pay. Browser ensures that the string can | |
59 // be successfully parsed into base::JSONParser. Renderer parses this string | |
60 // via v8::JSON::Parse() and hands off the result to the merchant website. | |
61 // There's no one format for this object, so more specific types cannot be | |
62 // used. A simple example: | |
63 // | |
64 // {"nameOnCard": "Jon Doe", "pan": "4111 1111 1111 1111"} | |
65 string stringified_details; | |
66 | |
67 PaymentAddress? shipping_address; | |
68 string? shipping_option; | |
69 string? payer_name; | |
70 string? payer_email; | |
71 string? payer_phone; | |
72 }; | |
73 | |
74 enum PaymentErrorReason { | |
75 UNKNOWN, | |
76 USER_CANCEL, | |
77 NOT_SUPPORTED | |
78 }; | |
79 | |
80 enum CanMakePaymentQueryResult { | |
81 CAN_MAKE_PAYMENT, | |
82 CANNOT_MAKE_PAYMENT, | |
83 QUERY_QUOTA_EXCEEDED | |
84 }; | |
85 | |
86 interface PaymentRequestClient { | |
87 OnShippingAddressChange(PaymentAddress address); | |
88 OnShippingOptionChange(string shipping_option_id); | |
89 OnPaymentResponse(PaymentResponse response); | |
90 OnError(PaymentErrorReason error); | |
91 OnComplete(); | |
92 OnAbort(bool aborted_successfully); | |
93 OnCanMakePayment(CanMakePaymentQueryResult result); | |
94 }; | |
95 | |
96 struct PaymentItem { | |
97 string label; | |
98 PaymentCurrencyAmount amount; | |
99 bool pending; | |
100 }; | |
101 | |
102 struct PaymentShippingOption { | |
103 string id; | |
104 string label; | |
105 PaymentCurrencyAmount amount; | |
106 bool selected; | |
107 }; | |
108 | |
109 enum AndroidPayEnvironment { | |
110 PRODUCTION, | |
111 TEST | |
112 }; | |
113 | |
114 enum AndroidPayCardNetwork { | |
115 AMEX, | |
116 DISCOVER, | |
117 MASTERCARD, | |
118 VISA | |
119 }; | |
120 | |
121 enum AndroidPayTokenization { | |
122 UNSPECIFIED, | |
123 GATEWAY_TOKEN, | |
124 NETWORK_TOKEN | |
125 }; | |
126 | |
127 struct AndroidPayTokenizationParameter { | |
128 string? key; | |
129 string? value; | |
130 }; | |
131 | |
132 enum BasicCardNetwork { | |
133 AMEX, | |
134 DINERS, | |
135 DISCOVER, | |
136 JCB, | |
137 MASTERCARD, | |
138 MIR, | |
139 UNIONPAY, | |
140 VISA | |
141 }; | |
142 | |
143 enum BasicCardType { | |
144 CREDIT, | |
145 DEBIT, | |
146 PREPAID | |
147 }; | |
148 | |
149 struct PaymentMethodData { | |
150 array<string> supported_methods; | |
151 | |
152 // A JSON string built by the renderer from a JavaScript object that the | |
153 // merchant website provides. The renderer uses | |
154 // blink::JSONObject::toJSONString() to generate this string. The browser does | |
155 // not parse the string and passes it as-is directly to payment apps. There's | |
156 // no one format for this object, so more specific types cannot be used. A | |
157 // simple example: | |
158 // | |
159 // {"gateway": "stripe"} | |
160 string stringified_data; | |
161 | |
162 // Android Pay specific method data is parsed in the renderer. | |
163 // https://developers.google.com/web/fundamentals/getting-started/primers/paym
ent-request/android-pay | |
164 // TODO(rouslan): Stop parsing Android Pay data. http://crbug.com/620173 | |
165 AndroidPayEnvironment environment; | |
166 string? merchant_name; | |
167 string? merchant_id; | |
168 array<AndroidPayCardNetwork> allowed_card_networks; | |
169 AndroidPayTokenization tokenization_type; | |
170 array<AndroidPayTokenizationParameter> parameters; | |
171 // Value of 0 means the merchant did not specify or it was an invalid value. | |
172 int32 min_google_play_services_version; | |
173 | |
174 // Basic card specific method data is parsed in the renderer. | |
175 array<BasicCardNetwork> supported_networks; | |
176 array<BasicCardType> supported_types; | |
177 }; | |
178 | |
179 struct PaymentDetailsModifier { | |
180 PaymentItem? total; | |
181 array<PaymentItem> additional_display_items; | |
182 PaymentMethodData method_data; | |
183 }; | |
184 | |
185 struct PaymentDetails { | |
186 PaymentItem? total; | |
187 array<PaymentItem> display_items; | |
188 array<PaymentShippingOption> shipping_options; | |
189 array<PaymentDetailsModifier> modifiers; | |
190 string error = ""; | |
191 }; | |
192 | |
193 enum PaymentShippingType { | |
194 SHIPPING, | |
195 DELIVERY, | |
196 PICKUP | |
197 }; | |
198 | |
199 struct PaymentOptions { | |
200 bool request_payer_name; | |
201 bool request_payer_email; | |
202 bool request_payer_phone; | |
203 bool request_shipping; | |
204 PaymentShippingType shipping_type; | |
205 }; | |
206 | |
207 enum PaymentComplete { | |
208 SUCCESS, | |
209 FAIL, | |
210 UNKNOWN | |
211 }; | |
212 | |
213 interface PaymentRequest { | |
214 Init(PaymentRequestClient client, | |
215 array<PaymentMethodData> method_data, | |
216 PaymentDetails details, | |
217 PaymentOptions options); | |
218 Show(); | |
219 UpdateWith(PaymentDetails details); | |
220 Abort(); | |
221 Complete(PaymentComplete result); | |
222 CanMakePayment(); | |
223 }; | |
OLD | NEW |