OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.payments; | 5 package org.chromium.chrome.browser.payments; |
6 | 6 |
7 import android.graphics.drawable.Drawable; | |
8 | |
9 import org.json.JSONObject; | |
10 | |
11 import org.chromium.chrome.browser.payments.ui.PaymentOption; | 7 import org.chromium.chrome.browser.payments.ui.PaymentOption; |
12 import org.chromium.payments.mojom.PaymentItem; | 8 import org.chromium.payments.mojom.PaymentItem; |
13 | 9 |
| 10 import org.json.JSONObject; |
| 11 |
14 import java.util.List; | 12 import java.util.List; |
15 | 13 |
16 /** | 14 /** |
17 * The base class for a single payment instrument, e.g., a credit card. | 15 * The base class for a single payment instrument, e.g., a credit card. |
18 */ | 16 */ |
19 public abstract class PaymentInstrument extends PaymentOption { | 17 public abstract class PaymentInstrument extends PaymentOption { |
20 /** | 18 /** |
21 * The interface for the requester of instrument details. | 19 * The interface for the requester of instrument details. |
22 */ | 20 */ |
23 public interface DetailsCallback { | 21 public interface DetailsCallback { |
24 /** | 22 /** |
25 * Called after retrieving instrument details. | 23 * Called after retrieving instrument details. |
26 * | 24 * |
27 * @param methodName Method name. For example, "visa". | 25 * @param methodName Method name. For example, "visa". |
28 * @param stringifiedDetails JSON-serialized object. For example, {"card
": "123"}. | 26 * @param stringifiedDetails JSON-serialized object. For example, {"card
": "123"}. |
29 */ | 27 */ |
30 void onInstrumentDetailsReady(String methodName, String stringifiedDetai
ls); | 28 void onInstrumentDetailsReady(String methodName, String stringifiedDetai
ls); |
31 | 29 |
32 /** | 30 /** |
33 * Called if unable to retrieve instrument details. | 31 * Called if unable to retrieve instrument details. |
34 */ | 32 */ |
35 void onInstrumentDetailsError(); | 33 void onInstrumentDetailsError(); |
36 } | 34 } |
37 | 35 |
38 protected PaymentInstrument(String id, String label, String sublabel, Drawab
le icon) { | 36 protected PaymentInstrument(String id, String label, String sublabel, int ic
on) { |
39 super(id, label, sublabel, icon); | 37 super(id, label, sublabel, icon); |
40 } | 38 } |
41 | 39 |
42 /** | 40 /** |
43 * Returns the method name for this instrument, e.g., "visa" or "mastercard"
in basic card | 41 * Returns the method name for this instrument, e.g., "visa" or "mastercard"
in basic card |
44 * payments: https://w3c.github.io/browser-payment-api/specs/basic-card-paym
ent.html#method-id | 42 * payments: https://w3c.github.io/browser-payment-api/specs/basic-card-paym
ent.html#method-id |
45 * | 43 * |
46 * @return The method name for this instrument. | 44 * @return The method name for this instrument. |
47 */ | 45 */ |
48 public abstract String getMethodName(); | 46 public abstract String getMethodName(); |
(...skipping 11 matching lines...) Expand all Loading... |
60 */ | 58 */ |
61 public abstract void getDetails(String merchantName, String origin, PaymentI
tem total, | 59 public abstract void getDetails(String merchantName, String origin, PaymentI
tem total, |
62 List<PaymentItem> cart, JSONObject details, DetailsCallback callback
); | 60 List<PaymentItem> cart, JSONObject details, DetailsCallback callback
); |
63 | 61 |
64 /** | 62 /** |
65 * Cleans up any resources held by the payment instrument. For example, clos
es server | 63 * Cleans up any resources held by the payment instrument. For example, clos
es server |
66 * connections. | 64 * connections. |
67 */ | 65 */ |
68 public abstract void dismiss(); | 66 public abstract void dismiss(); |
69 } | 67 } |
OLD | NEW |