@verapay/verapay-js 0.0.2 → 0.0.3
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 +37 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ A simple, PCI-compliant TypeScript SDK for Stripe payment processing.
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
npm install verapay-js
|
|
18
|
+
npm install @verapay/verapay-js
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
## Quick Start
|
|
@@ -23,7 +23,7 @@ npm install verapay-js
|
|
|
23
23
|
Initialize the SDK with your `merchantId` and the payment details — no backend setup required:
|
|
24
24
|
|
|
25
25
|
```typescript
|
|
26
|
-
import { VerapayClient } from 'verapay-js';
|
|
26
|
+
import { VerapayClient } from '@verapay/verapay-js';
|
|
27
27
|
|
|
28
28
|
const verapay = new VerapayClient({
|
|
29
29
|
merchantId: 'your-merchant-id',
|
|
@@ -44,7 +44,7 @@ const result = await verapay.processPayment({
|
|
|
44
44
|
## Processing Payments
|
|
45
45
|
|
|
46
46
|
```typescript
|
|
47
|
-
import { VerapayClient, ValidationError, PaymentError } from 'verapay-js';
|
|
47
|
+
import { VerapayClient, ValidationError, PaymentError } from '@verapay/verapay-js';
|
|
48
48
|
|
|
49
49
|
const verapay = new VerapayClient({
|
|
50
50
|
merchantId: 'your-merchant-id',
|
|
@@ -100,6 +100,26 @@ await verapay.mountAddress('#billing-address', 'billing');
|
|
|
100
100
|
await verapay.mountAddress('#shipping-address', 'shipping');
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
+
### Styling the Payment Form and Address Element
|
|
104
|
+
|
|
105
|
+
When using `mountPaymentForm` or `mountAddress`, pass an `appearance` object to customise their look. See [Stripe's Appearance API](https://stripe.com/docs/elements/appearance-api) for the full set of options.
|
|
106
|
+
|
|
107
|
+
> **Note:** Styling is split across two APIs due to a Stripe limitation. `mountPaymentForm` and `mountAddress` use newer Stripe elements that support the `appearance` API. `mountCardNumber`, `mountCardExpiry`, and `mountCardCvc` use older Stripe element types that predate `appearance` and only support per-element `style` configuration via `elementsConfig`.
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
const verapay = new VerapayClient({
|
|
111
|
+
merchantId: 'your-merchant-id',
|
|
112
|
+
paymentData: { amount: 5000, currency: 'gbp' },
|
|
113
|
+
appearance: {
|
|
114
|
+
theme: 'stripe',
|
|
115
|
+
variables: {
|
|
116
|
+
colorPrimary: '#6200ee',
|
|
117
|
+
fontFamily: 'Inter, sans-serif',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
103
123
|
### Styling Individual Form Elements
|
|
104
124
|
|
|
105
125
|
> This section applies only when mounting individual form elements (`mountCardNumber`, `mountCardExpiry`, `mountCardCvc`). It does not apply to `mountPaymentForm`.
|
|
@@ -150,16 +170,7 @@ const verapay = new VerapayClient({
|
|
|
150
170
|
|
|
151
171
|
#### Container styling
|
|
152
172
|
|
|
153
|
-
The
|
|
154
|
-
|
|
155
|
-
```css
|
|
156
|
-
.card-field {
|
|
157
|
-
border: 1px solid #e0e0e0;
|
|
158
|
-
border-radius: 4px;
|
|
159
|
-
padding: 12px;
|
|
160
|
-
background: white;
|
|
161
|
-
}
|
|
162
|
-
```
|
|
173
|
+
The SDK mounts Stripe Elements into whichever `div` selectors you provide. Style those containers however you like using your own CSS — there are no SDK-specific class names.
|
|
163
174
|
|
|
164
175
|
#### Locale
|
|
165
176
|
|
|
@@ -202,7 +213,7 @@ import {
|
|
|
202
213
|
ValidationError,
|
|
203
214
|
PaymentError,
|
|
204
215
|
ErrorFormatter,
|
|
205
|
-
} from 'verapay-js';
|
|
216
|
+
} from '@verapay/verapay-js';
|
|
206
217
|
|
|
207
218
|
try {
|
|
208
219
|
await verapay.processPayment(request);
|
|
@@ -230,7 +241,7 @@ import type {
|
|
|
230
241
|
ElementsConfig,
|
|
231
242
|
CardValidation,
|
|
232
243
|
ErrorCode,
|
|
233
|
-
} from 'verapay-js';
|
|
244
|
+
} from '@verapay/verapay-js';
|
|
234
245
|
```
|
|
235
246
|
|
|
236
247
|
## Extension Architecture
|
|
@@ -238,7 +249,7 @@ import type {
|
|
|
238
249
|
Use extensions to hook into the payment lifecycle:
|
|
239
250
|
|
|
240
251
|
```typescript
|
|
241
|
-
import type { PaymentExtension } from 'verapay-js';
|
|
252
|
+
import type { PaymentExtension } from '@verapay/verapay-js';
|
|
242
253
|
|
|
243
254
|
const analyticsExtension: PaymentExtension = {
|
|
244
255
|
name: 'analytics',
|
|
@@ -304,10 +315,10 @@ new VerapayClient(config: VerapayConfig)
|
|
|
304
315
|
|---|---|---|---|
|
|
305
316
|
| `merchantId` | `string` | Yes | Your merchant ID from onboarding |
|
|
306
317
|
| `paymentData` | `PaymentData` | Yes | Amount, currency, and optional partner fee |
|
|
307
|
-
| `appearance` | `Appearance` | No |
|
|
318
|
+
| `appearance` | `Appearance` | No | Styles `mountPaymentForm` and `mountAddress` elements |
|
|
308
319
|
| `locale` | `StripeElementLocale` | No | Locale for Stripe Elements |
|
|
309
320
|
| `fonts` | `StripeElementsOptions['fonts']` | No | Custom fonts for Stripe Elements |
|
|
310
|
-
| `elementsConfig` | `ElementsConfig` | No |
|
|
321
|
+
| `elementsConfig` | `ElementsConfig` | No | Styles `mountCardNumber`, `mountCardExpiry`, and `mountCardCvc` elements |
|
|
311
322
|
|
|
312
323
|
#### PaymentData
|
|
313
324
|
|
|
@@ -331,13 +342,13 @@ new VerapayClient(config: VerapayConfig)
|
|
|
331
342
|
|
|
332
343
|
#### ProcessPaymentRequest
|
|
333
344
|
|
|
334
|
-
| Property | Type | Description |
|
|
335
|
-
|
|
336
|
-
| `
|
|
337
|
-
| `
|
|
338
|
-
| `
|
|
339
|
-
| `customerFirstName` | `string` | Customer first name |
|
|
340
|
-
| `customerLastName` | `string` | Customer last name |
|
|
345
|
+
| Property | Type | Required | Description |
|
|
346
|
+
|---|---|---|---|
|
|
347
|
+
| `customerEmail` | `string` | Yes | Customer email address |
|
|
348
|
+
| `description` | `string` | No | Payment description |
|
|
349
|
+
| `metadata` | `Record<string, string>` | No | Arbitrary key-value metadata |
|
|
350
|
+
| `customerFirstName` | `string` | No | Customer first name |
|
|
351
|
+
| `customerLastName` | `string` | No | Customer last name |
|
|
341
352
|
|
|
342
353
|
#### PaymentResult
|
|
343
354
|
|
|
@@ -356,7 +367,5 @@ This software is proprietary and confidential. Unauthorised copying, distributio
|
|
|
356
367
|
|
|
357
368
|
## Support
|
|
358
369
|
|
|
359
|
-
For issues and questions
|
|
360
|
-
- [GitHub Issues](https://github.com/your-org/verapay-js/issues)
|
|
361
|
-
- [Stripe Documentation](https://stripe.com/docs)
|
|
370
|
+
For issues and questions, contact the Lopay engineering team.
|
|
362
371
|
|