@ponchopay/pp-browser 1.0.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/src/PpPayment.d.ts +2 -0
- package/dist/src/PpPayment.js +8 -0
- package/dist/src/PpPayment.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ The web component can be used by declaring it in HTML like this:
|
|
|
41
41
|
<pp-payment {properties}>{text}</pp-payment>
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
The following the list of accepted properties (please, refer to the [official documentation](https://
|
|
44
|
+
The following the list of accepted properties (please, refer to the [official documentation](https://pay.ponchopay.com/api/docs) for their meaning):
|
|
45
45
|
|
|
46
46
|
| Name | Mandatory |
|
|
47
47
|
| -------- | --------- |
|
|
@@ -51,6 +51,7 @@ The following the list of accepted properties (please, refer to the [official do
|
|
|
51
51
|
| amount | Yes |
|
|
52
52
|
| email | Yes |
|
|
53
53
|
| note | No |
|
|
54
|
+
| expiry | No |
|
|
54
55
|
|
|
55
56
|
The component's text is optional being "Pay with PonchoPay" the default text. Feel free to change it as you see fit.
|
|
56
57
|
|
package/dist/src/PpPayment.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export declare class PpPayment extends HTMLElement {
|
|
|
16
16
|
get email(): string;
|
|
17
17
|
set note(value: string);
|
|
18
18
|
get note(): string;
|
|
19
|
+
set expiry(value: Date | string);
|
|
20
|
+
get expiry(): string;
|
|
19
21
|
attributeChangedCallback(): void;
|
|
20
22
|
static get observedAttributes(): string[];
|
|
21
23
|
}
|
package/dist/src/PpPayment.js
CHANGED
|
@@ -7,6 +7,7 @@ const ATTRIBUTES = [
|
|
|
7
7
|
'amount',
|
|
8
8
|
'email',
|
|
9
9
|
'note',
|
|
10
|
+
'expiry',
|
|
10
11
|
];
|
|
11
12
|
const STYLES = [
|
|
12
13
|
'width: 100%',
|
|
@@ -97,6 +98,13 @@ export class PpPayment extends HTMLElement {
|
|
|
97
98
|
var _a;
|
|
98
99
|
return (_a = this.getAttribute('note')) !== null && _a !== void 0 ? _a : '';
|
|
99
100
|
}
|
|
101
|
+
set expiry(value) {
|
|
102
|
+
this.setAttribute('expiry', value instanceof Date ? value.toISOString() : value);
|
|
103
|
+
}
|
|
104
|
+
get expiry() {
|
|
105
|
+
var _a;
|
|
106
|
+
return (_a = this.getAttribute('expiry')) !== null && _a !== void 0 ? _a : '';
|
|
107
|
+
}
|
|
100
108
|
attributeChangedCallback() {
|
|
101
109
|
this.redrawContents();
|
|
102
110
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PpPayment.js","sourceRoot":"","sources":["../../src/PpPayment.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,UAAU,GACX,MAAM,SAAS,CAAC;AAEjB,MAAM,QAAQ,GAAG,mCAAmC,CAAC;AACrD,MAAM,UAAU,GAAG;IACjB,OAAO;IACP,UAAU;IACV,KAAK;IACL,QAAQ;IACR,OAAO;IACP,MAAM;
|
|
1
|
+
{"version":3,"file":"PpPayment.js","sourceRoot":"","sources":["../../src/PpPayment.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,UAAU,GACX,MAAM,SAAS,CAAC;AAEjB,MAAM,QAAQ,GAAG,mCAAmC,CAAC;AACrD,MAAM,UAAU,GAAG;IACjB,OAAO;IACP,UAAU;IACV,KAAK;IACL,QAAQ;IACR,OAAO;IACP,MAAM;IACN,QAAQ;CACA,CAAC;AACX,MAAM,MAAM,GAAG;IACb,aAAa;IACb,2BAA2B;IAC3B,qBAAqB;IACrB,4BAA4B;IAC5B,uBAAuB;IACvB,2CAA2C;IAC3C,oBAAoB;IACpB,oBAAoB;IACpB,sBAAsB;IACtB,cAAc;IACd,mBAAmB;IACnB,uBAAuB;IACvB,sBAAsB;I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AAI,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,IAAW,IAAI;;QACb,OAAO,MAAA,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,mCAAI,EAAE,CAAC;IACzC,CAAC;IAED,IAAW,MAAM,CAAC,KAAoB;QACpC,IAAI,CAAC,YAAY,CACf,QAAQ,EACR,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CACpD,CAAC;IACJ,CAAC;IAED,IAAW,MAAM;;QACf,OAAO,MAAA,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,mCAAI,EAAE,CAAC;IAC3C,CAAC;IAEM,wBAAwB;QAC7B,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IAEM,MAAM,KAAK,kBAAkB;QAClC,OAAO,CAAC,GAAG,UAAU,EAAE,MAAM,CAAC,CAAC;IACjC,CAAC;CACF","sourcesContent":["import {\n buildButton,\n buildForm,\n buildHiddenInput,\n buildSlot,\n buildStyle,\n} from './utils';\n\nconst ENDPOINT = '/api/integration/generic/initiate';\nconst ATTRIBUTES = [\n 'token',\n 'metadata',\n 'urn',\n 'amount',\n 'email',\n 'note',\n 'expiry',\n] as const;\nconst STYLES = [\n 'width: 100%',\n 'background-color: #02C2A0',\n 'white-space: nowrap',\n 'text-decoration-line: none',\n 'border-radius: .25rem',\n 'box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05)',\n 'text-align: center',\n 'font-size: 1.25rem',\n 'line-height: 1.75rem',\n 'color: white',\n 'margin-top: .5rem',\n 'margin-bottom: .75rem',\n 'padding: .75rem 1rem',\n 'display: flex',\n 'flex-wrap: nowrap',\n 'align-items: center',\n 'justify-content: space-evenly',\n 'cursor: pointer',\n 'text-transform: none',\n 'box-sizing: border-box',\n 'border-width: 0',\n 'border-style: solid',\n 'border-color: currentColor',\n];\n\nexport class PpPayment extends HTMLElement {\n private sr: ShadowRoot;\n\n public constructor() {\n super();\n\n this.sr = this.attachShadow({ mode: 'open' });\n this.redrawContents();\n }\n\n private redrawContents(): void {\n let base = this.base;\n while (base.slice(-1) === '/') base = base.slice(0, -1);\n if (base === '') base = 'https://pay.ponchopay.com';\n\n this.sr.replaceChildren();\n this.sr.appendChild(\n buildForm(\n `${base}${ENDPOINT}`,\n ...ATTRIBUTES.filter(name => this[name] !== '').map(name =>\n buildHiddenInput(name, this[name])\n ),\n buildStyle(\n `button { ${STYLES.join(';')} ${this.getAttribute(\n 'style'\n )} } button:active { transform: translate(1px,1px); }`\n ),\n buildButton(buildSlot('Pay with PonchoPay'))\n )\n );\n }\n\n public set base(value: string) {\n this.setAttribute('base', value);\n }\n\n public get base(): string {\n return this.getAttribute('base') ?? '';\n }\n\n public set token(value: string) {\n this.setAttribute('token', value);\n }\n\n public get token(): string {\n return this.getAttribute('token') ?? '';\n }\n\n public set metadata(value: string) {\n this.setAttribute('metadata', value);\n }\n\n public get metadata(): string {\n return this.getAttribute('metadata') ?? '';\n }\n\n public set urn(value: string) {\n this.setAttribute('urn', value);\n }\n\n public get urn(): string {\n return this.getAttribute('urn') ?? '';\n }\n\n public set amount(value: string | number) {\n this.setAttribute('amount', String(value));\n }\n\n public get amount(): string {\n return this.getAttribute('amount') ?? '';\n }\n\n public set email(value: string) {\n this.setAttribute('email', value);\n }\n\n public get email(): string {\n return this.getAttribute('email') ?? '';\n }\n\n public set note(value: string) {\n this.setAttribute('note', value);\n }\n\n public get note(): string {\n return this.getAttribute('note') ?? '';\n }\n\n public set expiry(value: Date | string) {\n this.setAttribute(\n 'expiry',\n value instanceof Date ? value.toISOString() : value\n );\n }\n\n public get expiry(): string {\n return this.getAttribute('expiry') ?? '';\n }\n\n public attributeChangedCallback(): void {\n this.redrawContents();\n }\n\n public static get observedAttributes() {\n return [...ATTRIBUTES, 'base'];\n }\n}\n"]}
|