@100pay-hq/100pay.js 1.4.6 → 1.4.7

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.
Files changed (2) hide show
  1. package/README.MD +130 -1
  2. package/package.json +1 -1
package/README.MD CHANGED
@@ -2,6 +2,37 @@
2
2
 
3
3
  A TypeScript library for integrating with the 100Pay payment platform, enabling developers to easily accept cryptocurrency payments, manage transactions, and perform bank transfers.
4
4
 
5
+ ## Table of Contents
6
+
7
+ - [Features](#features)
8
+ - [Installation](#installation)
9
+ - [Quick Start](#quick-start)
10
+ - [API Reference](#api-reference)
11
+ - [Initialization](#initialization)
12
+ - [Transaction Verification](#transaction-verification)
13
+ - [Subaccounts](#subaccounts)
14
+ - [Currency Conversion](#currency-conversion)
15
+ - [Asset Transfers](#asset-transfers)
16
+ - [Wallet Operations](#wallet-operations)
17
+ - [Bank Transfers](#bank-transfers)
18
+ - [OAuth 2.0 Authorization](#oauth-20-authorization)
19
+ - [Generic API Requests](#generic-api-requests)
20
+ - [Error Handling](#error-handling)
21
+ - [Security and Authentication](#security-and-authentication)
22
+ - [TypeScript Support](#typescript-support)
23
+ - [Common Use Cases](#common-use-cases)
24
+ - [Accepting Cryptocurrency Payments](#accepting-cryptocurrency-payments)
25
+ - [Creating Subaccounts for Partners or Marketplaces](#creating-subaccounts-for-partners-or-marketplaces)
26
+ - [Currency Conversion Preview](#currency-conversion-preview)
27
+ - [Bank Transfer Workflow](#bank-transfer-workflow)
28
+ - [OAuth 2.0 Workflow](#oauth-20-workflow)
29
+ - [Webhook Handling](#webhook-handling)
30
+ - [Resources](#resources)
31
+ - [Development](#development)
32
+ - [Building from Source](#building-from-source)
33
+ - [Available Scripts](#available-scripts)
34
+ - [License](#license)
35
+
5
36
  ## Features
6
37
 
7
38
  - ✅ Verify cryptocurrency payments
@@ -10,6 +41,7 @@ A TypeScript library for integrating with the 100Pay payment platform, enabling
10
41
  - ✅ Transfer assets between wallets
11
42
  - ✅ Get supported wallets
12
43
  - ✅ Bank transfers with account verification
44
+ - ✅ OAuth 2.0 for secure authorization
13
45
  - ✅ Make authenticated API requests
14
46
  - ✅ Full TypeScript support with comprehensive typing
15
47
  - ✅ Secure server-to-server communication with request signing
@@ -463,6 +495,39 @@ const transfer = await client.bankTransfer.transfer({
463
495
  });
464
496
  ```
465
497
 
498
+ ### OAuth 2.0 Authorization
499
+
500
+ #### Get Authorization URL
501
+
502
+ ```typescript
503
+ const authUrl = client.oauth.getAuthorizationUrl({
504
+ redirectUri: "https://yourapp.com/callback",
505
+ scope: "read_user_info read_app_info",
506
+ state: "some_random_state"
507
+ });
508
+ ```
509
+
510
+ #### Get Access Token
511
+
512
+ ```typescript
513
+ const tokenData = await client.oauth.getAccessToken({
514
+ code: "authorization_code",
515
+ redirectUri: "https://yourapp.com/callback"
516
+ });
517
+ ```
518
+
519
+ #### Get User Info
520
+
521
+ ```typescript
522
+ const userInfo = await client.oauth.getUserInfo(tokenData.access_token);
523
+ ```
524
+
525
+ #### Get App Info
526
+
527
+ ```typescript
528
+ const appInfo = await client.oauth.getAppInfo(tokenData.access_token);
529
+ ```
530
+
466
531
  **Parameters:**
467
532
 
468
533
  ```typescript
@@ -498,6 +563,31 @@ interface IBankTransferResponse {
498
563
  }
499
564
  ```
500
565
 
566
+ ### OAuth 2.0
567
+
568
+ The SDK provides methods for OAuth 2.0 authorization:
569
+
570
+ ```typescript
571
+ // Get authorization URL
572
+ const authUrl = client.oauth.getAuthorizationUrl({
573
+ redirectUri: "https://yourapp.com/callback",
574
+ scope: "read_user_info read_app_info",
575
+ state: "some_random_state"
576
+ });
577
+
578
+ // Get access token
579
+ const tokenData = await client.oauth.getAccessToken({
580
+ code: "authorization_code",
581
+ redirectUri: "https://yourapp.com/callback"
582
+ });
583
+
584
+ // Get user info
585
+ const userInfo = await client.oauth.getUserInfo(tokenData.access_token);
586
+
587
+ // Get app info
588
+ const appInfo = await client.oauth.getAppInfo(tokenData.access_token);
589
+ ```
590
+
501
591
  ### Generic API Requests
502
592
 
503
593
  The SDK provides a generic `request` method for making any API call to the 100Pay API:
@@ -566,7 +656,11 @@ import {
566
656
  IBankTransferData,
567
657
  IBankTransferResponse,
568
658
  IVerifyBankData,
569
- IVerifyBankResponse
659
+ IVerifyBankResponse,
660
+ IOAuthApp,
661
+ ITokenData,
662
+ IUserInfo,
663
+ IAppInfo
570
664
  } from '@100pay-hq/100pay.js';
571
665
  ```
572
666
 
@@ -669,6 +763,41 @@ async function performBankTransfer() {
669
763
  }
670
764
  ```
671
765
 
766
+ ### OAuth 2.0 Workflow
767
+
768
+ ```typescript
769
+ // Complete OAuth 2.0 workflow
770
+ async function performOAuth() {
771
+ try {
772
+ // 1. Get authorization URL
773
+ const authUrl = client.oauth.getAuthorizationUrl({
774
+ redirectUri: "https://yourapp.com/callback",
775
+ scope: "read_user_info read_app_info",
776
+ state: "some_random_state"
777
+ });
778
+ console.log(`Authorization URL: ${authUrl}`);
779
+
780
+ // 2. Get access token
781
+ const tokenData = await client.oauth.getAccessToken({
782
+ code: "authorization_code",
783
+ redirectUri: "https://yourapp.com/callback"
784
+ });
785
+
786
+ // 3. Get user info
787
+ const userInfo = await client.oauth.getUserInfo(tokenData.access_token);
788
+ console.log(`User info: ${userInfo}`);
789
+
790
+ // 4. Get app info
791
+ const appInfo = await client.oauth.getAppInfo(tokenData.access_token);
792
+ console.log(`App info: ${appInfo}`);
793
+
794
+ } catch (error) {
795
+ console.error(`OAuth workflow failed: ${error.message}`);
796
+ throw error;
797
+ }
798
+ }
799
+ ```
800
+
672
801
  ## Webhook Handling
673
802
 
674
803
  100Pay sends webhooks for various events. Here's an example bank transfer debit webhook payload:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@100pay-hq/100pay.js",
3
- "version": "1.4.6",
3
+ "version": "1.4.7",
4
4
  "description": "100Pay.js is the official Nodejs API wrapper SDK that lets you easily verify crypto payments, run bulk payout, transfer assets and many more.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",