placetopay-cli 0.3.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 +24 -0
- package/bin/run.js +21 -0
- package/install.js +126 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# PlacetoPay CLI
|
|
2
|
+
|
|
3
|
+
Command-line tool for the PlacetoPay payment gateway. Create checkout sessions, query transactions, manage webhooks, and more.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g placetopay-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
placetopay login
|
|
15
|
+
placetopay samples create
|
|
16
|
+
cd checkout-basic && npm start
|
|
17
|
+
placetopay listen --forward-to http://localhost:3000/webhook
|
|
18
|
+
placetopay test-flow
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Documentation
|
|
22
|
+
|
|
23
|
+
- [Landing page](https://step-labs-2026.github.io/placetopay-cli/)
|
|
24
|
+
- [GitHub](https://github.com/step-labs-2026/placetopay-cli)
|
package/bin/run.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { execFileSync } = require("child_process");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
|
|
8
|
+
const ext = process.platform === "win32" ? ".exe" : "";
|
|
9
|
+
const binaryPath = path.join(__dirname, `placetopay${ext}`);
|
|
10
|
+
|
|
11
|
+
if (!fs.existsSync(binaryPath)) {
|
|
12
|
+
console.error("PlacetoPay CLI binary not found. Try reinstalling:");
|
|
13
|
+
console.error(" npm install -g placetopay-cli");
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
execFileSync(binaryPath, process.argv.slice(2), { stdio: "inherit" });
|
|
19
|
+
} catch (err) {
|
|
20
|
+
process.exit(err.status || 1);
|
|
21
|
+
}
|
package/install.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const https = require("https");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const { execSync } = require("child_process");
|
|
8
|
+
|
|
9
|
+
const VERSION = require("./package.json").version;
|
|
10
|
+
const REPO = "step-labs-2026/placetopay-cli";
|
|
11
|
+
|
|
12
|
+
const PLATFORM_MAP = {
|
|
13
|
+
darwin: "darwin",
|
|
14
|
+
linux: "linux",
|
|
15
|
+
win32: "windows",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const ARCH_MAP = {
|
|
19
|
+
x64: "amd64",
|
|
20
|
+
arm64: "arm64",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function getBinaryName() {
|
|
24
|
+
const platform = PLATFORM_MAP[process.platform];
|
|
25
|
+
const arch = ARCH_MAP[process.arch];
|
|
26
|
+
|
|
27
|
+
if (!platform || !arch) {
|
|
28
|
+
console.error(
|
|
29
|
+
`Unsupported platform: ${process.platform}-${process.arch}`
|
|
30
|
+
);
|
|
31
|
+
console.error("Supported: darwin-x64, darwin-arm64, linux-x64, linux-arm64, win32-x64");
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const ext = platform === "windows" ? ".exe" : "";
|
|
36
|
+
return `placetopay-${platform}-${arch}${ext}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function getDownloadUrl() {
|
|
40
|
+
const binaryName = getBinaryName();
|
|
41
|
+
return `https://github.com/${REPO}/releases/download/v${VERSION}/${binaryName}`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function download(url, dest) {
|
|
45
|
+
return new Promise((resolve, reject) => {
|
|
46
|
+
const follow = (url, redirects = 0) => {
|
|
47
|
+
if (redirects > 5) return reject(new Error("Too many redirects"));
|
|
48
|
+
|
|
49
|
+
https
|
|
50
|
+
.get(url, { headers: { "User-Agent": "placetopay-cli-npm" } }, (res) => {
|
|
51
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
52
|
+
return follow(res.headers.location, redirects + 1);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (res.statusCode !== 200) {
|
|
56
|
+
return reject(
|
|
57
|
+
new Error(`Download failed: HTTP ${res.statusCode} from ${url}`)
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const file = fs.createWriteStream(dest);
|
|
62
|
+
res.pipe(file);
|
|
63
|
+
file.on("finish", () => {
|
|
64
|
+
file.close();
|
|
65
|
+
resolve();
|
|
66
|
+
});
|
|
67
|
+
file.on("error", reject);
|
|
68
|
+
})
|
|
69
|
+
.on("error", reject);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
follow(url);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function main() {
|
|
77
|
+
const binDir = path.join(__dirname, "bin");
|
|
78
|
+
const ext = process.platform === "win32" ? ".exe" : "";
|
|
79
|
+
const binaryPath = path.join(binDir, `placetopay${ext}`);
|
|
80
|
+
|
|
81
|
+
// Skip if binary already exists (e.g., CI caching)
|
|
82
|
+
if (fs.existsSync(binaryPath)) {
|
|
83
|
+
console.log("placetopay binary already exists, skipping download.");
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const url = getDownloadUrl();
|
|
88
|
+
console.log(`Downloading PlacetoPay CLI v${VERSION}...`);
|
|
89
|
+
console.log(` ${url}`);
|
|
90
|
+
|
|
91
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
await download(url, binaryPath);
|
|
95
|
+
} catch (err) {
|
|
96
|
+
console.error(`\nFailed to download PlacetoPay CLI: ${err.message}`);
|
|
97
|
+
console.error(
|
|
98
|
+
"\nYou can download it manually from:"
|
|
99
|
+
);
|
|
100
|
+
console.error(
|
|
101
|
+
` https://github.com/${REPO}/releases/tag/v${VERSION}`
|
|
102
|
+
);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Make executable on Unix
|
|
107
|
+
if (process.platform !== "win32") {
|
|
108
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Verify it works
|
|
112
|
+
try {
|
|
113
|
+
const output = execSync(`"${binaryPath}" version`, {
|
|
114
|
+
encoding: "utf8",
|
|
115
|
+
timeout: 5000,
|
|
116
|
+
});
|
|
117
|
+
console.log(` Installed: ${output.trim()}`);
|
|
118
|
+
} catch {
|
|
119
|
+
console.log(" Installed successfully (could not verify version).");
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
main().catch((err) => {
|
|
124
|
+
console.error("Installation failed:", err.message);
|
|
125
|
+
process.exit(1);
|
|
126
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "placetopay-cli",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "PlacetoPay CLI — manage payments from the command line",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"placetopay",
|
|
7
|
+
"payments",
|
|
8
|
+
"checkout",
|
|
9
|
+
"cli",
|
|
10
|
+
"gateway",
|
|
11
|
+
"webhooks"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/step-labs-2026/placetopay-cli",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/step-labs-2026/placetopay-cli.git"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"bin": {
|
|
20
|
+
"placetopay": "./bin/run.js"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"postinstall": "node install.js"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=16"
|
|
27
|
+
},
|
|
28
|
+
"os": [
|
|
29
|
+
"darwin",
|
|
30
|
+
"linux",
|
|
31
|
+
"win32"
|
|
32
|
+
],
|
|
33
|
+
"cpu": [
|
|
34
|
+
"x64",
|
|
35
|
+
"arm64"
|
|
36
|
+
]
|
|
37
|
+
}
|