@astropay/payments-lib 0.0.9 → 0.0.11

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/main.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { AstroPayPaymentsLib } from './core/astroPayInit';
2
- import { AstroPayPaymentComponent } from './components/pages/AstroPayPaymentComponent';
3
- export default AstroPayPaymentsLib;
4
- export { AstroPayPaymentComponent };
1
+ import { AstroPayCore } from './public/AstroPayCore';
2
+ import { AstroPayFullCheckout } from './public/AstroPayFullCheckout';
3
+ import { AstroPayPayment } from './public/AstroPayPayment';
4
+ export default AstroPayCore;
5
+ export { AstroPayFullCheckout, AstroPayPayment };
@@ -0,0 +1,56 @@
1
+ import { Component } from '../../components/templates/Component';
2
+ import { APCore } from '../../types';
3
+ /**
4
+ * AstroPayCore is the main entry point for the AstroPay Payments Library.
5
+ * It handles initialization, configuration, and lifecycle management of payment components.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * // Basic initialization
10
+ * AstroPayCore.init('app-id');
11
+ *
12
+ * ```
13
+ *
14
+ * @see {@link APCore} for configuration options
15
+ */
16
+ export declare class AstroPayCore {
17
+ private static isInitialized;
18
+ private static token;
19
+ private static components;
20
+ private constructor();
21
+ /**
22
+ * Initializes the AstroPay Payments Library.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * AstroPayCore.init('app-id',
27
+ * {
28
+ * environment: 'production', // or 'sandbox'
29
+ * theme: 'light' // or 'dark'
30
+ * language: 'en' // or 'es'/'pt'
31
+ * currencyMode: 'iso' // or 'symbol'
32
+ * styles: {
33
+ * primaryColor: '#000000',
34
+ * }
35
+ * });
36
+ * ```
37
+ *
38
+ * @param {string} token - The API token required for authentication.
39
+ * @param {APCore} [config] - Optional configuration settings.
40
+ */
41
+ static init(token: string, config?: APCore): void;
42
+ static registerComponent(component: Component): void;
43
+ static unregisterComponent(component: Component): void;
44
+ static getToken(): string;
45
+ /**
46
+ * Destroys the AstroPay Payments Library instance, cleaning up any resources
47
+ * and resetting the initialization state.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * AstroPayCore.destroy();
52
+ * ```
53
+ */
54
+ static destroy(): void;
55
+ static isLibInitialized(): boolean;
56
+ }
@@ -0,0 +1,56 @@
1
+ import { Component } from '../../components/templates/Component';
2
+ import { APFullCheckout } from '../../types';
3
+ /**
4
+ * AstroPayFullCheckout provides a complete payment checkout experience.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const checkout = new AstroPayFullCheckout({
9
+ * amount: 100,
10
+ * currency: 'USD',
11
+ * country: 'BR',
12
+ * // Optional props
13
+ * showTitle: true,
14
+ * showDescription: true,
15
+ * onSuccess: () => console.log('Payment successful'),
16
+ * onError: () => console.error('Payment failed')
17
+ * });
18
+ * ```
19
+ *
20
+ * @see {@link APFullCheckout} for all available configuration options
21
+ */
22
+ export declare class AstroPayFullCheckout extends Component<HTMLDivElement> {
23
+ private loadingWrapper;
24
+ private readonly componentProps;
25
+ constructor(params: APFullCheckout);
26
+ private createPayment;
27
+ private renderPaymentMethods;
28
+ private showSuccessContent;
29
+ /**
30
+ * Renders the full checkout experience into the specified DOM container.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * const checkoutComponent = new AstroPayFullCheckout(checkoutPaymentSettings);
35
+ * checkout.render(document.getElementById('payment-container'));
36
+ * ```
37
+ *
38
+ * @param {HTMLElement} container - The DOM element to render the payment component into.
39
+ */
40
+ render(container: HTMLElement): void;
41
+ /**
42
+ * Destroys the payment component instance, cleaning up all DOM elements
43
+ * and unregistering from the AstroPay Payments Library.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * // Initialize and render component
48
+ * const checkoutComponent = new AstroPayFullCheckout(checkoutPaymentSettings);
49
+ * checkout.render(document.getElementById('payment-container'));
50
+ *
51
+ * // Later cleanup
52
+ * checkoutComponent.destroy();
53
+ * ```
54
+ */
55
+ destroy(): void;
56
+ }
@@ -0,0 +1,55 @@
1
+ import { Component } from '../../components/templates/Component';
2
+ import { APPayment } from '../../types';
3
+ /**
4
+ * AstroPayPayment provides a streamlined payment component focused on AstroPay's
5
+ * native payment method.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const payment = new AstroPayPayment({
10
+ * amount: 100,
11
+ * currency: 'USD',
12
+ * country: 'BR'
13
+ * // Optional props
14
+ * onSuccess: () => console.log('Payment successful'),
15
+ * onError: () => console.error('Payment failed')
16
+ * });
17
+ * ```
18
+ *
19
+ * @see {@link APPayment} for all available configuration options
20
+ */
21
+ export declare class AstroPayPayment extends Component<HTMLDivElement> {
22
+ private loadingWrapper;
23
+ private readonly componentProps;
24
+ constructor(params: APPayment);
25
+ private createPayment;
26
+ private renderAstroPayMethod;
27
+ private showSuccessContent;
28
+ /**
29
+ * Renders the payment component into the specified DOM container.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const paymentComponent = new AstroPayPayment(paymentSettings);
34
+ * paymentComponent.render(document.getElementById('payment-container'));
35
+ * ```
36
+ *
37
+ * @param {HTMLElement} container - The DOM element to render the payment component into.
38
+ */
39
+ render(container: HTMLElement): void;
40
+ /**
41
+ * Destroys the payment component instance, cleaning up all DOM elements
42
+ * and unregistering from the AstroPay Payments Library.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * // Initialize and render component
47
+ * const paymentComponent = new AstroPayPayment(paymentSettings);
48
+ * paymentComponent.render(container);
49
+ *
50
+ * // Later cleanup
51
+ * paymentComponent.destroy();
52
+ * ```
53
+ */
54
+ destroy(): void;
55
+ }
@@ -14,19 +14,30 @@ type APComponentStyles = {
14
14
  textSecondaryColor: string;
15
15
  fontFamily: string;
16
16
  width: string | number;
17
+ paddingWrapper: string | number;
18
+ borderRadiusWrapper: string | number;
17
19
  };
