Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentInstrument.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentInstrument.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentInstrument.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bf4208d81d97460f2984b30358fb744bf30b9ece |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentInstrument.java |
| @@ -0,0 +1,65 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.chrome.browser.payments; |
| + |
| +import org.chromium.chrome.browser.payments.ui.LineItem; |
| +import org.chromium.chrome.browser.payments.ui.PaymentOption; |
| + |
| +import org.json.JSONObject; |
| + |
| +import java.util.ArrayList; |
| + |
| +/** |
| + * The base class for a single payment instrument, e.g., a credit card. |
| + */ |
| +public abstract class PaymentInstrument extends PaymentOption { |
| + /** |
| + * The interface for the requester of instrument details. |
| + */ |
| + public interface DetailsCallback { |
| + /** |
| + * Called after retrieving instrument details. |
| + * |
| + * @param methodName Method name. For example, "visa". |
| + * @param stringifiedDetails JSON-serialized object. For example, {"card": "123"}. |
| + */ |
| + void onInstrumentDetailsReady(String methodName, String stringifiedDetails); |
| + |
| + /** |
| + * Called if unable to retrieve instrument details. |
| + */ |
| + void onInstrumentDetailsError(); |
| + } |
| + |
| + protected PaymentInstrument(String id, String label, String sublabel, int icon) { |
| + super(id, label, sublabel, icon); |
| + } |
| + |
| + /** |
| + * Returns the method name for this instrument, e.g., "visa" or "mastercard" in basic card |
| + * payments: https://w3c.github.io/browser-payment-api/specs/basic-card-payment.html#method-id |
| + * |
| + * @return The method name for this instrument. |
| + */ |
| + public abstract String getMethodName(); |
| + |
| + /** |
| + * Asynchronously retrieves the instrument details and invokes the callback with the result. |
| + * |
| + * @param merchantName The name of the merchant. |
| + * @param origin The origin of this merchant. |
| + * @param items The line items, the last of which is the total. |
| + * @param details The payment-method specific data. |
| + * @param callback The object that will receive the instrument details. |
| + */ |
| + public abstract void getDetails(String merchantName, String origin, ArrayList<LineItem> items, |
|
Ted C
2016/04/22 03:59:37
List vs ArrayList comment as before
please use gerrit instead
2016/04/25 19:22:30
Done.
|
| + JSONObject details, DetailsCallback callback); |
| + |
| + /** |
| + * Cleans up any resources held by the payment instrument. For example, closes server |
| + * connections. |
| + */ |
| + public abstract void dismiss(); |
| +} |