@paykit-sdk/gopay 1.1.1 → 1.1.2

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/schema.d.mts CHANGED
@@ -1,17 +1,3 @@
1
- interface GoPayTokenResponse {
2
- /**
3
- * The type of the token
4
- */
5
- token_type: 'bearer';
6
- /**
7
- * The access token
8
- */
9
- access_token: string;
10
- /**
11
- * The expiry time of the token
12
- */
13
- expires_in: number;
14
- }
15
1
  interface GoPayPaymentBaseResponse {
16
2
  /**
17
3
  * The ID of the payment
@@ -310,4 +296,4 @@ interface GoPayPaymentRequest {
310
296
  preauthorization?: boolean;
311
297
  }
312
298
 
313
- export type { GoPayPaymentBaseResponse, GoPayPaymentItem, GoPayPaymentRequest, GoPaySubscriptionResponse, GoPayTokenResponse };
299
+ export type { GoPayPaymentBaseResponse, GoPayPaymentItem, GoPayPaymentRequest, GoPaySubscriptionResponse };
package/dist/schema.d.ts CHANGED
@@ -1,17 +1,3 @@
1
- interface GoPayTokenResponse {
2
- /**
3
- * The type of the token
4
- */
5
- token_type: 'bearer';
6
- /**
7
- * The access token
8
- */
9
- access_token: string;
10
- /**
11
- * The expiry time of the token
12
- */
13
- expires_in: number;
14
- }
15
1
  interface GoPayPaymentBaseResponse {
16
2
  /**
17
3
  * The ID of the payment
@@ -310,4 +296,4 @@ interface GoPayPaymentRequest {
310
296
  preauthorization?: boolean;
311
297
  }
312
298
 
313
- export type { GoPayPaymentBaseResponse, GoPayPaymentItem, GoPayPaymentRequest, GoPaySubscriptionResponse, GoPayTokenResponse };
299
+ export type { GoPayPaymentBaseResponse, GoPayPaymentItem, GoPayPaymentRequest, GoPaySubscriptionResponse };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paykit-sdk/gopay",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "GoPay provider for PayKit",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -15,6 +15,9 @@
15
15
  "files": [
16
16
  "dist"
17
17
  ],
18
+ "scripts": {
19
+ "build": "tsup"
20
+ },
18
21
  "keywords": [
19
22
  "paykit",
20
23
  "gopay"
@@ -25,10 +28,10 @@
25
28
  "@paykit-sdk/core": ">=1.1.102"
26
29
  },
27
30
  "devDependencies": {
31
+ "@paykit-sdk/core": "workspace:*",
28
32
  "tsup": "^8.5.0",
29
33
  "typescript": "^5.9.2",
30
- "zod": "^3.24.2",
31
- "@paykit-sdk/core": "1.1.102"
34
+ "zod": "^3.24.2"
32
35
  },
33
36
  "publishConfig": {
34
37
  "access": "public"
@@ -39,8 +42,5 @@
39
42
  },
40
43
  "bugs": {
41
44
  "url": "https://github.com/usepaykit/paykit-sdk/issues"
42
- },
43
- "scripts": {
44
- "build": "tsup"
45
45
  }
46
- }
46
+ }
@@ -1,19 +0,0 @@
1
- import { GoPayOptions } from '../gopay-provider.mjs';
2
- import '@paykit-sdk/core';
3
-
4
- declare class AuthController {
5
- private opts;
6
- private _client;
7
- private _accessToken;
8
- constructor(opts: GoPayOptions & {
9
- baseUrl: string;
10
- });
11
- getAccessToken: () => Promise<string>;
12
- getAuthHeaders: () => Promise<{
13
- Authorization: string;
14
- 'Content-Type': string;
15
- Accept: string;
16
- }>;
17
- }
18
-
19
- export { AuthController };
@@ -1,19 +0,0 @@
1
- import { GoPayOptions } from '../gopay-provider.js';
2
- import '@paykit-sdk/core';
3
-
4
- declare class AuthController {
5
- private opts;
6
- private _client;
7
- private _accessToken;
8
- constructor(opts: GoPayOptions & {
9
- baseUrl: string;
10
- });
11
- getAccessToken: () => Promise<string>;
12
- getAuthHeaders: () => Promise<{
13
- Authorization: string;
14
- 'Content-Type': string;
15
- Accept: string;
16
- }>;
17
- }
18
-
19
- export { AuthController };
@@ -1,61 +0,0 @@
1
- 'use strict';
2
-
3
- var core = require('@paykit-sdk/core');
4
-
5
- // src/controllers/auth.ts
6
- var AuthController = class {
7
- constructor(opts) {
8
- this.opts = opts;
9
- const debug = opts.debug ?? true;
10
- this._client = new core.HTTPClient({
11
- baseUrl: this.opts.baseUrl,
12
- headers: {},
13
- retryOptions: { max: 3, baseDelay: 1e3, debug }
14
- });
15
- }
16
- _client;
17
- _accessToken = null;
18
- getAccessToken = async () => {
19
- if (this._accessToken) {
20
- const [token, , expiryStr] = this._accessToken.split("::paykit::");
21
- const expiry = parseInt(expiryStr || "0", 10);
22
- if (expiry > Date.now()) return token;
23
- }
24
- const credentials = Buffer.from(
25
- `${this.opts.clientId}:${this.opts.clientSecret}`
26
- ).toString("base64");
27
- const body = new URLSearchParams({
28
- grant_type: "client_credentials",
29
- scope: "payment-all"
30
- }).toString();
31
- const response = await this._client.post("/oauth2/token", {
32
- headers: {
33
- Authorization: `Basic ${credentials}`,
34
- "Content-Type": "application/x-www-form-urlencoded",
35
- Accept: "application/json"
36
- },
37
- body
38
- });
39
- if (!response.ok || !response.value?.access_token) {
40
- throw new core.OperationFailedError("getAccessToken", "gopay", {
41
- cause: new Error(
42
- `Failed to obtain GoPay access token: ${JSON.stringify(response.value || response.error)}`
43
- )
44
- });
45
- }
46
- const expiryTime = Date.now() + (response.value.expires_in - 300) * 1e3;
47
- const accessToken = `${response.value.access_token}::paykit::${expiryTime}`;
48
- this._accessToken = accessToken;
49
- return response.value.access_token;
50
- };
51
- getAuthHeaders = async () => {
52
- const token = await this.getAccessToken();
53
- return {
54
- Authorization: `Bearer ${token}`,
55
- "Content-Type": "application/json",
56
- Accept: "application/json"
57
- };
58
- };
59
- };
60
-
61
- exports.AuthController = AuthController;
@@ -1,59 +0,0 @@
1
- import { HTTPClient, OperationFailedError } from '@paykit-sdk/core';
2
-
3
- // src/controllers/auth.ts
4
- var AuthController = class {
5
- constructor(opts) {
6
- this.opts = opts;
7
- const debug = opts.debug ?? true;
8
- this._client = new HTTPClient({
9
- baseUrl: this.opts.baseUrl,
10
- headers: {},
11
- retryOptions: { max: 3, baseDelay: 1e3, debug }
12
- });
13
- }
14
- _client;
15
- _accessToken = null;
16
- getAccessToken = async () => {
17
- if (this._accessToken) {
18
- const [token, , expiryStr] = this._accessToken.split("::paykit::");
19
- const expiry = parseInt(expiryStr || "0", 10);
20
- if (expiry > Date.now()) return token;
21
- }
22
- const credentials = Buffer.from(
23
- `${this.opts.clientId}:${this.opts.clientSecret}`
24
- ).toString("base64");
25
- const body = new URLSearchParams({
26
- grant_type: "client_credentials",
27
- scope: "payment-all"
28
- }).toString();
29
- const response = await this._client.post("/oauth2/token", {
30
- headers: {
31
- Authorization: `Basic ${credentials}`,
32
- "Content-Type": "application/x-www-form-urlencoded",
33
- Accept: "application/json"
34
- },
35
- body
36
- });
37
- if (!response.ok || !response.value?.access_token) {
38
- throw new OperationFailedError("getAccessToken", "gopay", {
39
- cause: new Error(
40
- `Failed to obtain GoPay access token: ${JSON.stringify(response.value || response.error)}`
41
- )
42
- });
43
- }
44
- const expiryTime = Date.now() + (response.value.expires_in - 300) * 1e3;
45
- const accessToken = `${response.value.access_token}::paykit::${expiryTime}`;
46
- this._accessToken = accessToken;
47
- return response.value.access_token;
48
- };
49
- getAuthHeaders = async () => {
50
- const token = await this.getAccessToken();
51
- return {
52
- Authorization: `Bearer ${token}`,
53
- "Content-Type": "application/json",
54
- Accept: "application/json"
55
- };
56
- };
57
- };
58
-
59
- export { AuthController };