Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5939)

Unified Diff: chrome/test/data/android/payments/basic_card.js

Issue 2501593003: Implement the new basic card specification. (Closed)
Patch Set: Rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/android/payments/basic_card.js
diff --git a/chrome/test/data/android/payments/basic_card.js b/chrome/test/data/android/payments/basic_card.js
new file mode 100644
index 0000000000000000000000000000000000000000..ce2201404e94af48c0ed7d99b9e037472117b92f
--- /dev/null
+++ b/chrome/test/data/android/payments/basic_card.js
@@ -0,0 +1,274 @@
+/*
+ * 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.
+ */
+
+/**
+ * Merchant checks for ability to pay using debit cards.
+ */
+function checkBasicDebit() { // eslint-disable-line no-unused-vars
+ try {
+ new PaymentRequest(
+ [{
+ supportedMethods: ['basic-card'],
+ data: {
+ supportedTypes: ['debit'],
+ },
+ }], {
+ total: {
+ label: 'Total',
+ amount: {
+ currency: 'USD',
+ value: '5.00',
+ },
+ },
+ })
+ .canMakePayment()
+ .then(function(result) {
+ print(result);
+ })
+ .catch(function(error) {
+ print(error);
+ });
+ } catch (error) {
+ print(error);
+ }
+}
+
+/**
+ * Merchant checks for ability to pay using "basic-card" with "mastercard" as
+ * the supported network.
+ */
+function checkBasicMasterCard() { // eslint-disable-line no-unused-vars
+ try {
+ new PaymentRequest(
+ [{
+ supportedMethods: ['basic-card'],
+ data: {
+ supportedNetworks: ['mastercard'],
+ },
+ }], {
+ total: {
+ label: 'Total',
+ amount: {
+ currency: 'USD',
+ value: '5.00',
+ },
+ },
+ })
+ .canMakePayment()
+ .then(function(result) {
+ print(result);
+ })
+ .catch(function(error) {
+ print(error);
+ });
+ } catch (error) {
+ print(error);
+ }
+}
+
+/**
+ * Merchant checks for ability to pay using "basic-card" with "visa" as the
+ * supported network.
+ */
+function checkBasicVisa() { // eslint-disable-line no-unused-vars
+ try {
+ new PaymentRequest(
+ [{
+ supportedMethods: ['basic-card'],
+ data: {
+ supportedNetworks: ['visa'],
+ },
+ }], {
+ total: {
+ label: 'Total',
+ amount: {
+ currency: 'USD',
+ value: '5.00',
+ },
+ },
+ })
+ .canMakePayment()
+ .then(function(result) {
+ print(result);
+ })
+ .catch(function(error) {
+ print(error);
+ });
+ } catch (error) {
+ print(error);
+ }
+}
+
+/**
+ * Merchant checks for ability to pay using "mastercard".
+ */
+function checkMasterCard() { // eslint-disable-line no-unused-vars
+ try {
+ new PaymentRequest(
+ [{
+ supportedMethods: ['mastercard'],
+ }], {
+ total: {
+ label: 'Total',
+ amount: {
+ currency: 'USD',
+ value: '5.00',
+ },
+ },
+ })
+ .canMakePayment()
+ .then(function(result) {
+ print(result);
+ })
+ .catch(function(error) {
+ print(error);
+ });
+ } catch (error) {
+ print(error);
+ }
+}
+
+/**
+ * Merchant checks for ability to pay using "visa".
+ */
+function checkVisa() { // eslint-disable-line no-unused-vars
+ try {
+ new PaymentRequest(
+ [{
+ supportedMethods: ['visa'],
+ }], {
+ total: {
+ label: 'Total',
+ amount: {
+ currency: 'USD',
+ value: '5.00',
+ },
+ },
+ })
+ .canMakePayment()
+ .then(function(result) {
+ print(result);
+ })
+ .catch(function(error) {
+ print(error);
+ });
+ } catch (error) {
+ print(error);
+ }
+}
+
+/**
+ * Merchant requests payment via either "mastercard" or "basic-card" with "visa"
+ * as the supported network.
+ */
+function buy() { // eslint-disable-line no-unused-vars
+ try {
+ new PaymentRequest(
+ [{
+ supportedMethods: ['mastercard'],
+ }, {
+ supportedMethods: ['basic-card'],
+ data: {
+ supportedNetworks: ['visa'],
+ },
+ }], {
+ 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);
+ });
+ } catch (error) {
+ print(error);
+ }
+}
+
+/**
+ * Merchant requests payment via "basic-card" with "debit" as the supported card
+ * type.
+ */
+function buyBasicDebit() { // eslint-disable-line no-unused-vars
+ try {
+ new PaymentRequest(
+ [{
+ supportedMethods: ['basic-card'],
+ data: {
+ supportedTypes: ['debit'],
+ },
+ }], {
+ 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);
+ });
+ } catch (error) {
+ print(error);
+ }
+}
+
+/**
+ * Merchant requests payment via "basic-card" payment method with "mastercard"
+ * as the only supported network.
+ */
+function buyBasicMasterCard() { // eslint-disable-line no-unused-vars
+ try {
+ new PaymentRequest(
+ [{
+ supportedMethods: ['basic-card'],
+ data: {
+ supportedNetworks: ['mastercard'],
+ },
+ }], {
+ 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);
+ });
+ } catch (error) {
+ print(error);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698