robuxpay 1.0.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/README.md ADDED
@@ -0,0 +1,146 @@
1
+ # RobuxPAY SDK
2
+
3
+ Official Node.js SDK for RobuxPAY - Accept Robux payments in your applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install robuxpay
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```javascript
14
+ import RobuxPAY from 'robuxpay';
15
+
16
+ // Initialize client
17
+ const robuxpay = new RobuxPAY({
18
+ apiKey: 'rpay_your_api_key_here'
19
+ });
20
+
21
+ // List products
22
+ const products = await robuxpay.products.list();
23
+ console.log(products);
24
+
25
+ // Create a payment
26
+ const payment = await robuxpay.payments.create({
27
+ productId: 'prod_123',
28
+ userId: '568128963'
29
+ });
30
+
31
+ console.log('Payment URL:', payment.paymentUrl);
32
+
33
+ // Verify a payment
34
+ const verified = await robuxpay.payments.verify('pay_abc123');
35
+ console.log('Payment status:', verified.status);
36
+ ```
37
+
38
+ ## API Reference
39
+
40
+ ### Initialize Client
41
+
42
+ ```javascript
43
+ const robuxpay = new RobuxPAY({
44
+ apiKey: 'rpay_xxx', // Required: Your API key
45
+ baseUrl: 'https://...' // Optional: Custom API URL
46
+ });
47
+ ```
48
+
49
+ ### Products
50
+
51
+ #### List all products
52
+ ```javascript
53
+ const products = await robuxpay.products.list();
54
+ ```
55
+
56
+ #### Get a specific product
57
+ ```javascript
58
+ const product = await robuxpay.products.get('prod_123');
59
+ ```
60
+
61
+ ### Payments
62
+
63
+ #### Create a payment
64
+ ```javascript
65
+ const payment = await robuxpay.payments.create({
66
+ productId: 'prod_123',
67
+ userId: '568128963',
68
+ metadata: { orderId: '12345' } // Optional
69
+ });
70
+ ```
71
+
72
+ #### Verify a payment
73
+ ```javascript
74
+ const payment = await robuxpay.payments.verify('pay_abc123');
75
+ ```
76
+
77
+ #### List all payments
78
+ ```javascript
79
+ const payments = await robuxpay.payments.list();
80
+ ```
81
+
82
+ ### Webhooks
83
+
84
+ Verify webhook signatures to ensure requests are from RobuxPAY:
85
+
86
+ ```javascript
87
+ import express from 'express';
88
+
89
+ app.post('/webhook', express.raw({ type: 'application/json' }), (req, res) => {
90
+ const signature = req.headers['x-robuxpay-signature'];
91
+ const payload = req.body.toString();
92
+
93
+ const isValid = robuxpay.verifyWebhook(
94
+ payload,
95
+ signature,
96
+ 'your_webhook_secret'
97
+ );
98
+
99
+ if (!isValid) {
100
+ return res.status(401).send('Invalid signature');
101
+ }
102
+
103
+ const event = JSON.parse(payload);
104
+
105
+ if (event.type === 'payment.completed') {
106
+ console.log('Payment completed:', event.data);
107
+ // Handle successful payment
108
+ }
109
+
110
+ res.send('OK');
111
+ });
112
+ ```
113
+
114
+ ## TypeScript Support
115
+
116
+ This SDK is written in TypeScript and includes type definitions:
117
+
118
+ ```typescript
119
+ import RobuxPAY, { Product, Payment } from 'robuxpay';
120
+
121
+ const robuxpay = new RobuxPAY({ apiKey: 'rpay_xxx' });
122
+
123
+ const products: Product[] = await robuxpay.products.list();
124
+ const payment: Payment = await robuxpay.payments.verify('pay_123');
125
+ ```
126
+
127
+ ## Error Handling
128
+
129
+ ```javascript
130
+ try {
131
+ const payment = await robuxpay.payments.create({
132
+ productId: 'prod_123',
133
+ userId: '568128963'
134
+ });
135
+ } catch (error) {
136
+ if (error.response) {
137
+ console.error('API Error:', error.response.data);
138
+ } else {
139
+ console.error('Network Error:', error.message);
140
+ }
141
+ }
142
+ ```
143
+
144
+ ## License
145
+
146
+ MIT
@@ -0,0 +1,44 @@
1
+ import { RobuxPAYConfig, Product, Payment, CreatePaymentParams } from './types';
2
+ export declare class RobuxPAY {
3
+ private client;
4
+ private apiKey;
5
+ constructor(config: RobuxPAYConfig);
6
+ /**
7
+ * Products API
8
+ */
9
+ products: {
10
+ /**
11
+ * List all products
12
+ */
13
+ list: () => Promise<Product[]>;
14
+ /**
15
+ * Get a specific product
16
+ */
17
+ get: (productId: string) => Promise<Product>;
18
+ };
19
+ /**
20
+ * Payments API
21
+ */
22
+ payments: {
23
+ /**
24
+ * Create a new payment
25
+ */
26
+ create: (params: CreatePaymentParams) => Promise<{
27
+ paymentUrl: string;
28
+ payment: Payment;
29
+ }>;
30
+ /**
31
+ * Verify a payment
32
+ */
33
+ verify: (paymentId: string) => Promise<Payment>;
34
+ /**
35
+ * List all payments
36
+ */
37
+ list: () => Promise<Payment[]>;
38
+ };
39
+ /**
40
+ * Verify webhook signature
41
+ */
42
+ verifyWebhook(payload: string, signature: string, secret: string): boolean;
43
+ }
44
+ export default RobuxPAY;
package/dist/client.js ADDED
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RobuxPAY = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ class RobuxPAY {
9
+ constructor(config) {
10
+ /**
11
+ * Products API
12
+ */
13
+ this.products = {
14
+ /**
15
+ * List all products
16
+ */
17
+ list: async () => {
18
+ const response = await this.client.get('/products');
19
+ return response.data.products;
20
+ },
21
+ /**
22
+ * Get a specific product
23
+ */
24
+ get: async (productId) => {
25
+ const response = await this.client.get(`/products/${productId}`);
26
+ return response.data;
27
+ },
28
+ };
29
+ /**
30
+ * Payments API
31
+ */
32
+ this.payments = {
33
+ /**
34
+ * Create a new payment
35
+ */
36
+ create: async (params) => {
37
+ const response = await this.client.post('/payments', params);
38
+ return response.data;
39
+ },
40
+ /**
41
+ * Verify a payment
42
+ */
43
+ verify: async (paymentId) => {
44
+ const response = await this.client.get(`/payments/${paymentId}`);
45
+ return response.data;
46
+ },
47
+ /**
48
+ * List all payments
49
+ */
50
+ list: async () => {
51
+ const response = await this.client.get('/payments');
52
+ return response.data.payments;
53
+ },
54
+ };
55
+ this.apiKey = config.apiKey;
56
+ this.client = axios_1.default.create({
57
+ baseURL: config.baseUrl || 'https://robuxpay.vercel.app/api',
58
+ headers: {
59
+ 'Authorization': `Bearer ${this.apiKey}`,
60
+ 'Content-Type': 'application/json',
61
+ },
62
+ });
63
+ }
64
+ /**
65
+ * Verify webhook signature
66
+ */
67
+ verifyWebhook(payload, signature, secret) {
68
+ const crypto = require('crypto');
69
+ const hmac = crypto.createHmac('sha256', secret);
70
+ const digest = hmac.update(payload).digest('hex');
71
+ return digest === signature;
72
+ }
73
+ }
74
+ exports.RobuxPAY = RobuxPAY;
75
+ exports.default = RobuxPAY;
@@ -0,0 +1,3 @@
1
+ export { RobuxPAY as default } from './client';
2
+ export * from './types';
3
+ export { RobuxPAY } from './client';
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.RobuxPAY = exports.default = void 0;
18
+ var client_1 = require("./client");
19
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return client_1.RobuxPAY; } });
20
+ __exportStar(require("./types"), exports);
21
+ var client_2 = require("./client");
22
+ Object.defineProperty(exports, "RobuxPAY", { enumerable: true, get: function () { return client_2.RobuxPAY; } });
@@ -0,0 +1,33 @@
1
+ export interface RobuxPAYConfig {
2
+ apiKey: string;
3
+ baseUrl?: string;
4
+ }
5
+ export interface Product {
6
+ id: string;
7
+ name: string;
8
+ description?: string;
9
+ price: number;
10
+ gamepassId: string;
11
+ createdAt: string;
12
+ updatedAt: string;
13
+ }
14
+ export interface Payment {
15
+ id: string;
16
+ productId: string;
17
+ userId: string;
18
+ amount: number;
19
+ status: 'pending' | 'completed' | 'failed';
20
+ gamepassId: string;
21
+ createdAt: string;
22
+ completedAt?: string;
23
+ }
24
+ export interface CreatePaymentParams {
25
+ productId: string;
26
+ userId: string;
27
+ metadata?: Record<string, any>;
28
+ }
29
+ export interface WebhookEvent {
30
+ type: 'payment.completed' | 'payment.failed';
31
+ data: Payment;
32
+ timestamp: string;
33
+ }
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "robuxpay",
3
+ "version": "1.0.0",
4
+ "description": "Official RobuxPAY SDK for Node.js - Accept Robux payments in your applications",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "prepublishOnly": "npm run build",
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ },
12
+ "keywords": [
13
+ "robux",
14
+ "roblox",
15
+ "payment",
16
+ "gamepass",
17
+ "robuxpay"
18
+ ],
19
+ "author": "RobuxPAY",
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/beratkan15/robuxpay"
24
+ },
25
+ "dependencies": {
26
+ "axios": "^1.6.0"
27
+ },
28
+ "devDependencies": {
29
+ "@types/node": "^20.0.0",
30
+ "typescript": "^5.0.0"
31
+ },
32
+ "files": [
33
+ "dist",
34
+ "README.md"
35
+ ]
36
+ }