naiveproxy/third_party/blink/public/mojom/payments/payment_request.mojom
2018-12-09 21:59:24 -05:00

218 lines
5.8 KiB
Plaintext

// 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.
[JavaPackage="org.chromium.payments.mojom"]
module payments.mojom;
import "components/payments/mojom/payment_request_data.mojom";
struct PaymentResponse {
string method_name;
// Payment method specific JSON string that is built either by the browser or
// a payment app, for example Android Pay. Browser ensures that the string can
// be successfully parsed into base::JSONParser. Renderer parses this string
// via v8::JSON::Parse() and hands off the result to the merchant website.
// There's no one format for this object, so more specific types cannot be
// used. A simple example:
//
// {"nameOnCard": "Jon Doe", "pan": "4111 1111 1111 1111"}
string stringified_details;
PaymentAddress? shipping_address;
string? shipping_option;
string? payer_name;
string? payer_email;
string? payer_phone;
};
enum PaymentErrorReason {
UNKNOWN,
USER_CANCEL,
NOT_SUPPORTED,
ALREADY_SHOWING
};
enum CanMakePaymentQueryResult {
CAN_MAKE_PAYMENT,
CANNOT_MAKE_PAYMENT,
QUERY_QUOTA_EXCEEDED,
// Used only on localhost and file:// schemes to warn web developer that the
// query quota has exceeded, but Chrome is returning an answer anyway.
WARNING_CAN_MAKE_PAYMENT,
WARNING_CANNOT_MAKE_PAYMENT,
};
interface PaymentRequestClient {
OnShippingAddressChange(PaymentAddress address);
OnShippingOptionChange(string shipping_option_id);
OnPaymentResponse(PaymentResponse response);
OnError(PaymentErrorReason error);
OnComplete();
OnAbort(bool aborted_successfully);
OnCanMakePayment(CanMakePaymentQueryResult result);
WarnNoFavicon();
};
struct PaymentItem {
string label;
PaymentCurrencyAmount amount;
bool pending;
};
struct PaymentShippingOption {
string id;
string label;
PaymentCurrencyAmount amount;
bool selected;
};
enum AndroidPayEnvironment {
PRODUCTION,
TEST
};
enum AndroidPayCardNetwork {
AMEX,
DISCOVER,
MASTERCARD,
VISA
};
enum AndroidPayTokenization {
UNSPECIFIED,
GATEWAY_TOKEN,
NETWORK_TOKEN
};
struct AndroidPayTokenizationParameter {
string? key;
string? value;
};
enum BasicCardNetwork {
AMEX,
DINERS,
DISCOVER,
JCB,
MASTERCARD,
MIR,
UNIONPAY,
VISA
};
enum BasicCardType {
CREDIT,
DEBIT,
PREPAID
};
struct PaymentMethodData {
string supported_method;
// A JSON string built by the renderer from a JavaScript object that the
// merchant website provides. The renderer uses
// blink::JSONObject::toJSONString() to generate this string. The browser does
// not parse the string and passes it as-is directly to payment apps. There's
// no one format for this object, so more specific types cannot be used. A
// simple example:
//
// {"gateway": "stripe"}
string stringified_data;
// Android Pay specific method data is parsed in the renderer.
// https://developers.google.com/web/fundamentals/getting-started/primers/payment-request/android-pay
// TODO(rouslan): Stop parsing Android Pay data. http://crbug.com/620173
AndroidPayEnvironment environment;
string? merchant_name;
string? merchant_id;
array<AndroidPayCardNetwork> allowed_card_networks;
AndroidPayTokenization tokenization_type;
array<AndroidPayTokenizationParameter> parameters;
// Value of 0 means the merchant did not specify or it was an invalid value.
int32 min_google_play_services_version;
// Value of 0 means the merchant did not specify or it was an invalid value.
int32 api_version;
// Basic card specific method data is parsed in the renderer.
array<BasicCardNetwork> supported_networks;
array<BasicCardType> supported_types;
};
struct PaymentDetailsModifier {
PaymentItem? total;
array<PaymentItem> additional_display_items;
PaymentMethodData method_data;
};
struct PaymentDetails {
PaymentItem? total;
array<PaymentItem> display_items;
array<PaymentShippingOption> shipping_options;
array<PaymentDetailsModifier> modifiers;
string error = "";
// Identifier identifying the payment request, to be exposed
// to payment apps. It is optional since this structure is used
// by PaymentDetailsUpdate (next to PaymentDetailsInit) but
// PaymentDetailsUpdate has no id.
string? id;
};
enum PaymentShippingType {
SHIPPING,
DELIVERY,
PICKUP
};
struct PaymentOptions {
bool request_payer_name;
bool request_payer_email;
bool request_payer_phone;
bool request_shipping;
PaymentShippingType shipping_type;
};
enum PaymentComplete {
FAIL,
SUCCESS,
UNKNOWN
};
interface PaymentRequest {
// Instantiates the renderer-browser connection with the information from the
// JavaScript constructor of PaymentRequest.
Init(PaymentRequestClient client,
array<PaymentMethodData> method_data,
PaymentDetails details,
PaymentOptions options);
// Shows the user interface with the payment details.
Show(bool is_user_gesture);
// Updates the payment details in response to new shipping address or shipping
// option.
UpdateWith(PaymentDetails details);
// Called when the merchant received a new shipping address or shipping
// option, but did not update the payment details in response.
NoUpdatedPaymentDetails();
// Requests to abort the checkout in process, for example because the item
// went out of stock.
Abort();
// Closes the payment user interface.
Complete(PaymentComplete result);
// Called when the merchant calls explicitly retry() method in JavaScript.
// The |errors| contains merchant-defined error message strings. They are
// used to indicate to the end-user that something is wrong with the data of
// the payment response.
Retry(PaymentValidationErrors errors);
// Queries whether the user has a form of payment on file.
CanMakePayment();
};