@astropay/payments-lib 0.0.6

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 ADDED
@@ -0,0 +1,171 @@
1
+ # AstroPay Payments Library
2
+
3
+ ![AstroPay](https://getapp.astropay.com/img/astropay/2023/logo-black.svg)
4
+
5
+ A TypeScript component library for integrating AstroPay payment processing capabilities into web applications. This library provides pre-built, customizable payment interface components that developers can easily incorporate into their websites or applications.
6
+
7
+ ## 📋 Table of Contents
8
+
9
+ - [Installation](#installation)
10
+ - [Basic Usage](#basic-usage)
11
+ - [Components](#components)
12
+ - [AstropayPaymentComponent](#astropaypaymentcomponent)
13
+ - [Styling & Theming](#styling--theming)
14
+ - [Available Themes](#available-themes)
15
+ - [Custom Styling](#custom-styling)
16
+ - [Internationalization](#internationalization)
17
+
18
+ ## 📦 Installation
19
+
20
+ ### Prerequisites
21
+
22
+ #### Dependencies
23
+
24
+ This library requires the following peer dependencies:
25
+
26
+ - @emotion/css: ^11.13.5
27
+ - axios: ^1.7.9
28
+ - bowser: ^2.11.0
29
+ - i18next: ^24.2.2
30
+ - qrcode: ^1.5.4
31
+
32
+ #### DOM Requirements
33
+
34
+ Before using the AstroPay Payment components, ensure your HTML document includes container elements where the components will be rendered. For example, to use the basic payment component, you need to have an element with `id="payment-container"` in your DOM:
35
+
36
+ ```html
37
+ <div id="payment-container"></div>
38
+ ```
39
+
40
+ The library will render the payment interface inside this container element.
41
+
42
+ ### NPM
43
+
44
+ ```bash
45
+ npm install astropay-payments-lib
46
+ ```
47
+
48
+ ### Yarn
49
+
50
+ ```bash
51
+ yarn add astropay-payments-lib
52
+ ```
53
+
54
+ ## 🚀 Basic Usage
55
+
56
+ Initialize the library with your API token and optional configuration:
57
+
58
+ ```typescript
59
+ import AstropayPaymentsLib, { AstropayPaymentComponent } from 'astropay-payments-lib';
60
+
61
+ // Initialize the library
62
+ AstropayPaymentsLib.init('your-api-token', {
63
+ theme: 'light', // or 'dark'
64
+ language: 'en', // or 'es', 'pt'
65
+ currencyMode: 'iso', // or 'symbol'
66
+ });
67
+
68
+ // Use the payment component in your application
69
+ // Note: Make sure an HTML element with id="payment-container" exists in your DOM before running this code
70
+ const paymentElement = document.getElementById('payment-container');
71
+ const payment = new AstropayPaymentComponent({
72
+ amount: 100,
73
+ currency: 'USD',
74
+ });
75
+
76
+ paymentElement.appendChild(payment.element);
77
+ ```
78
+
79
+ ## 🧩 Components
80
+
81
+ ### AstropayPaymentComponent
82
+
83
+ The main component for rendering a payment interface.
84
+
85
+ #### Props
86
+
87
+ | Prop | Type | Required | Description |
88
+ |------|------|----------|-------------|
89
+ | amount | number | Yes | The payment amount |
90
+ | currency | string | Yes | The currency code (e.g., 'USD') |
91
+
92
+ #### Example
93
+
94
+ ```typescript
95
+ import { AstropayPaymentComponent } from 'astropay-payments-lib';
96
+
97
+ const paymentComponent = new AstropayPaymentComponent({
98
+ amount: 100,
99
+ currency: 'USD',
100
+ });
101
+
102
+ // Note: Make sure an HTML element with id="payment-container" exists in your DOM before running this code
103
+ document.getElementById('payment-container').appendChild(paymentComponent.element);
104
+ ```
105
+
106
+ ## 🎨 Styling & Theming
107
+
108
+ The library supports customizable theming through the initialization configuration.
109
+
110
+ ### Available Themes
111
+
112
+ The library comes with two built-in themes:
113
+
114
+ - `light` (default)
115
+ - `dark`
116
+
117
+ You can specify the theme during initialization:
118
+
119
+ ```typescript
120
+ AstropayPaymentsLib.init('your-api-token', {
121
+ theme: 'dark',
122
+ });
123
+ ```
124
+
125
+ ### Custom Styling
126
+
127
+ You can customize the styling by providing a `styles` object in the initialization configuration:
128
+
129
+ ```typescript
130
+ AstropayPaymentsLib.init('your-api-token', {
131
+ styles: {
132
+ primaryColor: '#FF5500',
133
+ secondaryColor: '#00AAFF',
134
+ backgroundColor: '#FFFFFF',
135
+ textPrimaryColor: '#333333',
136
+ textSecondaryColor: '#666666',
137
+ fontFamily: 'Arial, sans-serif',
138
+ width: 500,
139
+ },
140
+ });
141
+ ```
142
+
143
+ #### Available Style Properties
144
+
145
+ | Property | Type | Description |
146
+ |----------|------|-------------|
147
+ | primaryColor | string | Primary brand color |
148
+ | secondaryColor | string | Secondary brand color |
149
+ | backgroundColor | string | Background color |
150
+ | textPrimaryColor | string | Primary text color |
151
+ | textSecondaryColor | string | Secondary text color |
152
+ | fontFamily | string | Font family |
153
+ | width | number | Component width in pixels |
154
+
155
+ ## 🌐 Internationalization
156
+
157
+ The library supports multiple languages through the i18next internationalization framework.
158
+
159
+ ### Available Languages
160
+
161
+ - English (`en`) - Default
162
+ - Spanish (`es`)
163
+ - Portuguese (`pt`)
164
+
165
+ You can specify the language during initialization:
166
+
167
+ ```typescript
168
+ AstropayPaymentsLib.init('your-api-token', {
169
+ language: 'es',
170
+ });
171
+ ```