Skip to content

Commit

Permalink
Add example for creating an invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
DemianParkhomenko committed May 8, 2024
1 parent 2eecb6a commit bc78d84
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
23 changes: 23 additions & 0 deletions examples/acquiring.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { createClientMonoAcquiring } from '../lib/index.js';

console.log('You can provide X_TOKEN and WEBHOOK_URL as environment variables');

const client = createClientMonoAcquiring({
headers: {
'X-Token': process.env.X_TOKEN,
},
});

const webHookUrl = process.env.WEBHOOK_URL;

{
console.log('Create invoice');
const { data, response } = await client.POST('/api/merchant/invoice/create', {
body: {
amount: 1000,
ccy: 840,
webHookUrl,
},
});
console.log(response.url, response.status, data);
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
},
"scripts": {
"build": "tsc",
"test": "echo \"Error: no test specified\""
"test": "echo \"Error: no test specified\"",
"examples": "npx tsx ./examples/acquiring.ts"
},
"type": "module",
"types": "lib/index.d.ts",
Expand Down

0 comments on commit bc78d84

Please sign in to comment.