@payriff-sdk/react 1.0.2 → 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/dist/PayriffProvider.d.ts +6 -4
- package/dist/PayriffProvider.js +2 -2
- package/dist/index.d.ts +1 -1
- package/package.json +14 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
import type { PayriffApiBase, PayriffError, PayriffEvents, PayriffField, PayriffInstance, PayriffLocale, PayriffOptions, PayriffOrder, PayriffResult, PayriffTheme } from '@payriff-sdk/payriff-js';
|
|
2
|
+
import type { PayriffApiBase, PayriffError, PayriffEvents, PayriffField, PayriffInstance, PayriffLocale, PayriffOptions, PayriffOrder, PayriffRegion, PayriffResult, PayriffTheme } from '@payriff-sdk/payriff-js';
|
|
3
3
|
export interface PayOptions {
|
|
4
4
|
/** Cardholder name collected in your own input, when the form has no holder field. */
|
|
5
5
|
holderValue?: string;
|
|
@@ -11,9 +11,11 @@ export type PayriffReactError = PayriffError & {
|
|
|
11
11
|
export interface PayriffProviderProps {
|
|
12
12
|
/** Your publishable key (pr_pk_live_…). Never the secret key. */
|
|
13
13
|
publishableKey: string;
|
|
14
|
-
/** Default
|
|
14
|
+
/** Where your merchant account is. Default `AZ`; Saudi merchants pass `KSA`. */
|
|
15
|
+
region?: PayriffRegion;
|
|
16
|
+
/** @deprecated Use `region`. If passed, it must be the API host of `region`. */
|
|
15
17
|
apiBase?: PayriffApiBase;
|
|
16
|
-
/** Default `az`. */
|
|
18
|
+
/** Default `az` for region `AZ`, `ar` for `KSA`. `ar` is right-to-left. */
|
|
17
19
|
locale?: PayriffLocale;
|
|
18
20
|
/** Text styling inside the card fields. With `<CardForm>`, prefer its `appearance`. */
|
|
19
21
|
theme?: PayriffTheme;
|
|
@@ -55,7 +57,7 @@ export interface FormLink {
|
|
|
55
57
|
}
|
|
56
58
|
export declare function toReactError(err: unknown): PayriffReactError;
|
|
57
59
|
/** Loads Payriff.js once for everything inside it, and shares the payment state with usePayriff(). */
|
|
58
|
-
export declare function PayriffProvider({ publishableKey, apiBase, locale, theme, autoAdvance, children }: PayriffProviderProps): import("react").JSX.Element;
|
|
60
|
+
export declare function PayriffProvider({ publishableKey, region, apiBase, locale, theme, autoAdvance, children }: PayriffProviderProps): import("react").JSX.Element;
|
|
59
61
|
/** Payment state and actions for the card form inside the nearest <PayriffProvider>. */
|
|
60
62
|
export declare function usePayriff(): UsePayriff;
|
|
61
63
|
/** @internal Used by <CardForm> and <CardFields>. */
|
package/dist/PayriffProvider.js
CHANGED
|
@@ -24,7 +24,7 @@ export function toReactError(err) {
|
|
|
24
24
|
return { ...err, message };
|
|
25
25
|
}
|
|
26
26
|
/** Loads Payriff.js once for everything inside it, and shares the payment state with usePayriff(). */
|
|
27
|
-
export function PayriffProvider({ publishableKey, apiBase, locale, theme, autoAdvance, children }) {
|
|
27
|
+
export function PayriffProvider({ publishableKey, region, apiBase, locale, theme, autoAdvance, children }) {
|
|
28
28
|
const [payriff, setPayriff] = useState(null);
|
|
29
29
|
const [order, setOrder] = useState(null);
|
|
30
30
|
const [complete, setComplete] = useState(false);
|
|
@@ -34,7 +34,7 @@ export function PayriffProvider({ publishableKey, apiBase, locale, theme, autoAd
|
|
|
34
34
|
const current = useRef(null);
|
|
35
35
|
// Compare the theme by value, so an inline object doesn't remount the form on every render.
|
|
36
36
|
const themeKey = theme ? JSON.stringify(theme) : '';
|
|
37
|
-
const options = useMemo(() => ({ apiBase, locale, autoAdvance, theme: themeKey ? JSON.parse(themeKey) : undefined }), [apiBase, locale, autoAdvance, themeKey]);
|
|
37
|
+
const options = useMemo(() => ({ region, apiBase, locale, autoAdvance, theme: themeKey ? JSON.parse(themeKey) : undefined }), [region, apiBase, locale, autoAdvance, themeKey]);
|
|
38
38
|
const link = useMemo(() => ({
|
|
39
39
|
options,
|
|
40
40
|
publishableKey,
|
package/dist/index.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ export type { CardFieldsProps, CardFieldProps } from './CardFields.js';
|
|
|
7
7
|
export { usePaymentResult } from './usePaymentResult.js';
|
|
8
8
|
export type { UsePaymentResult } from './usePaymentResult.js';
|
|
9
9
|
export type { FormCallbacks } from './useMountedForm.js';
|
|
10
|
-
export type { PayriffAppearance, PayriffCardLayout, PayriffError, PayriffField, PayriffLocale, PayriffOrder, PayriffResult, PayriffTheme, } from '@payriff-sdk/payriff-js';
|
|
10
|
+
export type { PayriffAppearance, PayriffCardLayout, PayriffError, PayriffField, PayriffLocale, PayriffOrder, PayriffRegion, PayriffResult, PayriffTheme, } from '@payriff-sdk/payriff-js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payriff-sdk/react",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "React components for Payriff.js card payments",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|
|
@@ -13,16 +13,26 @@
|
|
|
13
13
|
"default": "./dist/index.js"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
|
-
"files": [
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
17
21
|
"sideEffects": false,
|
|
18
|
-
"keywords": [
|
|
22
|
+
"keywords": [
|
|
23
|
+
"payriff",
|
|
24
|
+
"payments",
|
|
25
|
+
"card",
|
|
26
|
+
"3ds",
|
|
27
|
+
"react"
|
|
28
|
+
],
|
|
19
29
|
"scripts": {
|
|
20
30
|
"build": "rm -rf dist && tsc -p tsconfig.json",
|
|
21
31
|
"test": "npm run build && node --test test/*.test.js",
|
|
22
32
|
"prepublishOnly": "npm test"
|
|
23
33
|
},
|
|
24
34
|
"dependencies": {
|
|
25
|
-
"@payriff-sdk/payriff-js": "^1.
|
|
35
|
+
"@payriff-sdk/payriff-js": "^1.3.0"
|
|
26
36
|
},
|
|
27
37
|
"peerDependencies": {
|
|
28
38
|
"react": ">=18"
|