[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/browser/payments'\
|
||||
'|chrome/browser/ui/views/payments'\
|
||||
'|chrome/test/data/payments'\
|
||||
'|components/payments/test/data'\
|
||||
'|components/payments'\
|
||||
'|content/browser/payments'\
|
||||
'|content/test/data/payments'\
|
||||
|
@ -529,11 +529,11 @@ android_library("chrome_test_java") {
|
||||
"//chrome/test/data/image_search/valid.png",
|
||||
"//chrome/test/data/navigation_interception/",
|
||||
"//chrome/test/data/notifications/",
|
||||
"//chrome/test/data/payments/",
|
||||
"//chrome/test/data/popup_blocker/",
|
||||
"//chrome/test/data/push_messaging/",
|
||||
"//chrome/test/data/translate/",
|
||||
"//chrome/test/media_router/resources/",
|
||||
"//components/test/data/payments/",
|
||||
"//content/test/data/android/geolocation.html",
|
||||
"//content/test/data/android/media_permissions.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
|
||||
@Feature({"Payments"})
|
||||
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() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -166,7 +166,7 @@ public class PaymentManifestDownloaderTest implements ManifestDownloadCallback {
|
||||
@Test
|
||||
@Feature({"Payments"})
|
||||
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() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -210,9 +210,10 @@ public class PaymentManifestDownloaderTest implements ManifestDownloadCallback {
|
||||
@Feature({"Payments"})
|
||||
public void testSeveralDownloadsAtOnce() throws Throwable {
|
||||
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 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() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -235,4 +236,4 @@ public class PaymentManifestDownloaderTest implements ManifestDownloadCallback {
|
||||
Assert.assertEquals(PAYMENT_METHOD_MANIFEST, mPaymentMethodManifest);
|
||||
Assert.assertEquals(WEB_APP_MANIFEST, mWebAppManifest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ final class PaymentRequestTestCommon implements PaymentRequestObserverForTest,
|
||||
mTestFilePath = testFileName.startsWith("data:")
|
||||
? testFileName
|
||||
: UrlUtils.getIsolatedTestFilePath(
|
||||
String.format("chrome/test/data/payments/%s", testFileName));
|
||||
String.format("components/test/data/payments/%s", testFileName));
|
||||
}
|
||||
|
||||
public void startMainActivity() throws InterruptedException {
|
||||
|
@ -43,7 +43,8 @@ class SitePerProcessPaymentsBrowserTest : public InProcessBrowserTest {
|
||||
host_resolver()->AddRule("*", "127.0.0.1");
|
||||
ASSERT_TRUE(https_server_->InitializeAndListen());
|
||||
content::SetupCrossSiteRedirector(https_server_.get());
|
||||
https_server_->ServeFilesFromSourceDirectory("chrome/test/data/payments");
|
||||
https_server_->ServeFilesFromSourceDirectory(
|
||||
"components/test/data/payments");
|
||||
https_server_->StartAcceptingConnections();
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ void PaymentRequestBrowserTestBase::SetUpOnMainThread() {
|
||||
host_resolver()->AddRule("a.com", "127.0.0.1");
|
||||
host_resolver()->AddRule("b.com", "127.0.0.1");
|
||||
ASSERT_TRUE(https_server_->InitializeAndListen());
|
||||
https_server_->ServeFilesFromSourceDirectory("chrome/test/data/payments");
|
||||
https_server_->ServeFilesFromSourceDirectory("components/test/data/payments");
|
||||
https_server_->StartAcceptingConnections();
|
||||
|
||||
NavigateTo(test_file_path_);
|
||||
|
@ -87,7 +87,7 @@ class PaymentRequestBrowserTestBase
|
||||
|
||||
protected:
|
||||
// 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);
|
||||
~PaymentRequestBrowserTestBase() override;
|
||||
|
||||
|
@ -1701,6 +1701,7 @@ test("browser_tests") {
|
||||
"//chrome/browser/policy/test/policy_testserver.py",
|
||||
"//chrome/common/extensions/docs/examples/apps/calculator/",
|
||||
"//chrome/third_party/mock4js/",
|
||||
"//components/test/data/payments/",
|
||||
"//components/test/data/update_client/",
|
||||
"//content/test/data/",
|
||||
"//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-irregular-whitespace': 2,
|
||||
'no-unexpected-multiline': 2,
|
||||
'valid-jsdoc': [2, {
|
||||
requireParamDescription: true,
|
||||
requireReturnDescription: true,
|
||||
requireReturn: false,
|
||||
prefer: {
|
||||
returns: 'return',
|
||||
'valid-jsdoc': [
|
||||
2,
|
||||
{
|
||||
requireParamDescription: true,
|
||||
requireReturnDescription: true,
|
||||
requireReturn: false,
|
||||
prefer: {
|
||||
returns: 'return',
|
||||
},
|
||||
},
|
||||
}],
|
||||
],
|
||||
'curly': [2, 'multi-line'],
|
||||
'guard-for-in': 2,
|
||||
'no-caller': 2,
|
||||
@ -30,14 +33,20 @@ module.exports = {
|
||||
'no-new-wrappers': 2,
|
||||
'no-throw-literal': 2,
|
||||
'no-with': 2,
|
||||
'no-unused-vars': [2, {
|
||||
args: 'none',
|
||||
}],
|
||||
'no-unused-vars': [
|
||||
2,
|
||||
{
|
||||
args: 'none',
|
||||
},
|
||||
],
|
||||
'array-bracket-spacing': [2, 'never'],
|
||||
'brace-style': 2,
|
||||
'camelcase': [2, {
|
||||
properties: 'never',
|
||||
}],
|
||||
'camelcase': [
|
||||
2,
|
||||
{
|
||||
properties: 'never',
|
||||
},
|
||||
],
|
||||
'comma-dangle': [2, 'always-multiline'],
|
||||
'comma-spacing': 2,
|
||||
'comma-style': 2,
|
||||
@ -47,37 +56,45 @@ module.exports = {
|
||||
'key-spacing': 2,
|
||||
'keyword-spacing': 2,
|
||||
'linebreak-style': 2,
|
||||
'max-len': [2, {
|
||||
code: 80,
|
||||
tabWidth: 2,
|
||||
ignoreUrls: true,
|
||||
}],
|
||||
'max-len': [
|
||||
2,
|
||||
{
|
||||
code: 80,
|
||||
tabWidth: 2,
|
||||
ignoreUrls: true,
|
||||
},
|
||||
],
|
||||
'new-cap': 2,
|
||||
'no-array-constructor': 2,
|
||||
'no-mixed-spaces-and-tabs': 2,
|
||||
'no-multiple-empty-lines': [2, {
|
||||
max: 2,
|
||||
}],
|
||||
'no-multiple-empty-lines': [
|
||||
2,
|
||||
{
|
||||
max: 2,
|
||||
},
|
||||
],
|
||||
'no-new-object': 2,
|
||||
'no-trailing-spaces': 2,
|
||||
'object-curly-spacing': 2,
|
||||
'one-var': [2, {
|
||||
var: 'never',
|
||||
let: 'never',
|
||||
const: 'never',
|
||||
}],
|
||||
'padded-blocks': [2, 'never'],
|
||||
'quote-props': [2, 'consistent'],
|
||||
'quotes': [2, 'single', {
|
||||
allowTemplateLiterals: true,
|
||||
}],
|
||||
'require-jsdoc': [2, {
|
||||
require: {
|
||||
FunctionDeclaration: true,
|
||||
MethodDefinition: true,
|
||||
ClassDeclaration: true,
|
||||
'quotes': [
|
||||
2,
|
||||
'single',
|
||||
{
|
||||
allowTemplateLiterals: true,
|
||||
},
|
||||
}],
|
||||
],
|
||||
'require-jsdoc': [
|
||||
2,
|
||||
{
|
||||
require: {
|
||||
FunctionDeclaration: true,
|
||||
MethodDefinition: true,
|
||||
ClassDeclaration: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
'semi-spacing': 2,
|
||||
'semi': 2,
|
||||
'space-before-blocks': 2,
|
||||
@ -88,7 +105,6 @@ module.exports = {
|
||||
'generator-star-spacing': [2, 'after'],
|
||||
'no-new-symbol': 2,
|
||||
'no-this-before-super': 2,
|
||||
'no-var': 2,
|
||||
'prefer-rest-params': 2,
|
||||
'prefer-spread': 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
|
||||
try {
|
||||
request.abort().then(() => {
|
||||
print('Aborted');
|
||||
}).catch(() => {
|
||||
print('Cannot abort');
|
||||
});
|
||||
request.abort()
|
||||
.then(function() {
|
||||
print('Aborted');
|
||||
})
|
||||
.catch(function() {
|
||||
print('Cannot abort');
|
||||
});
|
||||
} catch (error) {
|
||||
print(error.message);
|
||||
}
|
@ -13,15 +13,23 @@
|
||||
function buy() { // eslint-disable-line no-unused-vars
|
||||
try {
|
||||
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'}}})
|
||||
.show()
|
||||
.then(function(resp) {
|
||||
resp.complete('success')
|
||||
.then(function() {
|
||||
print(resp.methodName + '<br>' +
|
||||
JSON.stringify(resp.details, undefined, 2));
|
||||
print(
|
||||
resp.methodName + '<br>' +
|
||||
JSON.stringify(resp.details, undefined, 2));
|
||||
})
|
||||
.catch(function(error) {
|
||||
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) {
|
||||
resp.complete('success')
|
||||
.then(function() {
|
||||
print(resp.methodName + '<br>' +
|
||||
JSON.stringify(resp.details, undefined, 2));
|
||||
print(
|
||||
resp.methodName + '<br>' +
|
||||
JSON.stringify(resp.details, undefined, 2));
|
||||
})
|
||||
.catch(function(error) {
|
||||
print('complete() rejected<br>' + error);
|
@ -13,8 +13,7 @@
|
||||
function buy() { // eslint-disable-line no-unused-vars
|
||||
try {
|
||||
new PaymentRequest(
|
||||
[{supportedMethods: ['https://bobpay.com', 'basic-card']}],
|
||||
{
|
||||
[{supportedMethods: ['https://bobpay.com', 'basic-card']}], {
|
||||
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
||||
modifiers: [{
|
||||
supportedMethods: ['basic-card'],
|
||||
@ -56,8 +55,7 @@ function buy() { // eslint-disable-line no-unused-vars
|
||||
function creditSupportedType() { // eslint-disable-line no-unused-vars
|
||||
try {
|
||||
new PaymentRequest(
|
||||
[{supportedMethods: ['https://bobpay.com', 'basic-card']}],
|
||||
{
|
||||
[{supportedMethods: ['https://bobpay.com', 'basic-card']}], {
|
||||
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
||||
modifiers: [{
|
||||
supportedMethods: ['basic-card'],
|
||||
@ -102,8 +100,7 @@ function creditSupportedType() { // eslint-disable-line no-unused-vars
|
||||
function debitSupportedType() { // eslint-disable-line no-unused-vars
|
||||
try {
|
||||
new PaymentRequest(
|
||||
[{supportedMethods: ['https://bobpay.com', 'basic-card']}],
|
||||
{
|
||||
[{supportedMethods: ['https://bobpay.com', 'basic-card']}], {
|
||||
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
||||
modifiers: [{
|
||||
supportedMethods: ['basic-card'],
|
||||
@ -148,8 +145,7 @@ function debitSupportedType() { // eslint-disable-line no-unused-vars
|
||||
function visaSupportedNetwork() { // eslint-disable-line no-unused-vars
|
||||
try {
|
||||
new PaymentRequest(
|
||||
[{supportedMethods: ['https://bobpay.com', 'basic-card']}],
|
||||
{
|
||||
[{supportedMethods: ['https://bobpay.com', 'basic-card']}], {
|
||||
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
||||
modifiers: [{
|
||||
supportedMethods: ['basic-card'],
|
||||
@ -196,8 +192,7 @@ function visaSupportedNetwork() { // eslint-disable-line no-unused-vars
|
||||
function mastercardSupportedNetwork() { // eslint-disable-line no-unused-vars
|
||||
try {
|
||||
new PaymentRequest(
|
||||
[{supportedMethods: ['https://bobpay.com', 'basic-card']}],
|
||||
{
|
||||
[{supportedMethods: ['https://bobpay.com', 'basic-card']}], {
|
||||
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
||||
modifiers: [{
|
||||
supportedMethods: ['basic-card'],
|
@ -13,20 +13,16 @@
|
||||
function buy() { // eslint-disable-line no-unused-vars
|
||||
try {
|
||||
new PaymentRequest(
|
||||
[{supportedMethods: ['https://bobpay.com', 'basic-card']}],
|
||||
{
|
||||
[{supportedMethods: ['https://bobpay.com', 'basic-card']}], {
|
||||
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
||||
modifiers: [{
|
||||
supportedMethods: ['https://bobpay.com'],
|
||||
total: {
|
||||
label: 'Total',
|
||||
amount: {currency: 'USD', value: '4.00'}
|
||||
},
|
||||
total: {label: 'Total', amount: {currency: 'USD', value: '4.00'}},
|
||||
additionalDisplayItems: [{
|
||||
label: 'BobPay discount',
|
||||
amount: {currency: 'USD', value: '-1.00'}
|
||||
amount: {currency: 'USD', value: '-1.00'},
|
||||
}],
|
||||
data: {discountProgramParticipantId: '86328764873265'}
|
||||
data: {discountProgramParticipantId: '86328764873265'},
|
||||
}],
|
||||
})
|
||||
.show()
|
@ -19,8 +19,9 @@ function buy() { // eslint-disable-line no-unused-vars
|
||||
.then(function(resp) {
|
||||
resp.complete('success')
|
||||
.then(function() {
|
||||
print(resp.methodName + '<br>' +
|
||||
JSON.stringify(resp.details, undefined, 2));
|
||||
print(
|
||||
resp.methodName + '<br>' +
|
||||
JSON.stringify(resp.details, undefined, 2));
|
||||
})
|
||||
.catch(function(error) {
|
||||
print(error.message);
|
@ -23,8 +23,9 @@ function buy() { // eslint-disable-line no-unused-vars
|
||||
.then(function(resp) {
|
||||
resp.complete('success')
|
||||
.then(function() {
|
||||
print(resp.methodName + '<br>' +
|
||||
JSON.stringify(resp.details, undefined, 2));
|
||||
print(
|
||||
resp.methodName + '<br>' +
|
||||
JSON.stringify(resp.details, undefined, 2));
|
||||
})
|
||||
.catch(function(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() {
|
||||
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) {
|
||||
print(error.message);
|
||||
}
|
||||
@ -40,17 +44,25 @@ function queryShow() { // eslint-disable-line no-unused-vars
|
||||
[{supportedMethods: ['https://bobpay.com', 'visa']}],
|
||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
||||
request.canMakePayment()
|
||||
.then(function(result) { print(result); })
|
||||
.catch(function(error) { print(error); });
|
||||
.then(function(result) {
|
||||
print(result);
|
||||
})
|
||||
.catch(function(error) {
|
||||
print(error);
|
||||
});
|
||||
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(function(error) { print(error); });
|
||||
.catch(function(error) {
|
||||
print(error);
|
||||
});
|
||||
} catch (error) {
|
||||
print(error.message);
|
||||
}
|
||||
@ -65,8 +77,12 @@ function queryNoShow() { // eslint-disable-line no-unused-vars
|
||||
[{supportedMethods: ['https://bobpay.com', 'visa']}],
|
||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
||||
request.canMakePayment()
|
||||
.then(function(result) { print(result); })
|
||||
.catch(function(error) { print(error); });
|
||||
.then(function(result) {
|
||||
print(result);
|
||||
})
|
||||
.catch(function(error) {
|
||||
print(error);
|
||||
});
|
||||
} catch (error) {
|
||||
print(error.message);
|
||||
}
|
||||
@ -77,11 +93,13 @@ function queryNoShow() { // eslint-disable-line no-unused-vars
|
||||
*/
|
||||
function abort() { // eslint-disable-line no-unused-vars
|
||||
try {
|
||||
request.abort().then(() => {
|
||||
print('Aborted');
|
||||
}).catch(() => {
|
||||
print('Cannot abort');
|
||||
});
|
||||
request.abort()
|
||||
.then(function() {
|
||||
print('Aborted');
|
||||
})
|
||||
.catch(function() {
|
||||
print('Cannot abort');
|
||||
});
|
||||
} catch (error) {
|
||||
print(error.message);
|
||||
}
|
@ -13,6 +13,7 @@ var second;
|
||||
/**
|
||||
* Sets the |first| variable and prints both |first| and |second| only if both
|
||||
* were set.
|
||||
* @param {object} result The object to print.
|
||||
*/
|
||||
function printFirst(result) {
|
||||
first = result.toString();
|
||||
@ -24,6 +25,7 @@ function printFirst(result) {
|
||||
/**
|
||||
* Sets the |second| variable and prints both |first| and |second| only if both
|
||||
* were set.
|
||||
* @param {object} result The object to print.
|
||||
*/
|
||||
function printSecond(result) {
|
||||
second = result.toString();
|
||||
@ -44,8 +46,12 @@ function buy() { // eslint-disable-line no-unused-vars
|
||||
[{supportedMethods: ['https://bobpay.com']}],
|
||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}})
|
||||
.canMakePayment()
|
||||
.then(function(result) { printFirst(result); })
|
||||
.catch(function(error) { printFirst(error); });
|
||||
.then(function(result) {
|
||||
printFirst(result);
|
||||
})
|
||||
.catch(function(error) {
|
||||
printFirst(error);
|
||||
});
|
||||
} catch (error) {
|
||||
printFirst(error);
|
||||
}
|
||||
@ -55,8 +61,12 @@ function buy() { // eslint-disable-line no-unused-vars
|
||||
[{supportedMethods: ['https://bobpay.com']}],
|
||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}})
|
||||
.canMakePayment()
|
||||
.then(function(result) { printSecond(result); })
|
||||
.catch(function(error) { printSecond(error); });
|
||||
.then(function(result) {
|
||||
printSecond(result);
|
||||
})
|
||||
.catch(function(error) {
|
||||
printSecond(error);
|
||||
});
|
||||
} catch (error) {
|
||||
printSecond(error);
|
||||
}
|
||||
@ -74,8 +84,12 @@ function otherBuy() { // eslint-disable-line no-unused-vars
|
||||
[{supportedMethods: ['https://bobpay.com']}],
|
||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}})
|
||||
.canMakePayment()
|
||||
.then(function(result) { printFirst(result); })
|
||||
.catch(function(error) { printFirst(error); });
|
||||
.then(function(result) {
|
||||
printFirst(result);
|
||||
})
|
||||
.catch(function(error) {
|
||||
printFirst(error);
|
||||
});
|
||||
} catch (error) {
|
||||
printFirst(error);
|
||||
}
|
||||
@ -85,8 +99,12 @@ function otherBuy() { // eslint-disable-line no-unused-vars
|
||||
[{supportedMethods: ['https://alicepay.com']}],
|
||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}})
|
||||
.canMakePayment()
|
||||
.then(function(result) { printSecond(result); })
|
||||
.catch(function(error) { printSecond(error); });
|
||||
.then(function(result) {
|
||||
printSecond(result);
|
||||
})
|
||||
.catch(function(error) {
|
||||
printSecond(error);
|
||||
});
|
||||
} catch (error) {
|
||||
printSecond(error);
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
*/
|
||||
function buy() { // eslint-disable-line no-unused-vars
|
||||
try {
|
||||
const request = new PaymentRequest(
|
||||
var request = new PaymentRequest(
|
||||
[{supportedMethods: ['visa']}],
|
||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
||||
request.canMakePayment()
|
||||
@ -29,7 +29,7 @@ function buy() { // eslint-disable-line no-unused-vars
|
||||
*/
|
||||
function other_buy() { // eslint-disable-line no-unused-vars, camelcase
|
||||
try {
|
||||
const request = new PaymentRequest(
|
||||
var request = new PaymentRequest(
|
||||
[{supportedMethods: ['mastercard']}],
|
||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
||||
request.canMakePayment()
|
@ -13,9 +13,11 @@ function buy() { // eslint-disable-line no-unused-vars
|
||||
try {
|
||||
new PaymentRequest(
|
||||
[{supportedMethods: ['https://bobpay.com', 'amex', 'visa']}],
|
||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}},
|
||||
{requestPayerName: true, requestPayerEmail: true,
|
||||
requestPayerPhone: true})
|
||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}}, {
|
||||
requestPayerName: true,
|
||||
requestPayerEmail: true,
|
||||
requestPayerPhone: true,
|
||||
})
|
||||
.show()
|
||||
.then(function(resp) {
|
||||
resp.complete('success')
|
@ -13,18 +13,21 @@
|
||||
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
|
||||
}]
|
||||
};
|
||||
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', 'https://bobpay.com']}], details,
|
||||
{requestPayerName: true, requestPayerEmail: true,
|
||||
requestPayerPhone: true, requestShipping: true});
|
||||
[{supportedMethods: ['visa', 'https://bobpay.com']}], details, {
|
||||
requestPayerName: true,
|
||||
requestPayerEmail: true,
|
||||
requestPayerPhone: true,
|
||||
requestShipping: true,
|
||||
});
|
||||
|
||||
request.addEventListener('shippingaddresschange', function(e) {
|
||||
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',
|
||||
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(
|
||||
@ -67,7 +64,7 @@ function updateDetails(details, addr) {
|
||||
id: '',
|
||||
label: '',
|
||||
amount: {currency: 'USD', value: '0.00'},
|
||||
selected: true
|
||||
selected: true,
|
||||
};
|
||||
if (addr.region === 'CA') {
|
||||
shippingOption.id = 'californiaShippingOption';
|
@ -6,7 +6,7 @@
|
||||
|
||||
/* global PaymentRequest:false */
|
||||
|
||||
/*
|
||||
/**
|
||||
* Launches the PaymentRequest UI that requests email address.
|
||||
*/
|
||||
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 */
|
||||
|
||||
/*
|
||||
/**
|
||||
* Launches the PaymentRequest UI that requests email address and phone number.
|
||||
*/
|
||||
function buy() { // eslint-disable-line no-unused-vars
|
@ -19,15 +19,16 @@ function buy() { // eslint-disable-line no-unused-vars
|
||||
id: 'freeShippingOption',
|
||||
label: 'Free global shipping',
|
||||
amount: {currency: 'USD', value: '0'},
|
||||
selected: true
|
||||
}]
|
||||
selected: true,
|
||||
}],
|
||||
};
|
||||
var request = new PaymentRequest([{supportedMethods: ['visa']}], details);
|
||||
request.show()
|
||||
.then(function(resp) {
|
||||
resp.complete('success')
|
||||
.then(function() {
|
||||
print(resp.methodName + '<br>' +
|
||||
print(
|
||||
resp.methodName + '<br>' +
|
||||
JSON.stringify(resp.details, undefined, 2));
|
||||
})
|
||||
.catch(function(error) {
|
@ -18,14 +18,23 @@ function buy() { // eslint-disable-line no-unused-vars
|
||||
id: 'freeShippingOption',
|
||||
label: 'Free global shipping',
|
||||
amount: {currency: 'USD', value: '0'},
|
||||
selected: true
|
||||
}]
|
||||
selected: true,
|
||||
}],
|
||||
};
|
||||
var request = new PaymentRequest(
|
||||
[{supportedMethods: ['visa', 'unionpay', 'mir', 'mastercard',
|
||||
'jcb', 'discover', 'diners', 'amex']}],
|
||||
details,
|
||||
{requestShipping: true});
|
||||
[{
|
||||
supportedMethods: [
|
||||
'visa',
|
||||
'unionpay',
|
||||
'mir',
|
||||
'mastercard',
|
||||
'jcb',
|
||||
'discover',
|
||||
'diners',
|
||||
'amex',
|
||||
],
|
||||
}],
|
||||
details, {requestShipping: true});
|
||||
request.addEventListener('shippingaddresschange', function(e) {
|
||||
e.updateWith(new Promise(function(resolve) {
|
||||
// No changes in price based on shipping address change.
|
@ -11,9 +11,9 @@
|
||||
* The Payment Request for this page.
|
||||
* @const
|
||||
*/
|
||||
let REQUEST = new PaymentRequest(
|
||||
[{supportedMethods: ['https://bobpay.com', 'visa']}],
|
||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
||||
var REQUEST = new PaymentRequest(
|
||||
[{supportedMethods: ['https://bobpay.com', 'visa']}],
|
||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
||||
|
||||
/**
|
||||
* 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
|
||||
try {
|
||||
REQUEST.abort().then(() => {
|
||||
print('Aborted');
|
||||
}).catch(() => {
|
||||
print('Cannot abort');
|
||||
});
|
||||
REQUEST.abort()
|
||||
.then(function() {
|
||||
print('Aborted');
|
||||
})
|
||||
.catch(function() {
|
||||
print('Cannot abort');
|
||||
});
|
||||
} catch (error) {
|
||||
print(error.message);
|
||||
}
|
@ -5,12 +5,10 @@
|
||||
*/
|
||||
|
||||
/** Invokes PaymentRequest with a very long request identifier. */
|
||||
function buy() { // eslint-disable-line no-unused-vars
|
||||
const foo = Object.freeze({
|
||||
supportedMethods: ['basic-card']
|
||||
});
|
||||
const defaultMethods = Object.freeze([foo]);
|
||||
const defaultDetails = Object.freeze({
|
||||
function buy() { // eslint-disable-line no-unused-vars
|
||||
var foo = Object.freeze({supportedMethods: ['basic-card']});
|
||||
var defaultMethods = Object.freeze([foo]);
|
||||
var defaultDetails = Object.freeze({
|
||||
total: {
|
||||
label: 'Label',
|
||||
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 '),
|
||||
});
|
||||
try {
|
||||
const request = new PaymentRequest(defaultMethods, newDetails);
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
var request = new PaymentRequest(defaultMethods, newDetails);
|
||||
} catch (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
|
||||
* required fields.
|
||||
*/
|
||||
function buy() { // eslint-disable-line no-unused-vars
|
||||
function buy() { // eslint-disable-line no-unused-vars
|
||||
try {
|
||||
new PaymentRequest(
|
||||
[{
|
||||
supportedMethods: ['foo'],
|
||||
}], {
|
||||
}],
|
||||
{
|
||||
total: {
|
||||
label: 'Total',
|
||||
amount: {
|
||||
@ -25,19 +26,19 @@ function buy() { // eslint-disable-line no-unused-vars
|
||||
supportedMethods: ['foo'],
|
||||
}],
|
||||
})
|
||||
.show()
|
||||
.then(function(response) {
|
||||
response.complete()
|
||||
.then(function() {
|
||||
print(complete);
|
||||
})
|
||||
.catch(function(error) {
|
||||
print(error);
|
||||
});
|
||||
})
|
||||
.catch(function(error) {
|
||||
print(error);
|
||||
});
|
||||
.show()
|
||||
.then(function(response) {
|
||||
response.complete()
|
||||
.then(function() {
|
||||
print(complete);
|
||||
})
|
||||
.catch(function(error) {
|
||||
print(error);
|
||||
});
|
||||
})
|
||||
.catch(function(error) {
|
||||
print(error);
|
||||
});
|
||||
} catch (error) {
|
||||
print(error.message);
|
||||
}
|
@ -23,9 +23,13 @@ function buy() { // eslint-disable-line no-unused-vars
|
||||
.then(function() {
|
||||
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) {
|
||||
print(error.message);
|
||||
}
|
||||
@ -42,9 +46,13 @@ function showAgain() { // eslint-disable-line no-unused-vars
|
||||
.then(function() {
|
||||
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) {
|
||||
print(error.message);
|
||||
}
|
||||
@ -64,9 +72,13 @@ function showSecondRequest() { // eslint-disable-line no-unused-vars
|
||||
.then(function() {
|
||||
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) {
|
||||
print(error.message);
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
|
||||
/* global PaymentRequest:false */
|
||||
|
||||
/*
|
||||
/**
|
||||
* Launches the PaymentRequest UI that requests payer name.
|
||||
*/
|
||||
function buy() { // eslint-disable-line no-unused-vars
|
@ -19,8 +19,8 @@ function buy() { // eslint-disable-line no-unused-vars
|
||||
id: 'freeShippingOption',
|
||||
label: 'Free global shipping',
|
||||
amount: {currency: 'USD', value: '0'},
|
||||
selected: true
|
||||
}]
|
||||
selected: true,
|
||||
}],
|
||||
},
|
||||
{requestPayerName: true, requestShipping: true});
|
||||
request.show()
|
@ -17,10 +17,10 @@ function buy() { // eslint-disable-line no-unused-vars
|
||||
{
|
||||
label: 'Subtotal',
|
||||
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()
|
||||
.then(function(resp) {
|
@ -11,23 +11,22 @@
|
||||
*/
|
||||
function canMakePaymentHelper(methodData) {
|
||||
try {
|
||||
new PaymentRequest(
|
||||
methodData, {
|
||||
total: {
|
||||
label: 'Total',
|
||||
amount: {
|
||||
currency: 'USD',
|
||||
value: '5.00',
|
||||
},
|
||||
},
|
||||
new PaymentRequest(methodData, {
|
||||
total: {
|
||||
label: 'Total',
|
||||
amount: {
|
||||
currency: 'USD',
|
||||
value: '5.00',
|
||||
},
|
||||
},
|
||||
})
|
||||
.canMakePayment()
|
||||
.then(function(result) {
|
||||
print(result);
|
||||
})
|
||||
.canMakePayment()
|
||||
.then(function(result) {
|
||||
print(result);
|
||||
})
|
||||
.catch(function(error) {
|
||||
print(error);
|
||||
});
|
||||
.catch(function(error) {
|
||||
print(error);
|
||||
});
|
||||
} catch (error) {
|
||||
print(error);
|
||||
}
|
||||
@ -37,7 +36,7 @@ function canMakePaymentHelper(methodData) {
|
||||
* Merchant checks for ability to pay using "basic-card" regardless of issuer
|
||||
* network.
|
||||
*/
|
||||
function checkBasicCard() { // eslint-disable-line no-unused-vars
|
||||
function checkBasicCard() { // eslint-disable-line no-unused-vars
|
||||
canMakePaymentHelper([{
|
||||
supportedMethods: ['basic-card'],
|
||||
}]);
|
||||
@ -46,7 +45,7 @@ function checkBasicCard() { // eslint-disable-line no-unused-vars
|
||||
/**
|
||||
* 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([{
|
||||
supportedMethods: ['basic-card'],
|
||||
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
|
||||
* the supported network.
|
||||
*/
|
||||
function checkBasicMasterCard() { // eslint-disable-line no-unused-vars
|
||||
function checkBasicMasterCard() { // eslint-disable-line no-unused-vars
|
||||
canMakePaymentHelper([{
|
||||
supportedMethods: ['basic-card'],
|
||||
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
|
||||
* supported network.
|
||||
*/
|
||||
function checkBasicVisa() { // eslint-disable-line no-unused-vars
|
||||
function checkBasicVisa() { // eslint-disable-line no-unused-vars
|
||||
canMakePaymentHelper([{
|
||||
supportedMethods: ['basic-card'],
|
||||
data: {
|
||||
@ -84,7 +83,7 @@ function checkBasicVisa() { // eslint-disable-line no-unused-vars
|
||||
/**
|
||||
* 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([{
|
||||
supportedMethods: ['mastercard'],
|
||||
}]);
|
||||
@ -93,7 +92,7 @@ function checkMasterCard() { // eslint-disable-line no-unused-vars
|
||||
/**
|
||||
* 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([{
|
||||
supportedMethods: ['visa'],
|
||||
}]);
|
||||
@ -107,27 +106,27 @@ function checkVisa() { // eslint-disable-line no-unused-vars
|
||||
function buyHelper(methodData) {
|
||||
try {
|
||||
new PaymentRequest(methodData, {
|
||||
total: {
|
||||
label: 'Total',
|
||||
amount: {
|
||||
currency: 'USD',
|
||||
value: '5.00',
|
||||
},
|
||||
total: {
|
||||
label: 'Total',
|
||||
amount: {
|
||||
currency: 'USD',
|
||||
value: '5.00',
|
||||
},
|
||||
})
|
||||
.show()
|
||||
.then(function(response) {
|
||||
response.complete('success')
|
||||
.then(function() {
|
||||
print(JSON.stringify(response, undefined, 2));
|
||||
})
|
||||
.catch(function(error) {
|
||||
print(error);
|
||||
});
|
||||
})
|
||||
.catch(function(error) {
|
||||
print(error);
|
||||
});
|
||||
},
|
||||
})
|
||||
.show()
|
||||
.then(function(response) {
|
||||
response.complete('success')
|
||||
.then(function() {
|
||||
print(JSON.stringify(response, undefined, 2));
|
||||
})
|
||||
.catch(function(error) {
|
||||
print(error);
|
||||
});
|
||||
})
|
||||
.catch(function(error) {
|
||||
print(error);
|
||||
});
|
||||
} catch (error) {
|
||||
print(error);
|
||||
}
|
||||
@ -137,21 +136,24 @@ function buyHelper(methodData) {
|
||||
* Merchant requests payment via either "mastercard" or "basic-card" with "visa"
|
||||
* as the supported network.
|
||||
*/
|
||||
function buy() { // eslint-disable-line no-unused-vars
|
||||
buyHelper([{
|
||||
supportedMethods: ['mastercard'],
|
||||
}, {
|
||||
supportedMethods: ['basic-card'],
|
||||
data: {
|
||||
supportedNetworks: ['visa'],
|
||||
function buy() { // eslint-disable-line no-unused-vars
|
||||
buyHelper([
|
||||
{
|
||||
supportedMethods: ['mastercard'],
|
||||
},
|
||||
}]);
|
||||
{
|
||||
supportedMethods: ['basic-card'],
|
||||
data: {
|
||||
supportedNetworks: ['visa'],
|
||||
},
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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([{
|
||||
supportedMethods: ['basic-card'],
|
||||
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
|
||||
* type.
|
||||
*/
|
||||
function buyBasicDebit() { // eslint-disable-line no-unused-vars
|
||||
function buyBasicDebit() { // eslint-disable-line no-unused-vars
|
||||
buyHelper([{
|
||||
supportedMethods: ['basic-card'],
|
||||
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
|
||||
* type.
|
||||
*/
|
||||
function buyBasicDebit() { // eslint-disable-line no-unused-vars
|
||||
function buyBasicDebit() { // eslint-disable-line no-unused-vars
|
||||
buyHelper([{
|
||||
supportedMethods: ['basic-card'],
|
||||
data: {
|
||||
@ -190,7 +192,7 @@ function buyBasicDebit() { // eslint-disable-line no-unused-vars
|
||||
* Merchant requests payment via "basic-card" payment method with "mastercard"
|
||||
* as the only supported network.
|
||||
*/
|
||||
function buyBasicMasterCard() { // eslint-disable-line no-unused-vars
|
||||
function buyBasicMasterCard() { // eslint-disable-line no-unused-vars
|
||||
buyHelper([{
|
||||
supportedMethods: ['basic-card'],
|
||||
data: {
|
@ -11,7 +11,7 @@ found in the LICENSE file.
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
</head>
|
||||
<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>
|
||||
<pre id="result"></pre>
|
||||
<script src="util.js"></script>
|
@ -12,7 +12,9 @@ found in the LICENSE file.
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
</head>
|
||||
<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>
|
||||
<script src="util.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">
|
||||
</head>
|
||||
<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>
|
||||
<script src="util.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">
|
||||
</head>
|
||||
<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>
|
||||
<script src="util.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">
|
||||
</head>
|
||||
<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>
|
||||
<script src="util.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">
|
||||
</head>
|
||||
<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>
|
||||
<script src="util.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">
|
||||
</head>
|
||||
<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>
|
||||
<script src="util.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">
|
||||
</head>
|
||||
<body>
|
||||
<button onclick="noQueryShow()" id="noQueryShow">No Query Show Test</button><br>
|
||||
<button onclick="queryShow()" id="queryShow">Query Show Test</button><br>
|
||||
<button onclick="queryNoShow()" id="queryNoShow">Query No Show Test</button><br>
|
||||
<button onclick="abort()" id="abort">Abort</button><br>
|
||||
<div>
|
||||
<button onclick="noQueryShow()" id="noQueryShow">No Query Show Test</button>
|
||||
</div>
|
||||
<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>
|
||||
<script src="util.js"></script>
|
||||
<script src="can_make_payment_metrics.js"></script>
|
@ -10,10 +10,10 @@
|
||||
*/
|
||||
function buy() { // eslint-disable-line no-unused-vars
|
||||
try {
|
||||
new PaymentRequest(
|
||||
[{supportedMethods: ['visa']}],
|
||||
{id: 'my_payment_id',
|
||||
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}})
|
||||
new PaymentRequest([{supportedMethods: ['visa']}], {
|
||||
id: 'my_payment_id',
|
||||
total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
|
||||
})
|
||||
.show()
|
||||
.then(function(resp) {
|
||||
resp.complete('success')
|
@ -14,7 +14,7 @@ found in the LICENSE file.
|
||||
</head>
|
||||
|
||||
<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>
|
||||
<script src="util.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">
|
||||
</head>
|
||||
<body>
|
||||
<button onclick="buy()" id="buy">Modifier Test</button><br>
|
||||
<div><button onclick="buy()" id="buy">Modifier Test</button></div>
|
||||
<pre id="result"></pre>
|
||||
<script src="util.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">
|
||||
</head>
|
||||
<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>
|
||||
<script src="util.js"></script>
|
||||
<script src="name_and_free_shipping.js"></script>
|
@ -19,8 +19,8 @@ function buy() { // eslint-disable-line no-unused-vars
|
||||
id: 'freeShippingOption',
|
||||
label: 'Free global shipping',
|
||||
amount: {currency: 'USD', value: '0'},
|
||||
selected: true
|
||||
}]
|
||||
selected: true,
|
||||
}],
|
||||
},
|
||||
{requestPayerPhone: true, requestShipping: true});
|
||||
request.show()
|
@ -16,20 +16,15 @@ function buy() { // eslint-disable-line no-unused-vars
|
||||
{
|
||||
label: 'Pending shipping price',
|
||||
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(
|
||||
[{supportedMethods: ['visa']}], details, {requestShipping: true});
|
||||
|
||||
var shippingAddressChange;
|
||||
|
||||
request.addEventListener('shippingaddresschange', function(evt) {
|
||||
evt.updateWith(new Promise(function(resolve) {
|
||||
print(JSON.stringify(request.shippingAddress, undefined, 2));
|
@ -8,10 +8,10 @@
|
||||
* Launches the PaymentRequest UI twice.
|
||||
*/
|
||||
function buy() { // eslint-disable-line no-unused-vars
|
||||
const payment1 = new PaymentRequest(
|
||||
var payment1 = new PaymentRequest(
|
||||
[{supportedMethods: ['visa']}],
|
||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
||||
const payment2 = new PaymentRequest(
|
||||
var payment2 = new PaymentRequest(
|
||||
[{supportedMethods: ['visa']}],
|
||||
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
|
||||
payment1.show();
|
@ -5,9 +5,9 @@
|
||||
*/
|
||||
|
||||
button {
|
||||
width: 100%;
|
||||
height: 5em;
|
||||
font-size: 3em;
|
||||
height: 5em;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
pre {
|
@ -8,6 +8,6 @@
|
||||
* Prints the message.
|
||||
* @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;
|
||||
}
|
Reference in New Issue
Block a user