@astropay/payments-lib 0.0.6 โ 0.0.7
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 +56 -19
- package/dist/astropay-payments-lib.es.js +8219 -1132
- package/package.json +10 -4
package/README.md
CHANGED
|
@@ -1,19 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="http://www.astropay.com">
|
|
2
3
|
|
|
3
4
|

|
|
5
|
+
</a>
|
|
6
|
+
</div>
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
AstroPay's official frontend library that allows you to easily embed customizable and secure payment components into your website or e-commerce platform. It supports seamless international transactions, theming, localization, and real-time payment processing โ all with minimal setup.
|
|
9
|
+
|
|
10
|
+
<div align="center">
|
|
11
|
+
|
|
12
|
+
[](https://www.npmjs.com/package/@astropay/payments-lib)
|
|
13
|
+
[](https://www.npmjs.com/package/@astropay/payments-lib)
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
## ๐ Quick Links
|
|
17
|
+
|
|
18
|
+
- ๐งช [Live Demo](https://demo.astropay.com)
|
|
19
|
+
- ๐ [Full Documentation](https://developers.astropay.com/docs/payments-library)
|
|
6
20
|
|
|
7
21
|
## ๐ Table of Contents
|
|
8
22
|
|
|
9
|
-
- [
|
|
10
|
-
- [
|
|
11
|
-
- [
|
|
12
|
-
- [
|
|
13
|
-
- [
|
|
23
|
+
- [๐ Quick Links](#-quick-links)
|
|
24
|
+
- [๐ Table of Contents](#-table-of-contents)
|
|
25
|
+
- [๐ฆ Installation](#-installation)
|
|
26
|
+
- [Prerequisites](#prerequisites)
|
|
27
|
+
- [Dependencies](#dependencies)
|
|
28
|
+
- [DOM Requirements](#dom-requirements)
|
|
29
|
+
- [NPM](#npm)
|
|
30
|
+
- [Yarn](#yarn)
|
|
31
|
+
- [๐ Basic Usage](#-basic-usage)
|
|
32
|
+
- [๐งฉ Components](#-components)
|
|
33
|
+
- [AstroPayPaymentComponent](#astropaypaymentcomponent)
|
|
34
|
+
- [Props](#props)
|
|
35
|
+
- [Example](#example)
|
|
36
|
+
- [๐จ Styling \& Theming](#-styling--theming)
|
|
14
37
|
- [Available Themes](#available-themes)
|
|
15
38
|
- [Custom Styling](#custom-styling)
|
|
16
|
-
- [
|
|
39
|
+
- [Available Style Properties](#available-style-properties)
|
|
40
|
+
- [๐ Internationalization](#-internationalization)
|
|
41
|
+
- [Available Languages](#available-languages)
|
|
17
42
|
|
|
18
43
|
## ๐ฆ Installation
|
|
19
44
|
|
|
@@ -42,13 +67,13 @@ The library will render the payment interface inside this container element.
|
|
|
42
67
|
### NPM
|
|
43
68
|
|
|
44
69
|
```bash
|
|
45
|
-
npm install astropay
|
|
70
|
+
npm install @astropay/payments-lib
|
|
46
71
|
```
|
|
47
72
|
|
|
48
73
|
### Yarn
|
|
49
74
|
|
|
50
75
|
```bash
|
|
51
|
-
yarn add astropay
|
|
76
|
+
yarn add @astropay/payments-lib
|
|
52
77
|
```
|
|
53
78
|
|
|
54
79
|
## ๐ Basic Usage
|
|
@@ -56,10 +81,11 @@ yarn add astropay-payments-lib
|
|
|
56
81
|
Initialize the library with your API token and optional configuration:
|
|
57
82
|
|
|
58
83
|
```typescript
|
|
59
|
-
import
|
|
84
|
+
import AstroPayPaymentsLib, { AstroPayPaymentComponent } from '@astropay/payments-lib';
|
|
60
85
|
|
|
61
86
|
// Initialize the library
|
|
62
|
-
|
|
87
|
+
AstroPayPaymentsLib.init('app-id', {
|
|
88
|
+
environment: 'production', // or 'sandbox'
|
|
63
89
|
theme: 'light', // or 'dark'
|
|
64
90
|
language: 'en', // or 'es', 'pt'
|
|
65
91
|
currencyMode: 'iso', // or 'symbol'
|
|
@@ -68,9 +94,10 @@ AstropayPaymentsLib.init('your-api-token', {
|
|
|
68
94
|
// Use the payment component in your application
|
|
69
95
|
// Note: Make sure an HTML element with id="payment-container" exists in your DOM before running this code
|
|
70
96
|
const paymentElement = document.getElementById('payment-container');
|
|
71
|
-
const payment = new
|
|
97
|
+
const payment = new AstroPayPaymentComponent({
|
|
72
98
|
amount: 100,
|
|
73
99
|
currency: 'USD',
|
|
100
|
+
country: 'BR',
|
|
74
101
|
});
|
|
75
102
|
|
|
76
103
|
paymentElement.appendChild(payment.element);
|
|
@@ -78,7 +105,7 @@ paymentElement.appendChild(payment.element);
|
|
|
78
105
|
|
|
79
106
|
## ๐งฉ Components
|
|
80
107
|
|
|
81
|
-
###
|
|
108
|
+
### AstroPayPaymentComponent
|
|
82
109
|
|
|
83
110
|
The main component for rendering a payment interface.
|
|
84
111
|
|
|
@@ -88,15 +115,22 @@ The main component for rendering a payment interface.
|
|
|
88
115
|
|------|------|----------|-------------|
|
|
89
116
|
| amount | number | Yes | The payment amount |
|
|
90
117
|
| currency | string | Yes | The currency code (e.g., 'USD') |
|
|
118
|
+
| country | string | Yes | The country code (e.g., 'BR', 'US') |
|
|
119
|
+
| showTitle | boolean | No | Whether to show the component title (defaults to `true`) |
|
|
120
|
+
| showDescription | boolean | No | Whether to show the payment description (defaults to `true`) |
|
|
91
121
|
|
|
92
122
|
#### Example
|
|
93
123
|
|
|
94
124
|
```typescript
|
|
95
|
-
import {
|
|
125
|
+
import { AstroPayPaymentComponent } from '@astropay/payments-lib';
|
|
96
126
|
|
|
97
|
-
const paymentComponent = new
|
|
127
|
+
const paymentComponent = new AstroPayPaymentComponent({
|
|
98
128
|
amount: 100,
|
|
99
129
|
currency: 'USD',
|
|
130
|
+
country: 'US',
|
|
131
|
+
// Optional props
|
|
132
|
+
showTitle: true,
|
|
133
|
+
showDescription: true,
|
|
100
134
|
});
|
|
101
135
|
|
|
102
136
|
// Note: Make sure an HTML element with id="payment-container" exists in your DOM before running this code
|
|
@@ -117,8 +151,11 @@ The library comes with two built-in themes:
|
|
|
117
151
|
You can specify the theme during initialization:
|
|
118
152
|
|
|
119
153
|
```typescript
|
|
120
|
-
|
|
154
|
+
AstroPayPaymentsLib.init('app-id', {
|
|
121
155
|
theme: 'dark',
|
|
156
|
+
environment: 'production', // or 'sandbox'
|
|
157
|
+
language: 'en',
|
|
158
|
+
currencyMode: 'iso', // or 'symbol'
|
|
122
159
|
});
|
|
123
160
|
```
|
|
124
161
|
|
|
@@ -127,7 +164,7 @@ AstropayPaymentsLib.init('your-api-token', {
|
|
|
127
164
|
You can customize the styling by providing a `styles` object in the initialization configuration:
|
|
128
165
|
|
|
129
166
|
```typescript
|
|
130
|
-
|
|
167
|
+
AstroPayPaymentsLib.init('app-id', {
|
|
131
168
|
styles: {
|
|
132
169
|
primaryColor: '#FF5500',
|
|
133
170
|
secondaryColor: '#00AAFF',
|
|
@@ -165,7 +202,7 @@ The library supports multiple languages through the i18next internationalization
|
|
|
165
202
|
You can specify the language during initialization:
|
|
166
203
|
|
|
167
204
|
```typescript
|
|
168
|
-
|
|
205
|
+
AstroPayPaymentsLib.init('app-id', {
|
|
169
206
|
language: 'es',
|
|
170
207
|
});
|
|
171
208
|
```
|