18
- type APLibConfig = {
20
+ type APCore = {
19
21
  environment?: APEnvironment;
20
22
  theme?: APAvailableTheme;
21
23
  language?: APAvailableLanguages;
22
24
  currencyMode?: APAvailableCurrencyMode;
23
25
  styles?: Partial<APComponentStyles>;
24
26
  };
25
- type APPaymentComponent = {
27
+ type APFullCheckout = {
26
28
  amount: number;
27
29
  currency: string;
28
30
  country: string;
29
31
  showTitle?: boolean;
30
32
  showDescription?: boolean;
33
+ onSuccess?: () => void;
34
+ onError?: () => void;
31
35
  };
32
- export type { APLibConfig, APPaymentComponent, APEnvironment, APAvailableTheme, APAvailableLanguages, APAvailableCurrencyMode, APComponentStyles, };
36
+ type APPayment = {
37
+ amount: number;
38
+ currency: string;
39
+ country: string;
40
+ onSuccess?: () => void;
41
+ onError?: () => void;
42
+ };
43
+ export type { APEnvironment, APAvailableTheme, APAvailableLanguages, APAvailableCurrencyMode, APComponentStyles, APCore, APFullCheckout, APPayment, };
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
- "version": "0.0.9",
2
+ "version": "0.0.11",
3
3
  "type": "module",
4
4
  "name": "@astropay/payments-lib",
5
5
  "description": "Official AstroPay payments library for web and mobile.",
6
6
  "license": "UNLICENSED",
7
+ "homepage": "https://www.astropay.com/business",
7
8
  "author": {
8
9
  "name": "AstroPay",
9
10
  "email": "support@astropay.com",
@@ -14,7 +15,7 @@
14
15
  },
15
16
  "repository": {
16
17
  "type": "git",
17
- "url": "https://github.com/astropay-it/astropay-payments-lib.git"
18
+ "url": "https://developers.astropay.com/docs/payments-library"
18
19
  },
19
20
  "contributors": [
20
21
  {
@@ -29,11 +30,10 @@
29
30
  ],
30
31
  "main": "./dist/astropay-payments-lib.es.js",
31
32
  "module": "./dist/astropay-payments-lib.es.js",
32
- "types": "./dist/types/index.d.ts",
33
33
  "exports": {
34
34
  ".": {
35
35
  "import": "./dist/astropay-payments-lib.es.js",
36
- "types": "./dist/types/*"
36
+ "types": "./dist/main.d.ts"
37
37
  },
38
38
  "./types": {
39
39
  "types": "./dist/types/index.d.ts"
@@ -42,7 +42,7 @@
42
42
  "typesVersions": {
43
43
  "*": {
44
44
  "types/*": [
45
- "./dist/types/*"
45
+ "./dist/types/index.d.ts"
46
46
  ]
47
47
  }
48
48
  },