[Payment Request] Moves Payment Request test data to components for iOS use
chrome/test/data/payments/* -> components/test/data/payments/* which allows iOS to use the Payment Request test data Also: - Fixes ESLint errors in the resource files. - Removes a rule from the .eslintrc.js because it was being checked by the js_checker.py for JS style errors: https://cs.chromium.org/chromium/src/tools/web_dev_style/js_checker.py?l=43 - Replaces arrow functions with regular functions (e.g., ()=>{} to function(){}) because they don't work in iOS9: https://chromium.googlesource.com/chromium/src/+/master/docs/es6_chromium.md#Arrow-Functions - Replaces instances of let with var as let is not supported in iOS9. Bug: 602666 Change-Id: I0354c969661359581630893a3e43561b7fc916c9 Reviewed-on: https://chromium-review.googlesource.com/572104 Commit-Queue: mahmadi <mahmadi@chromium.org> Reviewed-by: Sylvain Defresne <sdefresne@chromium.org> Reviewed-by: Rouslan Solomakhin <rouslan@chromium.org> Reviewed-by: Bernhard Bauer <bauerb@chromium.org> Reviewed-by: mahmadi <mahmadi@chromium.org> Cr-Commit-Position: refs/heads/master@{#487658}
This commit is contained in:

committed by
Commit Bot

parent
01f386bfb5
commit
2b45276fe2
WATCHLISTS
chrome
components/test/data/payments
.eslintrc.jsPRESUBMIT.pyabort.jsalicepay_bobpay_charliepay_and_cards.jsapp.jsonblob_url.jsbobpay.jsbobpay_and_basic_card_with_basic_card_modifiers.jsbobpay_and_basic_card_with_modifiers.jsbobpay_and_cards.jsbobpay_ui_skip.jsbobpay_ui_skip_preload.jscan_make_payment_metrics.jscan_make_payment_query.jscan_make_payment_query_bobpay.jscan_make_payment_query_cc.jscontact_details.jscontact_details_and_free_shipping.jsdebit.jsdynamic_shipping.jsemail.jsemail_and_free_shipping.jsemail_and_phone.jsextra_shipping_options.jsfail_complete.jsfree_shipping.jsinitiated.jsinitiated_test.htmllong_id.jsmetrics.jsmodifier.jsmultiple_show.jsname.jsname_and_free_shipping.jsno_shipping.jspayment-manifest.jsonpayment_method_identifier.jspayment_request_abort_test.htmlpayment_request_alicepay_bobpay_charliepay_and_cards_test.htmlpayment_request_blob_url_test.htmlpayment_request_bobpay_and_basic_card_with_basic_card_modifiers_test.htmlpayment_request_bobpay_and_basic_card_with_modifiers_test.htmlpayment_request_bobpay_and_cards_test.htmlpayment_request_bobpay_test.htmlpayment_request_bobpay_ui_skip_preload_test.htmlpayment_request_bobpay_ui_skip_test.htmlpayment_request_can_make_payment_metrics_test.htmlpayment_request_can_make_payment_query_bobpay_test.htmlpayment_request_can_make_payment_query_cc_test.htmlpayment_request_can_make_payment_query_test.htmlpayment_request_contact_details_and_free_shipping_test.htmlpayment_request_contact_details_test.htmlpayment_request_debit_test.htmlpayment_request_dynamic_shipping_test.htmlpayment_request_email_and_free_shipping_test.htmlpayment_request_email_and_phone_test.htmlpayment_request_email_test.htmlpayment_request_extra_shipping_options_test.htmlpayment_request_fail_complete_test.htmlpayment_request_free_shipping_test.htmlpayment_request_id.jspayment_request_id_test.htmlpayment_request_iframe.htmlpayment_request_long_id_test.htmlpayment_request_main.htmlpayment_request_metrics_test.htmlpayment_request_modifier_test.htmlpayment_request_multiple_requests.htmlpayment_request_multiple_show_test.htmlpayment_request_name_and_free_shipping_test.htmlpayment_request_name_test.htmlpayment_request_no_shipping_test.htmlpayment_request_payment_method_identifier_test.htmlpayment_request_phone_and_free_shipping_test.htmlpayment_request_phone_test.htmlpayment_request_shipping_address_change_test.htmlpayment_request_show_twice_test.htmlphone.jsphone_and_free_shipping.jsshipping_address_change.jsshow_twice.jsstyle.cssutil.jswebpaywebpay.mock-http-headers
@@ -894,7 +894,7 @@
|
|||||||
'|chrome/android/javatests/src/org/chromium/chrome/browser/payments'\
|
'|chrome/android/javatests/src/org/chromium/chrome/browser/payments'\
|
||||||
'|chrome/browser/payments'\
|
'|chrome/browser/payments'\
|
||||||
'|chrome/browser/ui/views/payments'\
|
'|chrome/browser/ui/views/payments'\
|
||||||
'|chrome/test/data/payments'\
|
'|components/payments/test/data'\
|
||||||
'|components/payments'\
|
'|components/payments'\
|
||||||
'|content/browser/payments'\
|
'|content/browser/payments'\
|
||||||
'|content/test/data/payments'\
|
'|content/test/data/payments'\
|
||||||
|
@@ -529,11 +529,11 @@ android_library("chrome_test_java") {
|
|||||||
"//chrome/test/data/image_search/valid.png",
|
"//chrome/test/data/image_search/valid.png",
|
||||||
"//chrome/test/data/navigation_interception/",
|
"//chrome/test/data/navigation_interception/",
|
||||||
"//chrome/test/data/notifications/",
|
"//chrome/test/data/notifications/",
|
||||||
"//chrome/test/data/payments/",
|
|
||||||
"//chrome/test/data/popup_blocker/",
|
"//chrome/test/data/popup_blocker/",
|
||||||
"//chrome/test/data/push_messaging/",
|
"//chrome/test/data/push_messaging/",
|
||||||
"//chrome/test/data/translate/",
|
"//chrome/test/data/translate/",
|
||||||
"//chrome/test/media_router/resources/",
|
"//chrome/test/media_router/resources/",
|
||||||
|
"//components/test/data/payments/",
|
||||||
"//content/test/data/android/geolocation.html",
|
"//content/test/data/android/geolocation.html",
|
||||||
"//content/test/data/android/media_permissions.html",
|
"//content/test/data/android/media_permissions.html",
|
||||||
"//content/test/data/android/permission_navigation.html",
|
"//content/test/data/android/permission_navigation.html",
|
||||||
|
11
chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentManifestDownloaderTest.java
11
chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentManifestDownloaderTest.java
@@ -124,7 +124,7 @@ public class PaymentManifestDownloaderTest implements ManifestDownloadCallback {
|
|||||||
@Test
|
@Test
|
||||||
@Feature({"Payments"})
|
@Feature({"Payments"})
|
||||||
public void testDownloadWebAppManifest() throws Throwable {
|
public void testDownloadWebAppManifest() throws Throwable {
|
||||||
final URI uri = new URI(mServer.getURL("/chrome/test/data/payments/app.json"));
|
final URI uri = new URI(mServer.getURL("/components/test/data/payments/app.json"));
|
||||||
mRule.runOnUiThread(new Runnable() {
|
mRule.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -166,7 +166,7 @@ public class PaymentManifestDownloaderTest implements ManifestDownloadCallback {
|
|||||||
@Test
|
@Test
|
||||||
@Feature({"Payments"})
|
@Feature({"Payments"})
|
||||||
public void testDownloadPaymentMethodManifest() throws Throwable {
|
public void testDownloadPaymentMethodManifest() throws Throwable {
|
||||||
final URI uri = new URI(mServer.getURL("/chrome/test/data/payments/webpay"));
|
final URI uri = new URI(mServer.getURL("/components/test/data/payments/webpay"));
|
||||||
mRule.runOnUiThread(new Runnable() {
|
mRule.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -210,9 +210,10 @@ public class PaymentManifestDownloaderTest implements ManifestDownloadCallback {
|
|||||||
@Feature({"Payments"})
|
@Feature({"Payments"})
|
||||||
public void testSeveralDownloadsAtOnce() throws Throwable {
|
public void testSeveralDownloadsAtOnce() throws Throwable {
|
||||||
final URI paymentMethodUri1 = new URI(mServer.getURL("/no-such-payment-method-name"));
|
final URI paymentMethodUri1 = new URI(mServer.getURL("/no-such-payment-method-name"));
|
||||||
final URI paymentMethodUri2 = new URI(mServer.getURL("/chrome/test/data/payments/webpay"));
|
final URI paymentMethodUri2 =
|
||||||
|
new URI(mServer.getURL("/components/test/data/payments/webpay"));
|
||||||
final URI webAppUri1 = new URI(mServer.getURL("/no-such-app.json"));
|
final URI webAppUri1 = new URI(mServer.getURL("/no-such-app.json"));
|
||||||
final URI webAppUri2 = new URI(mServer.getURL("/chrome/test/data/payments/app.json"));
|
final URI webAppUri2 = new URI(mServer.getURL("/components/test/data/payments/app.json"));
|
||||||
mRule.runOnUiThread(new Runnable() {
|
mRule.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -235,4 +236,4 @@ public class PaymentManifestDownloaderTest implements ManifestDownloadCallback {
|
|||||||
Assert.assertEquals(PAYMENT_METHOD_MANIFEST, mPaymentMethodManifest);
|
Assert.assertEquals(PAYMENT_METHOD_MANIFEST, mPaymentMethodManifest);
|
||||||
Assert.assertEquals(WEB_APP_MANIFEST, mWebAppManifest);
|
Assert.assertEquals(WEB_APP_MANIFEST, mWebAppManifest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -132,7 +132,7 @@ final class PaymentRequestTestCommon implements PaymentRequestObserverForTest,
|
|||||||
mTestFilePath = testFileName.startsWith("data:")
|
mTestFilePath = testFileName.startsWith("data:")
|
||||||
? testFileName
|
? testFileName
|
||||||
: UrlUtils.getIsolatedTestFilePath(
|
: UrlUtils.getIsolatedTestFilePath(
|
||||||
String.format("chrome/test/data/payments/%s", testFileName));
|
String.format("components/test/data/payments/%s", testFileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startMainActivity() throws InterruptedException {
|
public void startMainActivity() throws InterruptedException {
|
||||||
|
@@ -43,7 +43,8 @@ class SitePerProcessPaymentsBrowserTest : public InProcessBrowserTest {
|
|||||||
host_resolver()->AddRule("*", "127.0.0.1");
|
host_resolver()->AddRule("*", "127.0.0.1");
|
||||||
ASSERT_TRUE(https_server_->InitializeAndListen());
|
ASSERT_TRUE(https_server_->InitializeAndListen());
|
||||||
content::SetupCrossSiteRedirector(https_server_.get());
|
content::SetupCrossSiteRedirector(https_server_.get());
|
||||||
https_server_->ServeFilesFromSourceDirectory("chrome/test/data/payments");
|
https_server_->ServeFilesFromSourceDirectory(
|
||||||
|
"components/test/data/payments");
|
||||||
https_server_->StartAcceptingConnections();
|
https_server_->StartAcceptingConnections();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -97,7 +97,7 @@ void PaymentRequestBrowserTestBase::SetUpOnMainThread() {
|
|||||||
host_resolver()->AddRule("a.com", "127.0.0.1");
|
host_resolver()->AddRule("a.com", "127.0.0.1");
|
||||||
host_resolver()->AddRule("b.com", "127.0.0.1");
|
host_resolver()->AddRule("b.com", "127.0.0.1");
|
||||||
ASSERT_TRUE(https_server_->InitializeAndListen());
|
ASSERT_TRUE(https_server_->InitializeAndListen());
|
||||||
https_server_->ServeFilesFromSourceDirectory("chrome/test/data/payments");
|
https_server_->ServeFilesFromSourceDirectory("components/test/data/payments");
|
||||||
https_server_->StartAcceptingConnections();
|
https_server_->StartAcceptingConnections();
|
||||||
|
|
||||||
NavigateTo(test_file_path_);
|
NavigateTo(test_file_path_);
|
||||||
|
@@ -87,7 +87,7 @@ class PaymentRequestBrowserTestBase
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Test will open a browser window to |test_file_path| (relative to
|
// Test will open a browser window to |test_file_path| (relative to
|
||||||
// chrome/test/data/payments).
|
// components/test/data/payments).
|
||||||
explicit PaymentRequestBrowserTestBase(const std::string& test_file_path);
|
explicit PaymentRequestBrowserTestBase(const std::string& test_file_path);
|
||||||
~PaymentRequestBrowserTestBase() override;
|
~PaymentRequestBrowserTestBase() override;
|
||||||
|
|
||||||
|
@@ -1701,6 +1701,7 @@ test("browser_tests") {
|
|||||||
"//chrome/browser/policy/test/policy_testserver.py",
|
"//chrome/browser/policy/test/policy_testserver.py",
|
||||||
"//chrome/common/extensions/docs/examples/apps/calculator/",
|
"//chrome/common/extensions/docs/examples/apps/calculator/",
|
||||||
"//chrome/third_party/mock4js/",
|
"//chrome/third_party/mock4js/",
|
||||||
|
"//components/test/data/payments/",
|
||||||
"//components/test/data/update_client/",
|
"//components/test/data/update_client/",
|
||||||
"//content/test/data/",
|
"//content/test/data/",
|
||||||
"//google_apis/test/",
|
"//google_apis/test/",
|
||||||
|
@@ -1,17 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2017 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** Requests payment via a blob URL. */
|
|
||||||
function buy() { // eslint-disable-line no-unused-vars
|
|
||||||
const spoof = function() {
|
|
||||||
const payload = 'PGh0bWw+PGhlYWQ+PG1ldGEgbmFtZT0idmlld3BvcnQiIGNvbnRlbnQ9IndpZHRoPWRldmljZS13aWR0aCwgaW5pdGlhbC1zY2FsZT0yLCBtYXhpbXVtLXNjYWxlPTIiPjwvaGVhZD48Ym9keT48ZGl2IGlkPSJyZXN1bHQiPjwvZGl2PjxzY3JpcHQ+dHJ5IHsgIG5ldyBQYXltZW50UmVxdWVzdChbe3N1cHBvcnRlZE1ldGhvZHM6IFsiYmFzaWMtY2FyZCJdfV0sICAgIHt0b3RhbDoge2xhYmVsOiAiVCIsIGFtb3VudDoge2N1cnJlbmN5OiAiVVNEIiwgdmFsdWU6ICIxLjAwIn19fSkgIC5zaG93KCkgIC50aGVuKGZ1bmN0aW9uKGluc3RydW1lbnRSZXNwb25zZSkgeyAgICBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgicmVzdWx0IikuaW5uZXJIVE1MID0gIlJlc29sdmVkIjsgIH0pLmNhdGNoKGZ1bmN0aW9uKGUpIHsgICAgZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoInJlc3VsdCIpLmlubmVySFRNTCA9ICJSZWplY3RlZDogIiArIGU7ICB9KTt9IGNhdGNoKGUpIHsgIGRvY3VtZW50LmdldEVsZW1lbnRCeUlkKCJyZXN1bHQiKS5pbm5lckhUTUwgPSAiRXhjZXB0aW9uOiAiICsgZTt9PC9zY3JpcHQ+PC9ib2R5PjwvaHRtbD4=';
|
|
||||||
document.write(atob(payload));
|
|
||||||
};
|
|
||||||
window.location.href =
|
|
||||||
URL.createObjectURL(new Blob(['<script>(', spoof, ')();</script>'], {
|
|
||||||
type: 'text/html',
|
|
||||||
}));
|
|
||||||
}
|
|
@@ -1,66 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2017 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds PaymentRequest for Bob Pay, but does not show any UI yet.
|
|
||||||
*
|
|
||||||
* @return {PaymentRequest} The PaymentRequest object.
|
|
||||||
*/
|
|
||||||
function initPaymentRequest() {
|
|
||||||
let supportedInstruments = [{
|
|
||||||
supportedMethods: ['https://bobpay.com'],
|
|
||||||
}];
|
|
||||||
|
|
||||||
let details = {
|
|
||||||
total: {
|
|
||||||
label: 'Donation',
|
|
||||||
amount: {
|
|
||||||
currency: 'USD',
|
|
||||||
value: '55.00',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
displayItems: [{
|
|
||||||
label: 'Original donation amount',
|
|
||||||
amount: {
|
|
||||||
currency: 'USD',
|
|
||||||
value: '65.00',
|
|
||||||
},
|
|
||||||
}, {
|
|
||||||
label: 'Friends and family discount',
|
|
||||||
amount: {
|
|
||||||
currency: 'USD',
|
|
||||||
value: '-10.00',
|
|
||||||
},
|
|
||||||
}],
|
|
||||||
};
|
|
||||||
|
|
||||||
return new PaymentRequest(supportedInstruments, details);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Launches the PaymentRequest UI with Bob Pay as the only payment method.
|
|
||||||
* Preloads the second instance of PaymentRequest while the first instance is
|
|
||||||
* showing.
|
|
||||||
*/
|
|
||||||
function buy() { // eslint-disable-line no-unused-vars
|
|
||||||
let request = initPaymentRequest();
|
|
||||||
request.show()
|
|
||||||
.then(function(instrumentResponse) {
|
|
||||||
window.setTimeout(function() {
|
|
||||||
instrumentResponse.complete('success')
|
|
||||||
.then(function() {
|
|
||||||
print(JSON.stringify(instrumentResponse, undefined, 2));
|
|
||||||
})
|
|
||||||
.catch(function(err) {
|
|
||||||
print(err);
|
|
||||||
});
|
|
||||||
}, 500);
|
|
||||||
})
|
|
||||||
.catch(function(err) {
|
|
||||||
print(err);
|
|
||||||
});
|
|
||||||
request = initPaymentRequest();
|
|
||||||
}
|
|
@@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2017 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds a payment request for a debit card.
|
|
||||||
* @return {!PaymentRequest} A payment request for a debit card.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function buildPaymentRequest() {
|
|
||||||
return new PaymentRequest([{
|
|
||||||
supportedMethods: ['basic-card'],
|
|
||||||
data: {
|
|
||||||
supportedTypes: ['debit'],
|
|
||||||
},
|
|
||||||
}], {
|
|
||||||
total: {
|
|
||||||
label: 'Total',
|
|
||||||
amount: {
|
|
||||||
currency: 'USD',
|
|
||||||
value: '1.00',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Requests payment via a debit card. */
|
|
||||||
function buy() { // eslint-disable-line no-unused-vars
|
|
||||||
try {
|
|
||||||
buildPaymentRequest()
|
|
||||||
.show()
|
|
||||||
.then(function(response) {
|
|
||||||
response.complete()
|
|
||||||
.then(function() {
|
|
||||||
print(JSON.stringify(response, undefined, 2));
|
|
||||||
})
|
|
||||||
.catch(function(error) {
|
|
||||||
print(error);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(function(error) {
|
|
||||||
print(error);
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
print(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Checks whether payment via a debit card is possible. */
|
|
||||||
function canMakePayment() { // eslint-disable-line no-unused-vars
|
|
||||||
try {
|
|
||||||
buildPaymentRequest()
|
|
||||||
.canMakePayment()
|
|
||||||
.then(function(result) {
|
|
||||||
print(result);
|
|
||||||
})
|
|
||||||
.catch(function(error) {
|
|
||||||
print(error);
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
print(error);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* global PaymentRequest:false */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Launches the PaymentRequest UI that requests an email address and offers free
|
|
||||||
* shipping worldwide.
|
|
||||||
*/
|
|
||||||
function buy() { // eslint-disable-line no-unused-vars
|
|
||||||
try {
|
|
||||||
const details = {
|
|
||||||
total: {
|
|
||||||
label: 'Total',
|
|
||||||
amount: {
|
|
||||||
currency: 'USD',
|
|
||||||
value: '5.00'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
shippingOptions: [{
|
|
||||||
id: 'freeShippingOption',
|
|
||||||
label: 'Free global shipping',
|
|
||||||
amount: {
|
|
||||||
currency: 'USD',
|
|
||||||
value: '0'
|
|
||||||
},
|
|
||||||
selected: true
|
|
||||||
}]
|
|
||||||
};
|
|
||||||
const request = new PaymentRequest(
|
|
||||||
[{
|
|
||||||
supportedMethods: ['visa']
|
|
||||||
}], details, {
|
|
||||||
requestPayerEmail: true,
|
|
||||||
requestShipping: true
|
|
||||||
});
|
|
||||||
request.addEventListener('shippingaddresschange', function(e) {
|
|
||||||
e.updateWith(details);
|
|
||||||
});
|
|
||||||
request.show()
|
|
||||||
.then(function(resp) {
|
|
||||||
resp.complete('success')
|
|
||||||
.then(function() {
|
|
||||||
print(JSON.stringify(resp, undefined, 2));
|
|
||||||
})
|
|
||||||
.catch(function(error) {
|
|
||||||
print(error);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(function(error) {
|
|
||||||
print(error);
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
print(error.message);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,244 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* global PaymentRequest:false */
|
|
||||||
|
|
||||||
let request;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Launches the PaymentRequest UI that accepts credit cards.
|
|
||||||
*/
|
|
||||||
function ccBuy() { // eslint-disable-line no-unused-vars
|
|
||||||
try {
|
|
||||||
let details = {
|
|
||||||
total: {
|
|
||||||
label: 'Total',
|
|
||||||
amount: {
|
|
||||||
currency: 'USD',
|
|
||||||
value: '5.00',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
shippingOptions: [{
|
|
||||||
id: 'freeShippingOption',
|
|
||||||
label: 'Free global shipping',
|
|
||||||
amount: {
|
|
||||||
currency: 'USD',
|
|
||||||
value: '0',
|
|
||||||
},
|
|
||||||
selected: true,
|
|
||||||
}],
|
|
||||||
};
|
|
||||||
request = new PaymentRequest(
|
|
||||||
[{
|
|
||||||
supportedMethods: ['visa'],
|
|
||||||
}], {
|
|
||||||
total: {
|
|
||||||
label: 'Total',
|
|
||||||
amount: {
|
|
||||||
currency: 'USD',
|
|
||||||
value: '5.00',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
shippingOptions: [{
|
|
||||||
id: 'freeShippingOption',
|
|
||||||
label: 'Free global shipping',
|
|
||||||
amount: {
|
|
||||||
currency: 'USD',
|
|
||||||
value: '0',
|
|
||||||
},
|
|
||||||
selected: true,
|
|
||||||
}],
|
|
||||||
}, {
|
|
||||||
requestShipping: true,
|
|
||||||
});
|
|
||||||
request.show()
|
|
||||||
.then(function(resp) {
|
|
||||||
return resp.complete('success');
|
|
||||||
}).then(function() {
|
|
||||||
print(JSON.stringify(resp, undefined, 2));
|
|
||||||
}).catch(function(error) {
|
|
||||||
print(error);
|
|
||||||
});
|
|
||||||
request.addEventListener('shippingaddresschange', function(e) {
|
|
||||||
e.updateWith(new Promise(function(resolve) {
|
|
||||||
// No changes in price based on shipping address change.
|
|
||||||
resolve(details);
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
print(error.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Launches the PaymentRequest UI which accepts only Android Pay.
|
|
||||||
*/
|
|
||||||
function androidPayBuy() { // eslint-disable-line no-unused-vars
|
|
||||||
try {
|
|
||||||
request = new PaymentRequest(
|
|
||||||
[{
|
|
||||||
supportedMethods: ['https://android.com/pay'],
|
|
||||||
}], {
|
|
||||||
total: {
|
|
||||||
label: 'Total',
|
|
||||||
amount: {
|
|
||||||
currency: 'USD',
|
|
||||||
value: '5.00',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
shippingOptions: [{
|
|
||||||
id: 'freeShippingOption',
|
|
||||||
label: 'Free global shipping',
|
|
||||||
amount: {
|
|
||||||
currency: 'USD',
|
|
||||||
value: '0',
|
|
||||||
},
|
|
||||||
selected: true,
|
|
||||||
}],
|
|
||||||
}, {
|
|
||||||
requestShipping: true,
|
|
||||||
});
|
|
||||||
request.show()
|
|
||||||
.then(function(resp) {
|
|
||||||
return resp.complete('success');
|
|
||||||
}).then(function() {
|
|
||||||
print(JSON.stringify(resp, undefined, 2));
|
|
||||||
}).catch(function(error) {
|
|
||||||
print(error);
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
print(error.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Launches the PaymentRequest UI which accepts only Android Pay and does not
|
|
||||||
* require any other information.
|
|
||||||
*/
|
|
||||||
function androidPaySkipUiBuy() { // eslint-disable-line no-unused-vars
|
|
||||||
try {
|
|
||||||
request = new PaymentRequest(
|
|
||||||
[{
|
|
||||||
supportedMethods: ['https://android.com/pay'],
|
|
||||||
}], {
|
|
||||||
total: {
|
|
||||||
label: 'Total',
|
|
||||||
amount: {
|
|
||||||
currency: 'USD',
|
|
||||||
value: '5.00',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
request.show()
|
|
||||||
.then(function(resp) {
|
|
||||||
return resp.complete('success');
|
|
||||||
}).then(function() {
|
|
||||||
print(JSON.stringify(resp, undefined, 2));
|
|
||||||
}).catch(function(error) {
|
|
||||||
print(error);
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
print(error.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Launches the PaymentRequest UI which accepts only an unsupported payment
|
|
||||||
* method.
|
|
||||||
*/
|
|
||||||
function noSupported() { // eslint-disable-line no-unused-vars
|
|
||||||
try {
|
|
||||||
request = new PaymentRequest(
|
|
||||||
[{
|
|
||||||
supportedMethods: ['https://randompay.com'],
|
|
||||||
}], {
|
|
||||||
total: {
|
|
||||||
label: 'Total',
|
|
||||||
amount: {
|
|
||||||
currency: 'USD',
|
|
||||||
value: '5.00',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
shippingOptions: [{
|
|
||||||
id: 'freeShippingOption',
|
|
||||||
label: 'Free global shipping',
|
|
||||||
amount: {
|
|
||||||
currency: 'USD',
|
|
||||||
value: '0',
|
|
||||||
},
|
|
||||||
selected: true,
|
|
||||||
}],
|
|
||||||
}, {
|
|
||||||
requestShipping: true,
|
|
||||||
});
|
|
||||||
request.show()
|
|
||||||
.then(function(resp) {
|
|
||||||
return resp.complete('success');
|
|
||||||
}).then(function() {
|
|
||||||
print(JSON.stringify(resp, undefined, 2));
|
|
||||||
}).catch(function(error) {
|
|
||||||
print(error);
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
print(error.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Launches the PaymentRequest UI which accepts credit cards and Bob Pay.
|
|
||||||
*/
|
|
||||||
function cardsAndBobPayBuy() { // eslint-disable-line no-unused-vars
|
|
||||||
try {
|
|
||||||
request = new PaymentRequest(
|
|
||||||
[{
|
|
||||||
supportedMethods: ['visa', 'https://bobpay.com'],
|
|
||||||
}], {
|
|
||||||
total: {
|
|
||||||
label: 'Total',
|
|
||||||
amount: {
|
|
||||||
currency: 'USD',
|
|
||||||
value: '5.00',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
shippingOptions: [{
|
|
||||||
id: 'freeShippingOption',
|
|
||||||
label: 'Free global shipping',
|
|
||||||
amount: {
|
|
||||||
currency: 'USD',
|
|
||||||
value: '0',
|
|
||||||
},
|
|
||||||
selected: true,
|
|
||||||
}],
|
|
||||||
}, {
|
|
||||||
requestShipping: true,
|
|
||||||
});
|
|
||||||
request.show()
|
|
||||||
.then(function(resp) {
|
|
||||||
return resp.complete('success');
|
|
||||||
}).then(function() {
|
|
||||||
print(JSON.stringify(resp, undefined, 2));
|
|
||||||
}).catch(function(error) {
|
|
||||||
print(error);
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
print(error.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Aborts the current PaymentRequest.
|
|
||||||
*/
|
|
||||||
function abort() { // eslint-disable-line no-unused-vars
|
|
||||||
try {
|
|
||||||
request.abort().then(function() {
|
|
||||||
print('Aborted');
|
|
||||||
}).catch(function() {
|
|
||||||
print('Cannot abort');
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
print(error.message);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -11,14 +11,17 @@ module.exports = {
|
|||||||
'no-restricted-properties': 0,
|
'no-restricted-properties': 0,
|
||||||
'no-irregular-whitespace': 2,
|
'no-irregular-whitespace': 2,
|
||||||
'no-unexpected-multiline': 2,
|
'no-unexpected-multiline': 2,
|
||||||
'valid-jsdoc': [2, {
|
'valid-jsdoc': [
|
||||||
requireParamDescription: true,
|
2,
|
||||||
requireReturnDescription: true,
|
{
|
||||||
requireReturn: false,
|
requireParamDescription: true,
|
||||||
prefer: {
|
requireReturnDescription: true,
|
||||||
returns: 'return',
|
requireReturn: false,
|
||||||
|
prefer: {
|
||||||
|
returns: 'return',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}],
|
],
|
||||||
'curly': [2, 'multi-line'],
|
'curly': [2, 'multi-line'],
|
||||||
'guard-for-in': 2,
|
'guard-for-in': 2,
|
||||||
'no-caller': 2,
|
'no-caller': 2,
|
||||||
@@ -30,14 +33,20 @@ module.exports = {
|
|||||||
'no-new-wrappers': 2,
|
'no-new-wrappers': 2,
|
||||||
'no-throw-literal': 2,
|
'no-throw-literal': 2,
|
||||||
'no-with': 2,
|
'no-with': 2,
|
||||||
'no-unused-vars': [2, {
|
'no-unused-vars': [
|
||||||
args: 'none',
|
2,
|
||||||
}],
|
{
|
||||||
|
args: 'none',
|
||||||
|
},
|
||||||
|
],
|
||||||
'array-bracket-spacing': [2, 'never'],
|
'array-bracket-spacing': [2, 'never'],
|
||||||
'brace-style': 2,
|
'brace-style': 2,
|
||||||
'camelcase': [2, {
|
'camelcase': [
|
||||||
properties: 'never',
|
2,
|
||||||
}],
|
{
|
||||||
|
properties: 'never',
|
||||||
|
},
|
||||||
|
],
|
||||||
'comma-dangle': [2, 'always-multiline'],
|
'comma-dangle': [2, 'always-multiline'],
|
||||||
'comma-spacing': 2,
|
'comma-spacing': 2,
|
||||||
'comma-style': 2,
|
'comma-style': 2,
|
||||||
@@ -47,37 +56,45 @@ module.exports = {
|
|||||||
'key-spacing': 2,
|
'key-spacing': 2,
|
||||||
'keyword-spacing': 2,
|
'keyword-spacing': 2,
|
||||||
'linebreak-style': 2,
|
'linebreak-style': 2,
|
||||||
'max-len': [2, {
|
'max-len': [
|
||||||
code: 80,
|
2,
|
||||||
tabWidth: 2,
|
{
|
||||||
ignoreUrls: true,
|
code: 80,
|
||||||
}],
|
tabWidth: 2,
|
||||||
|
ignoreUrls: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
'new-cap': 2,
|
'new-cap': 2,
|
||||||
'no-array-constructor': 2,
|
'no-array-constructor': 2,
|
||||||
'no-mixed-spaces-and-tabs': 2,
|
'no-mixed-spaces-and-tabs': 2,
|
||||||
'no-multiple-empty-lines': [2, {
|
'no-multiple-empty-lines': [
|
||||||
max: 2,
|
2,
|
||||||
}],
|
{
|
||||||
|
max: 2,
|
||||||
|
},
|
||||||
|
],
|
||||||
'no-new-object': 2,
|
'no-new-object': 2,
|
||||||
'no-trailing-spaces': 2,
|
'no-trailing-spaces': 2,
|
||||||
'object-curly-spacing': 2,
|
'object-curly-spacing': 2,
|
||||||
'one-var': [2, {
|
|
||||||
var: 'never',
|
|
||||||
let: 'never',
|
|
||||||
const: 'never',
|
|
||||||
}],
|
|
||||||
'padded-blocks': [2, 'never'],
|
'padded-blocks': [2, 'never'],
|
||||||
'quote-props': [2, 'consistent'],
|
'quote-props': [2, 'consistent'],
|
||||||
'quotes': [2, 'single', {
|
'quotes': [
|
||||||
allowTemplateLiterals: true,
|
2,
|
||||||
}],
|
'single',
|
||||||
'require-jsdoc': [2, {
|
{
|
||||||
require: {
|
allowTemplateLiterals: true,
|
||||||
FunctionDeclaration: true,
|
|
||||||
MethodDefinition: true,
|
|
||||||
ClassDeclaration: true,
|
|
||||||
},
|
},
|
||||||
}],
|
],
|
||||||
|
'require-jsdoc': [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
require: {
|
||||||
|
FunctionDeclaration: true,
|
||||||
|
MethodDefinition: true,
|
||||||
|
ClassDeclaration: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
'semi-spacing': 2,
|
'semi-spacing': 2,
|
||||||
'semi': 2,
|
'semi': 2,
|
||||||
'space-before-blocks': 2,
|
'space-before-blocks': 2,
|
||||||
@@ -88,7 +105,6 @@ module.exports = {
|
|||||||
'generator-star-spacing': [2, 'after'],
|
'generator-star-spacing': [2, 'after'],
|
||||||
'no-new-symbol': 2,
|
'no-new-symbol': 2,
|
||||||
'no-this-before-super': 2,
|
'no-this-before-super': 2,
|
||||||
'no-var': 2,
|
|
||||||
'prefer-rest-params': 2,
|
'prefer-rest-params': 2,
|
||||||
'prefer-spread': 2,
|
'prefer-spread': 2,
|
||||||
'rest-spread-spacing': 2,
|
'rest-spread-spacing': 2,
|
@@ -27,11 +27,13 @@ function buy() { // eslint-disable-line no-unused-vars
|
|||||||
*/
|
*/
|
||||||
function abort() { // eslint-disable-line no-unused-vars
|
function abort() { // eslint-disable-line no-unused-vars
|
||||||
try {
|
try {
|
||||||
request.abort().then(() => {
|
request.abort()
|
||||||
print('Aborted');
|
.then(function() {
|
||||||
}).catch(() => {
|
print('Aborted');
|
||||||
print('Cannot abort');
|
})
|
||||||
});
|
.catch(function() {
|
||||||
|
print('Cannot abort');
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print(error.message);
|
print(error.message);
|
||||||
}
|
}
|
@@ -13,15 +13,23 @@
|
|||||||
function buy() { // eslint-disable-line no-unused-vars
|
function buy() { // eslint-disable-line no-unused-vars
|
||||||
try {
|
try {
|
||||||
new PaymentRequest(
|
new PaymentRequest(
|
||||||
[{supportedMethods: ['https://alicepay.com', 'https://bobpay.com',
|
[{
|
||||||
'https://charliepay.com', 'visa', 'mastercard']}],
|
supportedMethods: [
|
||||||
|
'https://alicepay.com',
|
||||||
|
'https://bobpay.com',
|
||||||
|
'https://charliepay.com',
|
||||||
|
'visa',
|
||||||
|
'mastercard',
|
||||||
|
],
|
||||||
|
}],
|
||||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}})
|
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}})
|
||||||
.show()
|
.show()
|
||||||
.then(function(resp) {
|
.then(function(resp) {
|
||||||
resp.complete('success')
|
resp.complete('success')
|
||||||
.then(function() {
|
.then(function() {
|
||||||
print(resp.methodName + '<br>' +
|
print(
|
||||||
JSON.stringify(resp.details, undefined, 2));
|
resp.methodName + '<br>' +
|
||||||
|
JSON.stringify(resp.details, undefined, 2));
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
print(error.message);
|
print(error.message);
|
18
components/test/data/payments/blob_url.js
Normal file
18
components/test/data/payments/blob_url.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Requests payment via a blob URL. */
|
||||||
|
function buy() { // eslint-disable-line no-unused-vars
|
||||||
|
var spoof = function() {
|
||||||
|
var payload =
|
||||||
|
'PGh0bWw+PGhlYWQ+PG1ldGEgbmFtZT0idmlld3BvcnQiIGNvbnRlbnQ9IndpZHRoPWRldmljZS13aWR0aCwgaW5pdGlhbC1zY2FsZT0yLCBtYXhpbXVtLXNjYWxlPTIiPjwvaGVhZD48Ym9keT48ZGl2IGlkPSJyZXN1bHQiPjwvZGl2PjxzY3JpcHQ+dHJ5IHsgIG5ldyBQYXltZW50UmVxdWVzdChbe3N1cHBvcnRlZE1ldGhvZHM6IFsiYmFzaWMtY2FyZCJdfV0sICAgIHt0b3RhbDoge2xhYmVsOiAiVCIsIGFtb3VudDoge2N1cnJlbmN5OiAiVVNEIiwgdmFsdWU6ICIxLjAwIn19fSkgIC5zaG93KCkgIC50aGVuKGZ1bmN0aW9uKGluc3RydW1lbnRSZXNwb25zZSkgeyAgICBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgicmVzdWx0IikuaW5uZXJIVE1MID0gIlJlc29sdmVkIjsgIH0pLmNhdGNoKGZ1bmN0aW9uKGUpIHsgICAgZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoInJlc3VsdCIpLmlubmVySFRNTCA9ICJSZWplY3RlZDogIiArIGU7ICB9KTt9IGNhdGNoKGUpIHsgIGRvY3VtZW50LmdldEVsZW1lbnRCeUlkKCJyZXN1bHQiKS5pbm5lckhUTUwgPSAiRXhjZXB0aW9uOiAiICsgZTt9PC9zY3JpcHQ+PC9ib2R5PjwvaHRtbD4='; // eslint-disable-line max-len
|
||||||
|
document.write(atob(payload));
|
||||||
|
};
|
||||||
|
window.location.href =
|
||||||
|
URL.createObjectURL(new Blob(['<script>(', spoof, ')();</script>'], {
|
||||||
|
type: 'text/html',
|
||||||
|
}));
|
||||||
|
}
|
@@ -19,8 +19,9 @@ function buy() { // eslint-disable-line no-unused-vars
|
|||||||
.then(function(resp) {
|
.then(function(resp) {
|
||||||
resp.complete('success')
|
resp.complete('success')
|
||||||
.then(function() {
|
.then(function() {
|
||||||
print(resp.methodName + '<br>' +
|
print(
|
||||||
JSON.stringify(resp.details, undefined, 2));
|
resp.methodName + '<br>' +
|
||||||
|
JSON.stringify(resp.details, undefined, 2));
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
print('complete() rejected<br>' + error);
|
print('complete() rejected<br>' + error);
|
@@ -13,8 +13,7 @@
|
|||||||
function buy() { // eslint-disable-line no-unused-vars
|
function buy() { // eslint-disable-line no-unused-vars
|
||||||
try {
|
try {
|
||||||
new PaymentRequest(
|
new PaymentRequest(
|
||||||
[{supportedMethods: ['https://bobpay.com', 'basic-card']}],
|
[{supportedMethods: ['https://bobpay.com', 'basic-card']}], {
|
||||||
{
|
|
||||||
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
||||||
modifiers: [{
|
modifiers: [{
|
||||||
supportedMethods: ['basic-card'],
|
supportedMethods: ['basic-card'],
|
||||||
@@ -56,8 +55,7 @@ function buy() { // eslint-disable-line no-unused-vars
|
|||||||
function creditSupportedType() { // eslint-disable-line no-unused-vars
|
function creditSupportedType() { // eslint-disable-line no-unused-vars
|
||||||
try {
|
try {
|
||||||
new PaymentRequest(
|
new PaymentRequest(
|
||||||
[{supportedMethods: ['https://bobpay.com', 'basic-card']}],
|
[{supportedMethods: ['https://bobpay.com', 'basic-card']}], {
|
||||||
{
|
|
||||||
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
||||||
modifiers: [{
|
modifiers: [{
|
||||||
supportedMethods: ['basic-card'],
|
supportedMethods: ['basic-card'],
|
||||||
@@ -102,8 +100,7 @@ function creditSupportedType() { // eslint-disable-line no-unused-vars
|
|||||||
function debitSupportedType() { // eslint-disable-line no-unused-vars
|
function debitSupportedType() { // eslint-disable-line no-unused-vars
|
||||||
try {
|
try {
|
||||||
new PaymentRequest(
|
new PaymentRequest(
|
||||||
[{supportedMethods: ['https://bobpay.com', 'basic-card']}],
|
[{supportedMethods: ['https://bobpay.com', 'basic-card']}], {
|
||||||
{
|
|
||||||
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
||||||
modifiers: [{
|
modifiers: [{
|
||||||
supportedMethods: ['basic-card'],
|
supportedMethods: ['basic-card'],
|
||||||
@@ -148,8 +145,7 @@ function debitSupportedType() { // eslint-disable-line no-unused-vars
|
|||||||
function visaSupportedNetwork() { // eslint-disable-line no-unused-vars
|
function visaSupportedNetwork() { // eslint-disable-line no-unused-vars
|
||||||
try {
|
try {
|
||||||
new PaymentRequest(
|
new PaymentRequest(
|
||||||
[{supportedMethods: ['https://bobpay.com', 'basic-card']}],
|
[{supportedMethods: ['https://bobpay.com', 'basic-card']}], {
|
||||||
{
|
|
||||||
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
||||||
modifiers: [{
|
modifiers: [{
|
||||||
supportedMethods: ['basic-card'],
|
supportedMethods: ['basic-card'],
|
||||||
@@ -196,8 +192,7 @@ function visaSupportedNetwork() { // eslint-disable-line no-unused-vars
|
|||||||
function mastercardSupportedNetwork() { // eslint-disable-line no-unused-vars
|
function mastercardSupportedNetwork() { // eslint-disable-line no-unused-vars
|
||||||
try {
|
try {
|
||||||
new PaymentRequest(
|
new PaymentRequest(
|
||||||
[{supportedMethods: ['https://bobpay.com', 'basic-card']}],
|
[{supportedMethods: ['https://bobpay.com', 'basic-card']}], {
|
||||||
{
|
|
||||||
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
||||||
modifiers: [{
|
modifiers: [{
|
||||||
supportedMethods: ['basic-card'],
|
supportedMethods: ['basic-card'],
|
@@ -13,20 +13,16 @@
|
|||||||
function buy() { // eslint-disable-line no-unused-vars
|
function buy() { // eslint-disable-line no-unused-vars
|
||||||
try {
|
try {
|
||||||
new PaymentRequest(
|
new PaymentRequest(
|
||||||
[{supportedMethods: ['https://bobpay.com', 'basic-card']}],
|
[{supportedMethods: ['https://bobpay.com', 'basic-card']}], {
|
||||||
{
|
|
||||||
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
||||||
modifiers: [{
|
modifiers: [{
|
||||||
supportedMethods: ['https://bobpay.com'],
|
supportedMethods: ['https://bobpay.com'],
|
||||||
total: {
|
total: {label: 'Total', amount: {currency: 'USD', value: '4.00'}},
|
||||||
label: 'Total',
|
|
||||||
amount: {currency: 'USD', value: '4.00'}
|
|
||||||
},
|
|
||||||
additionalDisplayItems: [{
|
additionalDisplayItems: [{
|
||||||
label: 'BobPay discount',
|
label: 'BobPay discount',
|
||||||
amount: {currency: 'USD', value: '-1.00'}
|
amount: {currency: 'USD', value: '-1.00'},
|
||||||
}],
|
}],
|
||||||
data: {discountProgramParticipantId: '86328764873265'}
|
data: {discountProgramParticipantId: '86328764873265'},
|
||||||
}],
|
}],
|
||||||
})
|
})
|
||||||
.show()
|
.show()
|
@@ -19,8 +19,9 @@ function buy() { // eslint-disable-line no-unused-vars
|
|||||||
.then(function(resp) {
|
.then(function(resp) {
|
||||||
resp.complete('success')
|
resp.complete('success')
|
||||||
.then(function() {
|
.then(function() {
|
||||||
print(resp.methodName + '<br>' +
|
print(
|
||||||
JSON.stringify(resp.details, undefined, 2));
|
resp.methodName + '<br>' +
|
||||||
|
JSON.stringify(resp.details, undefined, 2));
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
print(error.message);
|
print(error.message);
|
@@ -23,8 +23,9 @@ function buy() { // eslint-disable-line no-unused-vars
|
|||||||
.then(function(resp) {
|
.then(function(resp) {
|
||||||
resp.complete('success')
|
resp.complete('success')
|
||||||
.then(function() {
|
.then(function() {
|
||||||
print(resp.methodName + '<br>' +
|
print(
|
||||||
JSON.stringify(resp.details, undefined, 2));
|
resp.methodName + '<br>' +
|
||||||
|
JSON.stringify(resp.details, undefined, 2));
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
print('complete() rejected<br>' + error);
|
print('complete() rejected<br>' + error);
|
69
components/test/data/payments/bobpay_ui_skip_preload.js
Normal file
69
components/test/data/payments/bobpay_ui_skip_preload.js
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds PaymentRequest for Bob Pay, but does not show any UI yet.
|
||||||
|
*
|
||||||
|
* @return {PaymentRequest} The PaymentRequest object.
|
||||||
|
*/
|
||||||
|
function initPaymentRequest() {
|
||||||
|
var supportedInstruments = [{
|
||||||
|
supportedMethods: ['https://bobpay.com'],
|
||||||
|
}];
|
||||||
|
|
||||||
|
var details = {
|
||||||
|
total: {
|
||||||
|
label: 'Donation',
|
||||||
|
amount: {
|
||||||
|
currency: 'USD',
|
||||||
|
value: '55.00',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
displayItems: [
|
||||||
|
{
|
||||||
|
label: 'Original donation amount',
|
||||||
|
amount: {
|
||||||
|
currency: 'USD',
|
||||||
|
value: '65.00',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Friends and family discount',
|
||||||
|
amount: {
|
||||||
|
currency: 'USD',
|
||||||
|
value: '-10.00',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
return new PaymentRequest(supportedInstruments, details);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launches the PaymentRequest UI with Bob Pay as the only payment method.
|
||||||
|
* Preloads the second instance of PaymentRequest while the first instance is
|
||||||
|
* showing.
|
||||||
|
*/
|
||||||
|
function buy() { // eslint-disable-line no-unused-vars
|
||||||
|
var request = initPaymentRequest();
|
||||||
|
request.show()
|
||||||
|
.then(function(instrumentResponse) {
|
||||||
|
window.setTimeout(function() {
|
||||||
|
instrumentResponse.complete('success')
|
||||||
|
.then(function() {
|
||||||
|
print(JSON.stringify(instrumentResponse, undefined, 2));
|
||||||
|
})
|
||||||
|
.catch(function(err) {
|
||||||
|
print(err);
|
||||||
|
});
|
||||||
|
}, 500);
|
||||||
|
})
|
||||||
|
.catch(function(err) {
|
||||||
|
print(err);
|
||||||
|
});
|
||||||
|
request = initPaymentRequest();
|
||||||
|
}
|
@@ -23,9 +23,13 @@ function noQueryShow() { // eslint-disable-line no-unused-vars
|
|||||||
.then(function() {
|
.then(function() {
|
||||||
print(JSON.stringify(resp, undefined, 2));
|
print(JSON.stringify(resp, undefined, 2));
|
||||||
})
|
})
|
||||||
.catch(function(error) { print(error); });
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch(function(error) { print(error); });
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print(error.message);
|
print(error.message);
|
||||||
}
|
}
|
||||||
@@ -40,17 +44,25 @@ function queryShow() { // eslint-disable-line no-unused-vars
|
|||||||
[{supportedMethods: ['https://bobpay.com', 'visa']}],
|
[{supportedMethods: ['https://bobpay.com', 'visa']}],
|
||||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
||||||
request.canMakePayment()
|
request.canMakePayment()
|
||||||
.then(function(result) { print(result); })
|
.then(function(result) {
|
||||||
.catch(function(error) { print(error); });
|
print(result);
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
request.show()
|
request.show()
|
||||||
.then(function(resp) {
|
.then(function(resp) {
|
||||||
resp.complete('success')
|
resp.complete('success')
|
||||||
.then(function() {
|
.then(function() {
|
||||||
print(JSON.stringify(resp, undefined, 2));
|
print(JSON.stringify(resp, undefined, 2));
|
||||||
})
|
})
|
||||||
.catch(function(error) { print(error); });
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch(function(error) { print(error); });
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print(error.message);
|
print(error.message);
|
||||||
}
|
}
|
||||||
@@ -65,8 +77,12 @@ function queryNoShow() { // eslint-disable-line no-unused-vars
|
|||||||
[{supportedMethods: ['https://bobpay.com', 'visa']}],
|
[{supportedMethods: ['https://bobpay.com', 'visa']}],
|
||||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
||||||
request.canMakePayment()
|
request.canMakePayment()
|
||||||
.then(function(result) { print(result); })
|
.then(function(result) {
|
||||||
.catch(function(error) { print(error); });
|
print(result);
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print(error.message);
|
print(error.message);
|
||||||
}
|
}
|
||||||
@@ -77,11 +93,13 @@ function queryNoShow() { // eslint-disable-line no-unused-vars
|
|||||||
*/
|
*/
|
||||||
function abort() { // eslint-disable-line no-unused-vars
|
function abort() { // eslint-disable-line no-unused-vars
|
||||||
try {
|
try {
|
||||||
request.abort().then(() => {
|
request.abort()
|
||||||
print('Aborted');
|
.then(function() {
|
||||||
}).catch(() => {
|
print('Aborted');
|
||||||
print('Cannot abort');
|
})
|
||||||
});
|
.catch(function() {
|
||||||
|
print('Cannot abort');
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print(error.message);
|
print(error.message);
|
||||||
}
|
}
|
@@ -13,6 +13,7 @@ var second;
|
|||||||
/**
|
/**
|
||||||
* Sets the |first| variable and prints both |first| and |second| only if both
|
* Sets the |first| variable and prints both |first| and |second| only if both
|
||||||
* were set.
|
* were set.
|
||||||
|
* @param {object} result The object to print.
|
||||||
*/
|
*/
|
||||||
function printFirst(result) {
|
function printFirst(result) {
|
||||||
first = result.toString();
|
first = result.toString();
|
||||||
@@ -24,6 +25,7 @@ function printFirst(result) {
|
|||||||
/**
|
/**
|
||||||
* Sets the |second| variable and prints both |first| and |second| only if both
|
* Sets the |second| variable and prints both |first| and |second| only if both
|
||||||
* were set.
|
* were set.
|
||||||
|
* @param {object} result The object to print.
|
||||||
*/
|
*/
|
||||||
function printSecond(result) {
|
function printSecond(result) {
|
||||||
second = result.toString();
|
second = result.toString();
|
||||||
@@ -44,8 +46,12 @@ function buy() { // eslint-disable-line no-unused-vars
|
|||||||
[{supportedMethods: ['https://bobpay.com']}],
|
[{supportedMethods: ['https://bobpay.com']}],
|
||||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}})
|
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}})
|
||||||
.canMakePayment()
|
.canMakePayment()
|
||||||
.then(function(result) { printFirst(result); })
|
.then(function(result) {
|
||||||
.catch(function(error) { printFirst(error); });
|
printFirst(result);
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
printFirst(error);
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
printFirst(error);
|
printFirst(error);
|
||||||
}
|
}
|
||||||
@@ -55,8 +61,12 @@ function buy() { // eslint-disable-line no-unused-vars
|
|||||||
[{supportedMethods: ['https://bobpay.com']}],
|
[{supportedMethods: ['https://bobpay.com']}],
|
||||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}})
|
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}})
|
||||||
.canMakePayment()
|
.canMakePayment()
|
||||||
.then(function(result) { printSecond(result); })
|
.then(function(result) {
|
||||||
.catch(function(error) { printSecond(error); });
|
printSecond(result);
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
printSecond(error);
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
printSecond(error);
|
printSecond(error);
|
||||||
}
|
}
|
||||||
@@ -74,8 +84,12 @@ function otherBuy() { // eslint-disable-line no-unused-vars
|
|||||||
[{supportedMethods: ['https://bobpay.com']}],
|
[{supportedMethods: ['https://bobpay.com']}],
|
||||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}})
|
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}})
|
||||||
.canMakePayment()
|
.canMakePayment()
|
||||||
.then(function(result) { printFirst(result); })
|
.then(function(result) {
|
||||||
.catch(function(error) { printFirst(error); });
|
printFirst(result);
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
printFirst(error);
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
printFirst(error);
|
printFirst(error);
|
||||||
}
|
}
|
||||||
@@ -85,8 +99,12 @@ function otherBuy() { // eslint-disable-line no-unused-vars
|
|||||||
[{supportedMethods: ['https://alicepay.com']}],
|
[{supportedMethods: ['https://alicepay.com']}],
|
||||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}})
|
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}})
|
||||||
.canMakePayment()
|
.canMakePayment()
|
||||||
.then(function(result) { printSecond(result); })
|
.then(function(result) {
|
||||||
.catch(function(error) { printSecond(error); });
|
printSecond(result);
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
printSecond(error);
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
printSecond(error);
|
printSecond(error);
|
||||||
}
|
}
|
@@ -9,7 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
function buy() { // eslint-disable-line no-unused-vars
|
function buy() { // eslint-disable-line no-unused-vars
|
||||||
try {
|
try {
|
||||||
const request = new PaymentRequest(
|
var request = new PaymentRequest(
|
||||||
[{supportedMethods: ['visa']}],
|
[{supportedMethods: ['visa']}],
|
||||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
||||||
request.canMakePayment()
|
request.canMakePayment()
|
||||||
@@ -29,7 +29,7 @@ function buy() { // eslint-disable-line no-unused-vars
|
|||||||
*/
|
*/
|
||||||
function other_buy() { // eslint-disable-line no-unused-vars, camelcase
|
function other_buy() { // eslint-disable-line no-unused-vars, camelcase
|
||||||
try {
|
try {
|
||||||
const request = new PaymentRequest(
|
var request = new PaymentRequest(
|
||||||
[{supportedMethods: ['mastercard']}],
|
[{supportedMethods: ['mastercard']}],
|
||||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
||||||
request.canMakePayment()
|
request.canMakePayment()
|
@@ -13,9 +13,11 @@ function buy() { // eslint-disable-line no-unused-vars
|
|||||||
try {
|
try {
|
||||||
new PaymentRequest(
|
new PaymentRequest(
|
||||||
[{supportedMethods: ['https://bobpay.com', 'amex', 'visa']}],
|
[{supportedMethods: ['https://bobpay.com', 'amex', 'visa']}],
|
||||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}},
|
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}}, {
|
||||||
{requestPayerName: true, requestPayerEmail: true,
|
requestPayerName: true,
|
||||||
requestPayerPhone: true})
|
requestPayerEmail: true,
|
||||||
|
requestPayerPhone: true,
|
||||||
|
})
|
||||||
.show()
|
.show()
|
||||||
.then(function(resp) {
|
.then(function(resp) {
|
||||||
resp.complete('success')
|
resp.complete('success')
|
@@ -13,18 +13,21 @@
|
|||||||
function buy() { // eslint-disable-line no-unused-vars
|
function buy() { // eslint-disable-line no-unused-vars
|
||||||
try {
|
try {
|
||||||
var details = {
|
var details = {
|
||||||
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
||||||
shippingOptions: [{
|
shippingOptions: [{
|
||||||
id: 'freeShippingOption',
|
id: 'freeShippingOption',
|
||||||
label: 'Free global shipping',
|
label: 'Free global shipping',
|
||||||
amount: {currency: 'USD', value: '0'},
|
amount: {currency: 'USD', value: '0'},
|
||||||
selected: true
|
selected: true,
|
||||||
}]
|
}],
|
||||||
};
|
};
|
||||||
var request = new PaymentRequest(
|
var request = new PaymentRequest(
|
||||||
[{supportedMethods: ['visa', 'https://bobpay.com']}], details,
|
[{supportedMethods: ['visa', 'https://bobpay.com']}], details, {
|
||||||
{requestPayerName: true, requestPayerEmail: true,
|
requestPayerName: true,
|
||||||
requestPayerPhone: true, requestShipping: true});
|
requestPayerEmail: true,
|
||||||
|
requestPayerPhone: true,
|
||||||
|
requestShipping: true,
|
||||||
|
});
|
||||||
|
|
||||||
request.addEventListener('shippingaddresschange', function(e) {
|
request.addEventListener('shippingaddresschange', function(e) {
|
||||||
e.updateWith(new Promise(function(resolve) {
|
e.updateWith(new Promise(function(resolve) {
|
67
components/test/data/payments/debit.js
Normal file
67
components/test/data/payments/debit.js
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a payment request for a debit card.
|
||||||
|
* @return {!PaymentRequest} A payment request for a debit card.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
function buildPaymentRequest() {
|
||||||
|
return new PaymentRequest(
|
||||||
|
[{
|
||||||
|
supportedMethods: ['basic-card'],
|
||||||
|
data: {
|
||||||
|
supportedTypes: ['debit'],
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
{
|
||||||
|
total: {
|
||||||
|
label: 'Total',
|
||||||
|
amount: {
|
||||||
|
currency: 'USD',
|
||||||
|
value: '1.00',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Requests payment via a debit card. */
|
||||||
|
function buy() { // eslint-disable-line no-unused-vars
|
||||||
|
try {
|
||||||
|
buildPaymentRequest()
|
||||||
|
.show()
|
||||||
|
.then(function(response) {
|
||||||
|
response.complete()
|
||||||
|
.then(function() {
|
||||||
|
print(JSON.stringify(response, undefined, 2));
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
print(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Checks whether payment via a debit card is possible. */
|
||||||
|
function canMakePayment() { // eslint-disable-line no-unused-vars
|
||||||
|
try {
|
||||||
|
buildPaymentRequest()
|
||||||
|
.canMakePayment()
|
||||||
|
.then(function(result) {
|
||||||
|
print(result);
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
print(error);
|
||||||
|
}
|
||||||
|
}
|
11
chrome/test/data/payments/dynamic_shipping.js → components/test/data/payments/dynamic_shipping.js
11
chrome/test/data/payments/dynamic_shipping.js → components/test/data/payments/dynamic_shipping.js
@@ -18,13 +18,10 @@ function buy() { // eslint-disable-line no-unused-vars
|
|||||||
{
|
{
|
||||||
label: 'Pending shipping price',
|
label: 'Pending shipping price',
|
||||||
amount: {currency: 'USD', value: '0.00'},
|
amount: {currency: 'USD', value: '0.00'},
|
||||||
pending: true
|
pending: true,
|
||||||
},
|
},
|
||||||
{
|
{label: 'Subtotal', amount: {currency: 'USD', value: '5.00'}},
|
||||||
label: 'Subtotal',
|
],
|
||||||
amount: {currency: 'USD', value: '5.00'}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var request = new PaymentRequest(
|
var request = new PaymentRequest(
|
||||||
@@ -67,7 +64,7 @@ function updateDetails(details, addr) {
|
|||||||
id: '',
|
id: '',
|
||||||
label: '',
|
label: '',
|
||||||
amount: {currency: 'USD', value: '0.00'},
|
amount: {currency: 'USD', value: '0.00'},
|
||||||
selected: true
|
selected: true,
|
||||||
};
|
};
|
||||||
if (addr.region === 'CA') {
|
if (addr.region === 'CA') {
|
||||||
shippingOption.id = 'californiaShippingOption';
|
shippingOption.id = 'californiaShippingOption';
|
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
/* global PaymentRequest:false */
|
/* global PaymentRequest:false */
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Launches the PaymentRequest UI that requests email address.
|
* Launches the PaymentRequest UI that requests email address.
|
||||||
*/
|
*/
|
||||||
function buy() { // eslint-disable-line no-unused-vars
|
function buy() { // eslint-disable-line no-unused-vars
|
46
components/test/data/payments/email_and_free_shipping.js
Normal file
46
components/test/data/payments/email_and_free_shipping.js
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* global PaymentRequest:false */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launches the PaymentRequest UI that requests an email address and offers free
|
||||||
|
* shipping worldwide.
|
||||||
|
*/
|
||||||
|
function buy() { // eslint-disable-line no-unused-vars
|
||||||
|
try {
|
||||||
|
var details = {
|
||||||
|
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
||||||
|
shippingOptions: [{
|
||||||
|
id: 'freeShippingOption',
|
||||||
|
label: 'Free global shipping',
|
||||||
|
amount: {currency: 'USD', value: '0'},
|
||||||
|
selected: true,
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
var request = new PaymentRequest(
|
||||||
|
[{supportedMethods: ['visa']}], details,
|
||||||
|
{requestPayerEmail: true, requestShipping: true});
|
||||||
|
request.addEventListener('shippingaddresschange', function(e) {
|
||||||
|
e.updateWith(details);
|
||||||
|
});
|
||||||
|
request.show()
|
||||||
|
.then(function(resp) {
|
||||||
|
resp.complete('success')
|
||||||
|
.then(function() {
|
||||||
|
print(JSON.stringify(resp, undefined, 2));
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
print(error.message);
|
||||||
|
}
|
||||||
|
}
|
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
/* global PaymentRequest:false */
|
/* global PaymentRequest:false */
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Launches the PaymentRequest UI that requests email address and phone number.
|
* Launches the PaymentRequest UI that requests email address and phone number.
|
||||||
*/
|
*/
|
||||||
function buy() { // eslint-disable-line no-unused-vars
|
function buy() { // eslint-disable-line no-unused-vars
|
@@ -19,15 +19,16 @@ function buy() { // eslint-disable-line no-unused-vars
|
|||||||
id: 'freeShippingOption',
|
id: 'freeShippingOption',
|
||||||
label: 'Free global shipping',
|
label: 'Free global shipping',
|
||||||
amount: {currency: 'USD', value: '0'},
|
amount: {currency: 'USD', value: '0'},
|
||||||
selected: true
|
selected: true,
|
||||||
}]
|
}],
|
||||||
};
|
};
|
||||||
var request = new PaymentRequest([{supportedMethods: ['visa']}], details);
|
var request = new PaymentRequest([{supportedMethods: ['visa']}], details);
|
||||||
request.show()
|
request.show()
|
||||||
.then(function(resp) {
|
.then(function(resp) {
|
||||||
resp.complete('success')
|
resp.complete('success')
|
||||||
.then(function() {
|
.then(function() {
|
||||||
print(resp.methodName + '<br>' +
|
print(
|
||||||
|
resp.methodName + '<br>' +
|
||||||
JSON.stringify(resp.details, undefined, 2));
|
JSON.stringify(resp.details, undefined, 2));
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
@@ -18,14 +18,23 @@ function buy() { // eslint-disable-line no-unused-vars
|
|||||||
id: 'freeShippingOption',
|
id: 'freeShippingOption',
|
||||||
label: 'Free global shipping',
|
label: 'Free global shipping',
|
||||||
amount: {currency: 'USD', value: '0'},
|
amount: {currency: 'USD', value: '0'},
|
||||||
selected: true
|
selected: true,
|
||||||
}]
|
}],
|
||||||
};
|
};
|
||||||
var request = new PaymentRequest(
|
var request = new PaymentRequest(
|
||||||
[{supportedMethods: ['visa', 'unionpay', 'mir', 'mastercard',
|
[{
|
||||||
'jcb', 'discover', 'diners', 'amex']}],
|
supportedMethods: [
|
||||||
details,
|
'visa',
|
||||||
{requestShipping: true});
|
'unionpay',
|
||||||
|
'mir',
|
||||||
|
'mastercard',
|
||||||
|
'jcb',
|
||||||
|
'discover',
|
||||||
|
'diners',
|
||||||
|
'amex',
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
details, {requestShipping: true});
|
||||||
request.addEventListener('shippingaddresschange', function(e) {
|
request.addEventListener('shippingaddresschange', function(e) {
|
||||||
e.updateWith(new Promise(function(resolve) {
|
e.updateWith(new Promise(function(resolve) {
|
||||||
// No changes in price based on shipping address change.
|
// No changes in price based on shipping address change.
|
@@ -11,9 +11,9 @@
|
|||||||
* The Payment Request for this page.
|
* The Payment Request for this page.
|
||||||
* @const
|
* @const
|
||||||
*/
|
*/
|
||||||
let REQUEST = new PaymentRequest(
|
var REQUEST = new PaymentRequest(
|
||||||
[{supportedMethods: ['https://bobpay.com', 'visa']}],
|
[{supportedMethods: ['https://bobpay.com', 'visa']}],
|
||||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the Payment Request UI.
|
* Show the Payment Request UI.
|
||||||
@@ -43,11 +43,13 @@ function show() { // eslint-disable-line no-unused-vars
|
|||||||
*/
|
*/
|
||||||
function abort() { // eslint-disable-line no-unused-vars
|
function abort() { // eslint-disable-line no-unused-vars
|
||||||
try {
|
try {
|
||||||
REQUEST.abort().then(() => {
|
REQUEST.abort()
|
||||||
print('Aborted');
|
.then(function() {
|
||||||
}).catch(() => {
|
print('Aborted');
|
||||||
print('Cannot abort');
|
})
|
||||||
});
|
.catch(function() {
|
||||||
|
print('Cannot abort');
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print(error.message);
|
print(error.message);
|
||||||
}
|
}
|
@@ -5,12 +5,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/** Invokes PaymentRequest with a very long request identifier. */
|
/** Invokes PaymentRequest with a very long request identifier. */
|
||||||
function buy() { // eslint-disable-line no-unused-vars
|
function buy() { // eslint-disable-line no-unused-vars
|
||||||
const foo = Object.freeze({
|
var foo = Object.freeze({supportedMethods: ['basic-card']});
|
||||||
supportedMethods: ['basic-card']
|
var defaultMethods = Object.freeze([foo]);
|
||||||
});
|
var defaultDetails = Object.freeze({
|
||||||
const defaultMethods = Object.freeze([foo]);
|
|
||||||
const defaultDetails = Object.freeze({
|
|
||||||
total: {
|
total: {
|
||||||
label: 'Label',
|
label: 'Label',
|
||||||
amount: {
|
amount: {
|
||||||
@@ -19,11 +17,12 @@ function buy() { // eslint-disable-line no-unused-vars
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const newDetails = Object.assign({}, defaultDetails, {
|
var newDetails = Object.assign({}, defaultDetails, {
|
||||||
id: ''.padStart(100000000, '\n very long id \t \n '),
|
id: ''.padStart(100000000, '\n very long id \t \n '),
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
const request = new PaymentRequest(defaultMethods, newDetails);
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
var request = new PaymentRequest(defaultMethods, newDetails);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print(error);
|
print(error);
|
||||||
}
|
}
|
265
components/test/data/payments/metrics.js
Normal file
265
components/test/data/payments/metrics.js
Normal file
@@ -0,0 +1,265 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* global PaymentRequest:false */
|
||||||
|
|
||||||
|
var request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launches the PaymentRequest UI that accepts credit cards.
|
||||||
|
*/
|
||||||
|
function ccBuy() { // eslint-disable-line no-unused-vars
|
||||||
|
try {
|
||||||
|
var details = {
|
||||||
|
total: {
|
||||||
|
label: 'Total',
|
||||||
|
amount: {
|
||||||
|
currency: 'USD',
|
||||||
|
value: '5.00',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
shippingOptions: [{
|
||||||
|
id: 'freeShippingOption',
|
||||||
|
label: 'Free global shipping',
|
||||||
|
amount: {
|
||||||
|
currency: 'USD',
|
||||||
|
value: '0',
|
||||||
|
},
|
||||||
|
selected: true,
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
request = new PaymentRequest(
|
||||||
|
[{
|
||||||
|
supportedMethods: ['visa'],
|
||||||
|
}],
|
||||||
|
{
|
||||||
|
total: {
|
||||||
|
label: 'Total',
|
||||||
|
amount: {
|
||||||
|
currency: 'USD',
|
||||||
|
value: '5.00',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
shippingOptions: [{
|
||||||
|
id: 'freeShippingOption',
|
||||||
|
label: 'Free global shipping',
|
||||||
|
amount: {
|
||||||
|
currency: 'USD',
|
||||||
|
value: '0',
|
||||||
|
},
|
||||||
|
selected: true,
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
requestShipping: true,
|
||||||
|
});
|
||||||
|
request.show()
|
||||||
|
.then(function(resp) {
|
||||||
|
return resp.complete('success');
|
||||||
|
})
|
||||||
|
.then(function() {
|
||||||
|
print(JSON.stringify(resp, undefined, 2));
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
|
request.addEventListener('shippingaddresschange', function(e) {
|
||||||
|
e.updateWith(new Promise(function(resolve) {
|
||||||
|
// No changes in price based on shipping address change.
|
||||||
|
resolve(details);
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
print(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launches the PaymentRequest UI which accepts only Android Pay.
|
||||||
|
*/
|
||||||
|
function androidPayBuy() { // eslint-disable-line no-unused-vars
|
||||||
|
try {
|
||||||
|
request = new PaymentRequest(
|
||||||
|
[{
|
||||||
|
supportedMethods: ['https://android.com/pay'],
|
||||||
|
}],
|
||||||
|
{
|
||||||
|
total: {
|
||||||
|
label: 'Total',
|
||||||
|
amount: {
|
||||||
|
currency: 'USD',
|
||||||
|
value: '5.00',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
shippingOptions: [{
|
||||||
|
id: 'freeShippingOption',
|
||||||
|
label: 'Free global shipping',
|
||||||
|
amount: {
|
||||||
|
currency: 'USD',
|
||||||
|
value: '0',
|
||||||
|
},
|
||||||
|
selected: true,
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
requestShipping: true,
|
||||||
|
});
|
||||||
|
request.show()
|
||||||
|
.then(function(resp) {
|
||||||
|
return resp.complete('success');
|
||||||
|
})
|
||||||
|
.then(function() {
|
||||||
|
print(JSON.stringify(resp, undefined, 2));
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
print(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launches the PaymentRequest UI which accepts only Android Pay and does not
|
||||||
|
* require any other information.
|
||||||
|
*/
|
||||||
|
function androidPaySkipUiBuy() { // eslint-disable-line no-unused-vars
|
||||||
|
try {
|
||||||
|
request = new PaymentRequest(
|
||||||
|
[{
|
||||||
|
supportedMethods: ['https://android.com/pay'],
|
||||||
|
}],
|
||||||
|
{
|
||||||
|
total: {
|
||||||
|
label: 'Total',
|
||||||
|
amount: {
|
||||||
|
currency: 'USD',
|
||||||
|
value: '5.00',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
request.show()
|
||||||
|
.then(function(resp) {
|
||||||
|
return resp.complete('success');
|
||||||
|
})
|
||||||
|
.then(function() {
|
||||||
|
print(JSON.stringify(resp, undefined, 2));
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
print(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launches the PaymentRequest UI which accepts only an unsupported payment
|
||||||
|
* method.
|
||||||
|
*/
|
||||||
|
function noSupported() { // eslint-disable-line no-unused-vars
|
||||||
|
try {
|
||||||
|
request = new PaymentRequest(
|
||||||
|
[{
|
||||||
|
supportedMethods: ['https://randompay.com'],
|
||||||
|
}],
|
||||||
|
{
|
||||||
|
total: {
|
||||||
|
label: 'Total',
|
||||||
|
amount: {
|
||||||
|
currency: 'USD',
|
||||||
|
value: '5.00',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
shippingOptions: [{
|
||||||
|
id: 'freeShippingOption',
|
||||||
|
label: 'Free global shipping',
|
||||||
|
amount: {
|
||||||
|
currency: 'USD',
|
||||||
|
value: '0',
|
||||||
|
},
|
||||||
|
selected: true,
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
requestShipping: true,
|
||||||
|
});
|
||||||
|
request.show()
|
||||||
|
.then(function(resp) {
|
||||||
|
return resp.complete('success');
|
||||||
|
})
|
||||||
|
.then(function() {
|
||||||
|
print(JSON.stringify(resp, undefined, 2));
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
print(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launches the PaymentRequest UI which accepts credit cards and Bob Pay.
|
||||||
|
*/
|
||||||
|
function cardsAndBobPayBuy() { // eslint-disable-line no-unused-vars
|
||||||
|
try {
|
||||||
|
request = new PaymentRequest(
|
||||||
|
[{
|
||||||
|
supportedMethods: ['visa', 'https://bobpay.com'],
|
||||||
|
}],
|
||||||
|
{
|
||||||
|
total: {
|
||||||
|
label: 'Total',
|
||||||
|
amount: {
|
||||||
|
currency: 'USD',
|
||||||
|
value: '5.00',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
shippingOptions: [{
|
||||||
|
id: 'freeShippingOption',
|
||||||
|
label: 'Free global shipping',
|
||||||
|
amount: {
|
||||||
|
currency: 'USD',
|
||||||
|
value: '0',
|
||||||
|
},
|
||||||
|
selected: true,
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
requestShipping: true,
|
||||||
|
});
|
||||||
|
request.show()
|
||||||
|
.then(function(resp) {
|
||||||
|
return resp.complete('success');
|
||||||
|
})
|
||||||
|
.then(function() {
|
||||||
|
print(JSON.stringify(resp, undefined, 2));
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
print(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aborts the current PaymentRequest.
|
||||||
|
*/
|
||||||
|
function abort() { // eslint-disable-line no-unused-vars
|
||||||
|
try {
|
||||||
|
request.abort()
|
||||||
|
.then(function() {
|
||||||
|
print('Aborted');
|
||||||
|
})
|
||||||
|
.catch(function() {
|
||||||
|
print('Cannot abort');
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
print(error.message);
|
||||||
|
}
|
||||||
|
}
|
@@ -8,12 +8,13 @@
|
|||||||
* Invokes the PaymentRequest with a modifier that contains the bare mininum of
|
* Invokes the PaymentRequest with a modifier that contains the bare mininum of
|
||||||
* required fields.
|
* required fields.
|
||||||
*/
|
*/
|
||||||
function buy() { // eslint-disable-line no-unused-vars
|
function buy() { // eslint-disable-line no-unused-vars
|
||||||
try {
|
try {
|
||||||
new PaymentRequest(
|
new PaymentRequest(
|
||||||
[{
|
[{
|
||||||
supportedMethods: ['foo'],
|
supportedMethods: ['foo'],
|
||||||
}], {
|
}],
|
||||||
|
{
|
||||||
total: {
|
total: {
|
||||||
label: 'Total',
|
label: 'Total',
|
||||||
amount: {
|
amount: {
|
||||||
@@ -25,19 +26,19 @@ function buy() { // eslint-disable-line no-unused-vars
|
|||||||
supportedMethods: ['foo'],
|
supportedMethods: ['foo'],
|
||||||
}],
|
}],
|
||||||
})
|
})
|
||||||
.show()
|
.show()
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
response.complete()
|
response.complete()
|
||||||
.then(function() {
|
.then(function() {
|
||||||
print(complete);
|
print(complete);
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
print(error);
|
print(error);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
print(error);
|
print(error);
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print(error.message);
|
print(error.message);
|
||||||
}
|
}
|
@@ -23,9 +23,13 @@ function buy() { // eslint-disable-line no-unused-vars
|
|||||||
.then(function() {
|
.then(function() {
|
||||||
print(JSON.stringify(resp, undefined, 2));
|
print(JSON.stringify(resp, undefined, 2));
|
||||||
})
|
})
|
||||||
.catch(function(error) { print(error); });
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch(function(error) { print(error); });
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print(error.message);
|
print(error.message);
|
||||||
}
|
}
|
||||||
@@ -42,9 +46,13 @@ function showAgain() { // eslint-disable-line no-unused-vars
|
|||||||
.then(function() {
|
.then(function() {
|
||||||
print(JSON.stringify(resp, undefined, 2));
|
print(JSON.stringify(resp, undefined, 2));
|
||||||
})
|
})
|
||||||
.catch(function(error) { print(error); });
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch(function(error) { print(error); });
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print(error.message);
|
print(error.message);
|
||||||
}
|
}
|
||||||
@@ -64,9 +72,13 @@ function showSecondRequest() { // eslint-disable-line no-unused-vars
|
|||||||
.then(function() {
|
.then(function() {
|
||||||
print(JSON.stringify(resp, undefined, 2));
|
print(JSON.stringify(resp, undefined, 2));
|
||||||
})
|
})
|
||||||
.catch(function(error) { print(error); });
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch(function(error) { print(error); });
|
.catch(function(error) {
|
||||||
|
print(error);
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print(error.message);
|
print(error.message);
|
||||||
}
|
}
|
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
/* global PaymentRequest:false */
|
/* global PaymentRequest:false */
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Launches the PaymentRequest UI that requests payer name.
|
* Launches the PaymentRequest UI that requests payer name.
|
||||||
*/
|
*/
|
||||||
function buy() { // eslint-disable-line no-unused-vars
|
function buy() { // eslint-disable-line no-unused-vars
|
@@ -19,8 +19,8 @@ function buy() { // eslint-disable-line no-unused-vars
|
|||||||
id: 'freeShippingOption',
|
id: 'freeShippingOption',
|
||||||
label: 'Free global shipping',
|
label: 'Free global shipping',
|
||||||
amount: {currency: 'USD', value: '0'},
|
amount: {currency: 'USD', value: '0'},
|
||||||
selected: true
|
selected: true,
|
||||||
}]
|
}],
|
||||||
},
|
},
|
||||||
{requestPayerName: true, requestShipping: true});
|
{requestPayerName: true, requestShipping: true});
|
||||||
request.show()
|
request.show()
|
@@ -17,10 +17,10 @@ function buy() { // eslint-disable-line no-unused-vars
|
|||||||
{
|
{
|
||||||
label: 'Subtotal',
|
label: 'Subtotal',
|
||||||
amount: {currency: 'USD', value: '4.50'},
|
amount: {currency: 'USD', value: '4.50'},
|
||||||
pending: true
|
pending: true,
|
||||||
},
|
},
|
||||||
{label: 'Taxes', amount: {currency: 'USD', value: '0.50'}}
|
{label: 'Taxes', amount: {currency: 'USD', value: '0.50'}},
|
||||||
]
|
],
|
||||||
})
|
})
|
||||||
.show()
|
.show()
|
||||||
.then(function(resp) {
|
.then(function(resp) {
|
@@ -11,23 +11,22 @@
|
|||||||
*/
|
*/
|
||||||
function canMakePaymentHelper(methodData) {
|
function canMakePaymentHelper(methodData) {
|
||||||
try {
|
try {
|
||||||
new PaymentRequest(
|
new PaymentRequest(methodData, {
|
||||||
methodData, {
|
total: {
|
||||||
total: {
|
label: 'Total',
|
||||||
label: 'Total',
|
amount: {
|
||||||
amount: {
|
currency: 'USD',
|
||||||
currency: 'USD',
|
value: '5.00',
|
||||||
value: '5.00',
|
},
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
|
.canMakePayment()
|
||||||
|
.then(function(result) {
|
||||||
|
print(result);
|
||||||
})
|
})
|
||||||
.canMakePayment()
|
.catch(function(error) {
|
||||||
.then(function(result) {
|
print(error);
|
||||||
print(result);
|
});
|
||||||
})
|
|
||||||
.catch(function(error) {
|
|
||||||
print(error);
|
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print(error);
|
print(error);
|
||||||
}
|
}
|
||||||
@@ -37,7 +36,7 @@ function canMakePaymentHelper(methodData) {
|
|||||||
* Merchant checks for ability to pay using "basic-card" regardless of issuer
|
* Merchant checks for ability to pay using "basic-card" regardless of issuer
|
||||||
* network.
|
* network.
|
||||||
*/
|
*/
|
||||||
function checkBasicCard() { // eslint-disable-line no-unused-vars
|
function checkBasicCard() { // eslint-disable-line no-unused-vars
|
||||||
canMakePaymentHelper([{
|
canMakePaymentHelper([{
|
||||||
supportedMethods: ['basic-card'],
|
supportedMethods: ['basic-card'],
|
||||||
}]);
|
}]);
|
||||||
@@ -46,7 +45,7 @@ function checkBasicCard() { // eslint-disable-line no-unused-vars
|
|||||||
/**
|
/**
|
||||||
* Merchant checks for ability to pay using debit cards.
|
* Merchant checks for ability to pay using debit cards.
|
||||||
*/
|
*/
|
||||||
function checkBasicDebit() { // eslint-disable-line no-unused-vars
|
function checkBasicDebit() { // eslint-disable-line no-unused-vars
|
||||||
canMakePaymentHelper([{
|
canMakePaymentHelper([{
|
||||||
supportedMethods: ['basic-card'],
|
supportedMethods: ['basic-card'],
|
||||||
data: {
|
data: {
|
||||||
@@ -59,7 +58,7 @@ function checkBasicDebit() { // eslint-disable-line no-unused-vars
|
|||||||
* Merchant checks for ability to pay using "basic-card" with "mastercard" as
|
* Merchant checks for ability to pay using "basic-card" with "mastercard" as
|
||||||
* the supported network.
|
* the supported network.
|
||||||
*/
|
*/
|
||||||
function checkBasicMasterCard() { // eslint-disable-line no-unused-vars
|
function checkBasicMasterCard() { // eslint-disable-line no-unused-vars
|
||||||
canMakePaymentHelper([{
|
canMakePaymentHelper([{
|
||||||
supportedMethods: ['basic-card'],
|
supportedMethods: ['basic-card'],
|
||||||
data: {
|
data: {
|
||||||
@@ -72,7 +71,7 @@ function checkBasicMasterCard() { // eslint-disable-line no-unused-vars
|
|||||||
* Merchant checks for ability to pay using "basic-card" with "visa" as the
|
* Merchant checks for ability to pay using "basic-card" with "visa" as the
|
||||||
* supported network.
|
* supported network.
|
||||||
*/
|
*/
|
||||||
function checkBasicVisa() { // eslint-disable-line no-unused-vars
|
function checkBasicVisa() { // eslint-disable-line no-unused-vars
|
||||||
canMakePaymentHelper([{
|
canMakePaymentHelper([{
|
||||||
supportedMethods: ['basic-card'],
|
supportedMethods: ['basic-card'],
|
||||||
data: {
|
data: {
|
||||||
@@ -84,7 +83,7 @@ function checkBasicVisa() { // eslint-disable-line no-unused-vars
|
|||||||
/**
|
/**
|
||||||
* Merchant checks for ability to pay using "mastercard".
|
* Merchant checks for ability to pay using "mastercard".
|
||||||
*/
|
*/
|
||||||
function checkMasterCard() { // eslint-disable-line no-unused-vars
|
function checkMasterCard() { // eslint-disable-line no-unused-vars
|
||||||
canMakePaymentHelper([{
|
canMakePaymentHelper([{
|
||||||
supportedMethods: ['mastercard'],
|
supportedMethods: ['mastercard'],
|
||||||
}]);
|
}]);
|
||||||
@@ -93,7 +92,7 @@ function checkMasterCard() { // eslint-disable-line no-unused-vars
|
|||||||
/**
|
/**
|
||||||
* Merchant checks for ability to pay using "visa".
|
* Merchant checks for ability to pay using "visa".
|
||||||
*/
|
*/
|
||||||
function checkVisa() { // eslint-disable-line no-unused-vars
|
function checkVisa() { // eslint-disable-line no-unused-vars
|
||||||
canMakePaymentHelper([{
|
canMakePaymentHelper([{
|
||||||
supportedMethods: ['visa'],
|
supportedMethods: ['visa'],
|
||||||
}]);
|
}]);
|
||||||
@@ -107,27 +106,27 @@ function checkVisa() { // eslint-disable-line no-unused-vars
|
|||||||
function buyHelper(methodData) {
|
function buyHelper(methodData) {
|
||||||
try {
|
try {
|
||||||
new PaymentRequest(methodData, {
|
new PaymentRequest(methodData, {
|
||||||
total: {
|
total: {
|
||||||
label: 'Total',
|
label: 'Total',
|
||||||
amount: {
|
amount: {
|
||||||
currency: 'USD',
|
currency: 'USD',
|
||||||
value: '5.00',
|
value: '5.00',
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
},
|
||||||
.show()
|
})
|
||||||
.then(function(response) {
|
.show()
|
||||||
response.complete('success')
|
.then(function(response) {
|
||||||
.then(function() {
|
response.complete('success')
|
||||||
print(JSON.stringify(response, undefined, 2));
|
.then(function() {
|
||||||
})
|
print(JSON.stringify(response, undefined, 2));
|
||||||
.catch(function(error) {
|
})
|
||||||
print(error);
|
.catch(function(error) {
|
||||||
});
|
print(error);
|
||||||
})
|
});
|
||||||
.catch(function(error) {
|
})
|
||||||
print(error);
|
.catch(function(error) {
|
||||||
});
|
print(error);
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print(error);
|
print(error);
|
||||||
}
|
}
|
||||||
@@ -137,21 +136,24 @@ function buyHelper(methodData) {
|
|||||||
* Merchant requests payment via either "mastercard" or "basic-card" with "visa"
|
* Merchant requests payment via either "mastercard" or "basic-card" with "visa"
|
||||||
* as the supported network.
|
* as the supported network.
|
||||||
*/
|
*/
|
||||||
function buy() { // eslint-disable-line no-unused-vars
|
function buy() { // eslint-disable-line no-unused-vars
|
||||||
buyHelper([{
|
buyHelper([
|
||||||
supportedMethods: ['mastercard'],
|
{
|
||||||
}, {
|
supportedMethods: ['mastercard'],
|
||||||
supportedMethods: ['basic-card'],
|
|
||||||
data: {
|
|
||||||
supportedNetworks: ['visa'],
|
|
||||||
},
|
},
|
||||||
}]);
|
{
|
||||||
|
supportedMethods: ['basic-card'],
|
||||||
|
data: {
|
||||||
|
supportedNetworks: ['visa'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merchant requests payment via "basic-card" with any issuer network.
|
* Merchant requests payment via "basic-card" with any issuer network.
|
||||||
*/
|
*/
|
||||||
function buyBasicCard() { // eslint-disable-line no-unused-vars
|
function buyBasicCard() { // eslint-disable-line no-unused-vars
|
||||||
buyHelper([{
|
buyHelper([{
|
||||||
supportedMethods: ['basic-card'],
|
supportedMethods: ['basic-card'],
|
||||||
data: {
|
data: {
|
||||||
@@ -164,7 +166,7 @@ function buyBasicCard() { // eslint-disable-line no-unused-vars
|
|||||||
* Merchant requests payment via "basic-card" with "debit" as the supported card
|
* Merchant requests payment via "basic-card" with "debit" as the supported card
|
||||||
* type.
|
* type.
|
||||||
*/
|
*/
|
||||||
function buyBasicDebit() { // eslint-disable-line no-unused-vars
|
function buyBasicDebit() { // eslint-disable-line no-unused-vars
|
||||||
buyHelper([{
|
buyHelper([{
|
||||||
supportedMethods: ['basic-card'],
|
supportedMethods: ['basic-card'],
|
||||||
data: {
|
data: {
|
||||||
@@ -177,7 +179,7 @@ function buyBasicDebit() { // eslint-disable-line no-unused-vars
|
|||||||
* Merchant requests payment via "basic-card" with "debit" as the supported card
|
* Merchant requests payment via "basic-card" with "debit" as the supported card
|
||||||
* type.
|
* type.
|
||||||
*/
|
*/
|
||||||
function buyBasicDebit() { // eslint-disable-line no-unused-vars
|
function buyBasicDebit() { // eslint-disable-line no-unused-vars
|
||||||
buyHelper([{
|
buyHelper([{
|
||||||
supportedMethods: ['basic-card'],
|
supportedMethods: ['basic-card'],
|
||||||
data: {
|
data: {
|
||||||
@@ -190,7 +192,7 @@ function buyBasicDebit() { // eslint-disable-line no-unused-vars
|
|||||||
* Merchant requests payment via "basic-card" payment method with "mastercard"
|
* Merchant requests payment via "basic-card" payment method with "mastercard"
|
||||||
* as the only supported network.
|
* as the only supported network.
|
||||||
*/
|
*/
|
||||||
function buyBasicMasterCard() { // eslint-disable-line no-unused-vars
|
function buyBasicMasterCard() { // eslint-disable-line no-unused-vars
|
||||||
buyHelper([{
|
buyHelper([{
|
||||||
supportedMethods: ['basic-card'],
|
supportedMethods: ['basic-card'],
|
||||||
data: {
|
data: {
|
@@ -11,7 +11,7 @@ found in the LICENSE file.
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<button onclick="buy()" id="buy">Buy</button><br>
|
<div><button onclick="buy()" id="buy">Buy</button></div>
|
||||||
<button onclick="abort()" id="abort">Abort</button>
|
<button onclick="abort()" id="abort">Abort</button>
|
||||||
<pre id="result"></pre>
|
<pre id="result"></pre>
|
||||||
<script src="util.js"></script>
|
<script src="util.js"></script>
|
@@ -12,7 +12,9 @@ found in the LICENSE file.
|
|||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<button onclick="buy()" id="buy">Multiple apps and Cards Test</button><br>
|
<div>
|
||||||
|
<button onclick="buy()" id="buy">Multiple apps and Cards Test</button>
|
||||||
|
</div>
|
||||||
<pre id="result"></pre>
|
<pre id="result"></pre>
|
||||||
<script src="util.js"></script>
|
<script src="util.js"></script>
|
||||||
<script src="alicepay_bobpay_charliepay_and_cards.js"></script>
|
<script src="alicepay_bobpay_charliepay_and_cards.js"></script>
|
@@ -12,7 +12,11 @@ found in the LICENSE file.
|
|||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<button onclick="buy()" id="buy">Bob Pay and Basic-Card with modifiers Test</button><br>
|
<div>
|
||||||
|
<button onclick="buy()" id="buy">
|
||||||
|
Bob Pay and Basic-Card with modifiers Test
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<pre id="result"></pre>
|
<pre id="result"></pre>
|
||||||
<script src="util.js"></script>
|
<script src="util.js"></script>
|
||||||
<script src="bobpay_and_basic_card_with_modifiers.js"></script>
|
<script src="bobpay_and_basic_card_with_modifiers.js"></script>
|
@@ -12,7 +12,7 @@ found in the LICENSE file.
|
|||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<button onclick="buy()" id="buy">Bob Pay and Cards Test</button><br>
|
<div><button onclick="buy()" id="buy">Bob Pay and Cards Test</button></div>
|
||||||
<pre id="result"></pre>
|
<pre id="result"></pre>
|
||||||
<script src="util.js"></script>
|
<script src="util.js"></script>
|
||||||
<script src="bobpay_and_cards.js"></script>
|
<script src="bobpay_and_cards.js"></script>
|
@@ -12,7 +12,7 @@ found in the LICENSE file.
|
|||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<button onclick="buy()" id="buy">Bob Pay Test</button><br>
|
<div><button onclick="buy()" id="buy">Bob Pay Test</button></div>
|
||||||
<pre id="result"></pre>
|
<pre id="result"></pre>
|
||||||
<script src="util.js"></script>
|
<script src="util.js"></script>
|
||||||
<script src="bobpay.js"></script>
|
<script src="bobpay.js"></script>
|
@@ -12,7 +12,7 @@ found in the LICENSE file.
|
|||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<button onclick="buy()" id="buy">UI skip, preload test</button><br>
|
<div><button onclick="buy()" id="buy">UI skip, preload test</button></div>
|
||||||
<pre id="result"></pre>
|
<pre id="result"></pre>
|
||||||
<script src="util.js"></script>
|
<script src="util.js"></script>
|
||||||
<script src="bobpay_ui_skip_preload.js"></script>
|
<script src="bobpay_ui_skip_preload.js"></script>
|
@@ -12,7 +12,7 @@ found in the LICENSE file.
|
|||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<button onclick="buy()" id="buy">Bob Pay Test</button><br>
|
<div><button onclick="buy()" id="buy">Bob Pay Test</button></div>
|
||||||
<pre id="result"></pre>
|
<pre id="result"></pre>
|
||||||
<script src="util.js"></script>
|
<script src="util.js"></script>
|
||||||
<script src="bobpay_ui_skip.js"></script>
|
<script src="bobpay_ui_skip.js"></script>
|
@@ -12,10 +12,14 @@ found in the LICENSE file.
|
|||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<button onclick="noQueryShow()" id="noQueryShow">No Query Show Test</button><br>
|
<div>
|
||||||
<button onclick="queryShow()" id="queryShow">Query Show Test</button><br>
|
<button onclick="noQueryShow()" id="noQueryShow">No Query Show Test</button>
|
||||||
<button onclick="queryNoShow()" id="queryNoShow">Query No Show Test</button><br>
|
</div>
|
||||||
<button onclick="abort()" id="abort">Abort</button><br>
|
<div><button onclick="queryShow()" id="queryShow">Query Show Test</button></div>
|
||||||
|
<div>
|
||||||
|
<button onclick="queryNoShow()" id="queryNoShow">Query No Show Test</button>
|
||||||
|
</div>
|
||||||
|
<div><button onclick="abort()" id="abort">Abort</button></div>
|
||||||
<pre id="result"></pre>
|
<pre id="result"></pre>
|
||||||
<script src="util.js"></script>
|
<script src="util.js"></script>
|
||||||
<script src="can_make_payment_metrics.js"></script>
|
<script src="can_make_payment_metrics.js"></script>
|
@@ -10,10 +10,10 @@
|
|||||||
*/
|
*/
|
||||||
function buy() { // eslint-disable-line no-unused-vars
|
function buy() { // eslint-disable-line no-unused-vars
|
||||||
try {
|
try {
|
||||||
new PaymentRequest(
|
new PaymentRequest([{supportedMethods: ['visa']}], {
|
||||||
[{supportedMethods: ['visa']}],
|
id: 'my_payment_id',
|
||||||
{id: 'my_payment_id',
|
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
||||||
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}})
|
})
|
||||||
.show()
|
.show()
|
||||||
.then(function(resp) {
|
.then(function(resp) {
|
||||||
resp.complete('success')
|
resp.complete('success')
|
@@ -14,7 +14,7 @@ found in the LICENSE file.
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<button onclick="buy()" id="buy">Long ID Test</button><br>
|
<div><button onclick="buy()" id="buy">Long ID Test</button></div>
|
||||||
<pre id="result"></pre>
|
<pre id="result"></pre>
|
||||||
<script src="util.js"></script>
|
<script src="util.js"></script>
|
||||||
<script src="long_id.js"></script>
|
<script src="long_id.js"></script>
|
@@ -11,7 +11,7 @@ found in the LICENSE file.
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<button onclick="buy()" id="buy">Modifier Test</button><br>
|
<div><button onclick="buy()" id="buy">Modifier Test</button></div>
|
||||||
<pre id="result"></pre>
|
<pre id="result"></pre>
|
||||||
<script src="util.js"></script>
|
<script src="util.js"></script>
|
||||||
<script src="modifier.js"></script>
|
<script src="modifier.js"></script>
|
@@ -12,7 +12,7 @@ found in the LICENSE file.
|
|||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<button onclick="buy()" id="buy">Name and Free Shipping Test</button><br>
|
<div><button onclick="buy()" id="buy">Name and Free Shipping Test</button></div>
|
||||||
<pre id="result"></pre>
|
<pre id="result"></pre>
|
||||||
<script src="util.js"></script>
|
<script src="util.js"></script>
|
||||||
<script src="name_and_free_shipping.js"></script>
|
<script src="name_and_free_shipping.js"></script>
|
@@ -19,8 +19,8 @@ function buy() { // eslint-disable-line no-unused-vars
|
|||||||
id: 'freeShippingOption',
|
id: 'freeShippingOption',
|
||||||
label: 'Free global shipping',
|
label: 'Free global shipping',
|
||||||
amount: {currency: 'USD', value: '0'},
|
amount: {currency: 'USD', value: '0'},
|
||||||
selected: true
|
selected: true,
|
||||||
}]
|
}],
|
||||||
},
|
},
|
||||||
{requestPayerPhone: true, requestShipping: true});
|
{requestPayerPhone: true, requestShipping: true});
|
||||||
request.show()
|
request.show()
|
@@ -16,20 +16,15 @@ function buy() { // eslint-disable-line no-unused-vars
|
|||||||
{
|
{
|
||||||
label: 'Pending shipping price',
|
label: 'Pending shipping price',
|
||||||
amount: {currency: 'USD', value: '0.00'},
|
amount: {currency: 'USD', value: '0.00'},
|
||||||
pending: true
|
pending: true,
|
||||||
},
|
},
|
||||||
{
|
{label: 'Subtotal', amount: {currency: 'USD', value: '5.00'}},
|
||||||
label: 'Subtotal',
|
],
|
||||||
amount: {currency: 'USD', value: '5.00'}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var request = new PaymentRequest(
|
var request = new PaymentRequest(
|
||||||
[{supportedMethods: ['visa']}], details, {requestShipping: true});
|
[{supportedMethods: ['visa']}], details, {requestShipping: true});
|
||||||
|
|
||||||
var shippingAddressChange;
|
|
||||||
|
|
||||||
request.addEventListener('shippingaddresschange', function(evt) {
|
request.addEventListener('shippingaddresschange', function(evt) {
|
||||||
evt.updateWith(new Promise(function(resolve) {
|
evt.updateWith(new Promise(function(resolve) {
|
||||||
print(JSON.stringify(request.shippingAddress, undefined, 2));
|
print(JSON.stringify(request.shippingAddress, undefined, 2));
|
@@ -8,10 +8,10 @@
|
|||||||
* Launches the PaymentRequest UI twice.
|
* Launches the PaymentRequest UI twice.
|
||||||
*/
|
*/
|
||||||
function buy() { // eslint-disable-line no-unused-vars
|
function buy() { // eslint-disable-line no-unused-vars
|
||||||
const payment1 = new PaymentRequest(
|
var payment1 = new PaymentRequest(
|
||||||
[{supportedMethods: ['visa']}],
|
[{supportedMethods: ['visa']}],
|
||||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
||||||
const payment2 = new PaymentRequest(
|
var payment2 = new PaymentRequest(
|
||||||
[{supportedMethods: ['visa']}],
|
[{supportedMethods: ['visa']}],
|
||||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
||||||
payment1.show();
|
payment1.show();
|
@@ -5,9 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
button {
|
button {
|
||||||
width: 100%;
|
|
||||||
height: 5em;
|
|
||||||
font-size: 3em;
|
font-size: 3em;
|
||||||
|
height: 5em;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre {
|
pre {
|
@@ -8,6 +8,6 @@
|
|||||||
* Prints the message.
|
* Prints the message.
|
||||||
* @param {String} msg - The message to print.
|
* @param {String} msg - The message to print.
|
||||||
*/
|
*/
|
||||||
function print(msg) { // eslint-disable-line no-unused-vars
|
function print(msg) { // eslint-disable-line no-unused-vars
|
||||||
document.getElementById('result').innerHTML = msg;
|
document.getElementById('result').innerHTML = msg;
|
||||||
}
|
}
|
Reference in New Issue
Block a user