@bloque/payments 0.0.1

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.
@@ -0,0 +1,173 @@
1
+ import type { Currency, Metadata } from './common';
2
+ import type { Customer } from './customer';
3
+ export interface CreateCheckoutPayload {
4
+ name: string;
5
+ description?: string;
6
+ image_url?: string;
7
+ asset: 'dUSD/6';
8
+ payment_type: 'shopping_cart';
9
+ items: {
10
+ name: string;
11
+ price: string;
12
+ units: number;
13
+ image_url?: string;
14
+ }[];
15
+ redirect_url: string;
16
+ expires_at?: string;
17
+ metadata?: Metadata;
18
+ }
19
+ export interface CreateCheckoutResponse {
20
+ payment: {
21
+ urn: string;
22
+ url: string;
23
+ price: number;
24
+ image_url?: string | null;
25
+ metadata?: Metadata;
26
+ created_at: string;
27
+ updated_at: string;
28
+ expires_at: string;
29
+ summary: {
30
+ status: CheckoutStatus;
31
+ };
32
+ };
33
+ }
34
+ /**
35
+ * Represents a single item included in a checkout.
36
+ */
37
+ export interface CheckoutItem {
38
+ /**
39
+ * Name of the product or service.
40
+ */
41
+ name: string;
42
+ /**
43
+ * Optional description of the item.
44
+ */
45
+ description?: string;
46
+ /**
47
+ * Unit price of the item, expressed in the checkout currency.
48
+ * Usually represented in the smallest currency unit (e.g. cents).
49
+ */
50
+ amount: number;
51
+ /**
52
+ * Number of units for this item.
53
+ */
54
+ quantity: number;
55
+ /**
56
+ * URL of an image representing the item.
57
+ */
58
+ image_url?: string;
59
+ }
60
+ /**
61
+ * Parameters used to create a checkout.
62
+ */
63
+ export interface CheckoutParams {
64
+ /**
65
+ * Name of the checkout session.
66
+ */
67
+ name: string;
68
+ /**
69
+ * Optional description of the checkout.
70
+ */
71
+ description?: string;
72
+ /**
73
+ * URL of an image representing the checkout.
74
+ */
75
+ image_url?: string;
76
+ /**
77
+ * List of items to be charged.
78
+ * Must contain at least one item.
79
+ */
80
+ items: CheckoutItem[];
81
+ /**
82
+ * Currency used for the checkout.
83
+ *
84
+ * @default 'USD'
85
+ */
86
+ currency?: Currency;
87
+ /**
88
+ * URL the customer will be redirected to after a successful payment.
89
+ */
90
+ success_url: string;
91
+ /**
92
+ * URL the customer will be redirected to if the payment is canceled.
93
+ */
94
+ cancel_url: string;
95
+ /**
96
+ * Arbitrary metadata attached to the checkout.
97
+ * Useful for internal references or business logic.
98
+ */
99
+ metadata?: Metadata;
100
+ /**
101
+ * Checkout expiration date and time in ISO 8601 format.
102
+ * If not provided, the checkout may not expire automatically.
103
+ */
104
+ expires_at?: string;
105
+ /**
106
+ * Payment methods enabled for this checkout.
107
+ *
108
+ * @default ['card', 'pse', 'cash']
109
+ */
110
+ payment_methods?: ('card' | 'pse' | 'cash')[];
111
+ }
112
+ /**
113
+ * Possible states of a checkout.
114
+ */
115
+ export type CheckoutStatus = 'pending' | 'completed' | 'expired' | 'canceled';
116
+ /**
117
+ * Represents a checkout object returned by the API.
118
+ */
119
+ export interface Checkout {
120
+ /**
121
+ * Unique identifier of the checkout.
122
+ */
123
+ id: string;
124
+ /**
125
+ * Object type discriminator.
126
+ */
127
+ object: 'checkout';
128
+ /**
129
+ * Public URL where the customer can complete the payment.
130
+ */
131
+ url: string;
132
+ /**
133
+ * Current status of the checkout.
134
+ */
135
+ status: CheckoutStatus;
136
+ /**
137
+ * Total amount to be paid, including taxes, discounts,
138
+ * or additional charges.
139
+ */
140
+ amount_total: number;
141
+ /**
142
+ * Subtotal amount before additional charges.
143
+ */
144
+ amount_subtotal: number;
145
+ /**
146
+ * Currency used for the checkout.
147
+ */
148
+ currency: Currency;
149
+ /**
150
+ * Customer associated with the checkout, if any.
151
+ */
152
+ customer?: Customer;
153
+ /**
154
+ * Items included in the checkout.
155
+ */
156
+ items: CheckoutItem[];
157
+ /**
158
+ * Metadata attached to the checkout.
159
+ */
160
+ metadata?: Metadata;
161
+ /**
162
+ * Checkout creation timestamp in ISO 8601 format.
163
+ */
164
+ created_at: string;
165
+ /**
166
+ * Last update timestamp in ISO 8601 format.
167
+ */
168
+ updated_at: string;
169
+ /**
170
+ * Checkout expiration timestamp in ISO 8601 format.
171
+ */
172
+ expires_at: string;
173
+ }
@@ -0,0 +1,12 @@
1
+ export type Currency = 'COP' | 'USD';
2
+ export interface Metadata {
3
+ [key: string]: string | number | boolean;
4
+ }
5
+ export interface Address {
6
+ line1: string;
7
+ line2?: string;
8
+ city: string;
9
+ state?: string;
10
+ postal_code?: string;
11
+ country: string;
12
+ }
@@ -0,0 +1,12 @@
1
+ import type { Address, Metadata } from './common';
2
+ export interface Customer {
3
+ id?: string;
4
+ object?: 'customer';
5
+ email: string;
6
+ name: string;
7
+ phone?: string;
8
+ address?: Address;
9
+ metadata?: Metadata;
10
+ created_at?: string;
11
+ updated_at?: string;
12
+ }
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@bloque/payments",
3
+ "version": "0.0.1",
4
+ "description": "Official Bloque SDK for creating and managing payments and checkouts.",
5
+ "type": "module",
6
+ "keywords": [
7
+ "bloque",
8
+ "payments",
9
+ "sdk",
10
+ "api"
11
+ ],
12
+ "author": "Nestor Cortina <nexckycort@gmail.com>",
13
+ "license": "MIT",
14
+ "publishConfig": {
15
+ "access": "public",
16
+ "provenance": true
17
+ },
18
+ "homepage": "git+https://github.com/bloque-app/payments.git#readme",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/bloque-app/payments.git",
22
+ "directory": "packages/payments"
23
+ },
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "import": "./dist/index.js",
28
+ "require": "./dist/index.cjs"
29
+ }
30
+ },
31
+ "main": "./dist/index.cjs",
32
+ "types": "./dist/index.d.ts",
33
+ "files": [
34
+ "dist"
35
+ ],
36
+ "engines": {
37
+ "node": ">=22"
38
+ },
39
+ "scripts": {
40
+ "build": "rslib build",
41
+ "dev": "rslib build --watch",
42
+ "clean": "rm -rf node_modules && rm -rf dist",
43
+ "check": "biome check --write",
44
+ "typecheck": "tsgo --noEmit"
45
+ },
46
+ "dependencies": {
47
+ "@bloque/payments-core": "workspace:*"
48
+ },
49
+ "devDependencies": {
50
+ "@rslib/core": "catalog:",
51
+ "@types/node": "catalog:",
52
+ "@typescript/native-preview": "catalog:",
53
+ "typescript": "catalog:"
54
+ }
55
+ }