| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 The Chromium Authors. All rights reserved. | 2 * Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /* global PaymentRequest:false */ | 7 /* global PaymentRequest:false */ |
| 8 /* global toDictionary:false */ | 8 /* global toDictionary:false */ |
| 9 | 9 |
| 10 var request; | 10 var request; |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * Launches the PaymentRequest UI that accepts credit cards. | 13 * Launches the PaymentRequest UI that accepts credit cards. |
| 14 */ | 14 */ |
| 15 function buy() { // eslint-disable-line no-unused-vars | 15 function ccBuy() { // eslint-disable-line no-unused-vars |
| 16 try { | 16 try { |
| 17 request = new PaymentRequest( | 17 request = new PaymentRequest( |
| 18 [{supportedMethods: ['visa']}], { | 18 [{supportedMethods: ['visa']}], { |
| 19 total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}, | 19 total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}, |
| 20 shippingOptions: [{ | 20 shippingOptions: [{ |
| 21 id: 'freeShippingOption', | 21 id: 'freeShippingOption', |
| 22 label: 'Free global shipping', | 22 label: 'Free global shipping', |
| 23 amount: {currency: 'USD', value: '0'}, | 23 amount: {currency: 'USD', value: '0'}, |
| 24 selected: true | 24 selected: true |
| 25 }] | 25 }] |
| (...skipping 11 matching lines...) Expand all Loading... |
| 37 JSON.stringify(resp.details, undefined, 2)); | 37 JSON.stringify(resp.details, undefined, 2)); |
| 38 }).catch(function(error) { | 38 }).catch(function(error) { |
| 39 print(error); | 39 print(error); |
| 40 }); | 40 }); |
| 41 } catch (error) { | 41 } catch (error) { |
| 42 print(error.message); | 42 print(error.message); |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 | 45 |
| 46 /** | 46 /** |
| 47 * Launches the PaymentRequest UI which accepts a supported payment method but | 47 * Launches the PaymentRequest UI which accepts only Android Pay. |
| 48 * does not accept credit cards. | |
| 49 */ | 48 */ |
| 50 function noMatching() { // eslint-disable-line no-unused-vars | 49 function androidPayBuy() { // eslint-disable-line no-unused-vars |
| 51 try { | 50 try { |
| 52 request = new PaymentRequest( | 51 request = new PaymentRequest( |
| 53 [{supportedMethods: ['https://bobpay.com']}], { | 52 [{supportedMethods: ['https://android.com/pay']}], { |
| 54 total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}, | 53 total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}, |
| 55 shippingOptions: [{ | 54 shippingOptions: [{ |
| 56 id: 'freeShippingOption', | 55 id: 'freeShippingOption', |
| 57 label: 'Free global shipping', | 56 label: 'Free global shipping', |
| 58 amount: {currency: 'USD', value: '0'}, | 57 amount: {currency: 'USD', value: '0'}, |
| 59 selected: true | 58 selected: true |
| 60 }] | 59 }] |
| 61 }, | 60 }, |
| 62 {requestShipping: true}); | 61 {requestShipping: true}); |
| 63 request.show() | 62 request.show() |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 try { | 119 try { |
| 121 request.abort().then(function() { | 120 request.abort().then(function() { |
| 122 print('Aborted'); | 121 print('Aborted'); |
| 123 }).catch(function() { | 122 }).catch(function() { |
| 124 print('Cannot abort'); | 123 print('Cannot abort'); |
| 125 }); | 124 }); |
| 126 } catch (error) { | 125 } catch (error) { |
| 127 print(error.message); | 126 print(error.message); |
| 128 } | 127 } |
| 129 } | 128 } |
| OLD | NEW |