@htmlbricks/hb-payment-paypal 0.71.36 → 0.72.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 +16 -13
- package/manifest.json +2 -4
- package/package.json +1 -1
- package/types/webcomponent.type.d.json +1 -3
- package/types/webcomponent.type.d.ts +6 -6
package/README.md
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
# hb-payment-paypal
|
|
1
|
+
# `hb-payment-paypal` — integrator guide
|
|
2
2
|
|
|
3
3
|
**Category:** commerce · **Tags:** commerce, payment · **Package:** `@htmlbricks/hb-payment-paypal`
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Summary
|
|
6
6
|
|
|
7
7
|
`hb-payment-paypal` loads the official [PayPal JS SDK](https://developer.paypal.com/docs/checkout/) using your **client id** and **currency**, renders **PayPal Buttons** for a **single fixed order total**, and on buyer approval runs **order capture** (`intent: "CAPTURE"`). When capture succeeds, the element dispatches a **`paymentCompleted`** custom event so your host page can continue checkout, clear a cart, or show a receipt.
|
|
8
8
|
|
|
9
9
|
The visible PayPal button chrome is drawn by PayPal inside the mounted region; this web component owns wiring, totals, and the completion event.
|
|
10
10
|
|
|
11
|
-
## Custom element
|
|
11
|
+
## Custom element tag
|
|
12
12
|
|
|
13
|
-
```
|
|
14
|
-
hb-payment-paypal
|
|
13
|
+
```html
|
|
14
|
+
<hb-payment-paypal …></hb-payment-paypal>
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
## Attributes (HTML)
|
|
17
|
+
## Attributes (HTML / reflected props)
|
|
18
18
|
|
|
19
|
-
All
|
|
19
|
+
All names are **snake_case**. Values from HTML are **strings**; **`total`** is coerced with **`Number(...)`** inside the component.
|
|
20
20
|
|
|
21
21
|
| Attribute | Required | Description |
|
|
22
22
|
|-----------|----------|-------------|
|
|
23
|
-
| `paypalid` | Yes | PayPal **client id** (
|
|
24
|
-
| `currency` |
|
|
25
|
-
| `total` |
|
|
26
|
-
| `id` | No | Optional
|
|
27
|
-
|
|
28
|
-
> **Typings note:** `types/webcomponent.type.d.ts` may list an optional `style` field on the logical `Component` shape. The current Svelte implementation does not read `style` from props, so setting a `style` attribute has no defined effect on this build.
|
|
23
|
+
| `paypalid` | Yes | PayPal **client id** (passed to the SDK as **`client-id`**). |
|
|
24
|
+
| `currency` | No | **`EUR`** or **`USD`** (uppercased when set; defaults to **`EUR`**). |
|
|
25
|
+
| `total` | No | Order amount (string or number after coercion; default **`0`** in the implementation). |
|
|
26
|
+
| `id` | No | Optional host id. |
|
|
27
|
+
| `style` | No | Optional on **`Component`**; normal host **`style`** still applies in the light DOM. |
|
|
29
28
|
|
|
30
29
|
## Behavior
|
|
31
30
|
|
|
@@ -70,6 +69,10 @@ See [Bulma CSS variables](https://bulma.io/documentation/features/css-variables/
|
|
|
70
69
|
|------|--------|
|
|
71
70
|
| `btn` | Host wrapper around the PayPal Buttons mount (`#paypalbtn`). Use `::part(btn)` for **layout and spacing** around the SDK; do not expect to theme PayPal’s internal button art. |
|
|
72
71
|
|
|
72
|
+
## TypeScript typings (authoring)
|
|
73
|
+
|
|
74
|
+
From `types/webcomponent.type.d.ts`: **`Component`** (`paypalid`, optional **`currency`**, **`total`**, **`id`**, **`style`**) and **`Events`** (`paymentCompleted`).
|
|
75
|
+
|
|
73
76
|
## Integration notes
|
|
74
77
|
|
|
75
78
|
- **Content Security Policy:** Allow PayPal’s script and frame origins required by the JS SDK and Smart Payment Buttons, or the load/render step will fail.
|
package/manifest.json
CHANGED
|
@@ -60,9 +60,7 @@
|
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
"required": [
|
|
63
|
-
"paypalid"
|
|
64
|
-
"currency",
|
|
65
|
-
"total"
|
|
63
|
+
"paypalid"
|
|
66
64
|
],
|
|
67
65
|
"type": "object"
|
|
68
66
|
}
|
|
@@ -186,5 +184,5 @@
|
|
|
186
184
|
"size": {},
|
|
187
185
|
"iifePath": "main.iife.js",
|
|
188
186
|
"repoName": "@htmlbricks/hb-payment-paypal",
|
|
189
|
-
"version": "0.
|
|
187
|
+
"version": "0.72.0"
|
|
190
188
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htmlbricks/hb-payment-paypal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.72.0",
|
|
4
4
|
"contributors": [],
|
|
5
5
|
"description": "Loads the PayPal JS SDK with your client id and currency, renders PayPal Buttons for a fixed order total, captures payment on approval, and dispatches paymentCompleted when the order is captured successfully.",
|
|
6
6
|
"licenses": [
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export type Component = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
id?: string;
|
|
3
|
+
style?: string;
|
|
4
|
+
paypalid: string;
|
|
5
|
+
currency?: "EUR" | "USD";
|
|
6
|
+
total?: number;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export type Events = {
|
|
10
|
-
|
|
10
|
+
paymentCompleted: { method: "paypal"; total: number };
|
|
11
11
|
};
|