-
Notifications
You must be signed in to change notification settings - Fork 1
/
payment-item.js
98 lines (83 loc) · 2.27 KB
/
payment-item.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
const $_documentContainer = document.createElement('template');
$_documentContainer.innerHTML = `<dom-module id="payment-item">
<template>
<style>
:host {
display: none;
}
</style>
</template>
</dom-module>`;
document.head.appendChild($_documentContainer.content);
/*
`payment-item`
PaymentItem dictionary implementation from browser payment API
*/
export const PaymentItem = class extends PolymerElement {
static get is() {
return 'payment-item';
}
static get properties() {
return {
/**
* This is a human-readable description of the item.
* The user agent may display this to the user.
*/
label: String,
/**
* A valid decimal monetary value containing a monetary amount of the item.
*/
value: Number,
/**
* A string containing a currency identifier of the item.
* The value of currency can be any string that is valid within
* the currency system indicated by currencySystem.
*/
currency: String,
/**
* A URL that indicates the currency system
* that the currency identifier belongs to
*/
currencySystem: {
type: String,
value: 'urn:iso:std:iso:4217'
},
/**
* Contain the monetary amount for the item.
*/
amount: {
type: Object,
computed: '_computeAmount(value, currency, currencySystem)'
},
/**
* When set to true this flag means that the amount member is not final.
* This is commonly used to show items such as shipping or tax amounts
* that depend upon selection of shipping address or shipping option.
*/
pending: {
type: Boolean,
value: false
},
dictionary: {
type: Object,
computed: '_computeDictionary(label, amount, pending)'
}
}
}
_computeAmount(value, currency, currencySystem) {
return {
value: value,
currency: currency,
currencySystem: currencySystem
};
}
_computeDictionary(label, amount, pending) {
return {
label: label,
amount: amount,
pending: pending
};
}
};
window.customElements.define(PaymentItem.is, PaymentItem);