Skip to content

Commit 290531e

Browse files
authored
Merge pull request #13 from marcinx/master
* update README
2 parents b30788c + c3d85b9 commit 290531e

File tree

1 file changed

+135
-167
lines changed

1 file changed

+135
-167
lines changed

README.md

Lines changed: 135 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -35,231 +35,199 @@ Get your API key and secret here: https://www.coinqvest.com/en/api-settings
3535
Creates a customer object, which can be associated with checkouts, payments, and invoices. Checkouts associated with a customer generate more transaction details, help with your accounting, and can automatically create invoices for your customer and yourself.
3636

3737
```javascript
38-
client.post('/customer',
39-
{
40-
customer:{
41-
email: 'john@doe.com',
42-
firstname: 'John',
43-
lastname: 'Doe',
44-
company: 'ACME Inc.',
45-
adr1: '810 Beach St',
46-
adr2: 'Finance Department',
47-
zip: 'CA 94133',
48-
city: 'San Francisco',
49-
countrycode: 'US'
50-
}
51-
},
52-
function (response) {
38+
let response = await client.post('/customer', {
39+
customer:{
40+
email: 'john@doe.com',
41+
firstname: 'John',
42+
lastname: 'Doe',
43+
company: 'ACME Inc.',
44+
adr1: '810 Beach St',
45+
adr2: 'Finance Department',
46+
zip: 'CA 94133',
47+
city: 'San Francisco',
48+
countrycode: 'US'
49+
}
50+
});
5351

54-
console.log(response.status);
55-
console.log(response.data);
52+
console.log(response.status);
53+
console.log(response.data);
5654

57-
if (response.status !== 200) {
58-
// something went wrong, let's abort and debug by looking at our log file
59-
console.log('Could not create customer. Inspect above log entry.');
60-
return;
61-
}
55+
if (response.status !== 200) {
56+
// something went wrong, let's abort and debug by looking at our log file
57+
console.log('Could not create customer. Inspect above log entry.');
58+
return;
59+
}
6260

63-
let customerId = response.data['customerId']; // store this persistently in your database
64-
}
65-
);
61+
let customerId = response.data['customerId']; // store this persistently in your database
6662
```
6763

6864
**Create a Hosted Checkout** (https://www.coinqvest.com/en/api-docs#post-checkout-hosted)
6965

70-
Hosted checkouts are the simplest form of getting paid using the COINQVEST platform.
66+
Hosted checkouts are the simplest form of getting paid using the COINQVEST platform.
7167

72-
Using this endpoint, your server submits a set of parameters, such as the payment details including optional tax items, customer information, and settlement currency. Your server then receives a checkout URL in return, which is displayed back to your customer.
68+
Using this endpoint, your server submits a set of parameters, such as the payment details including optional tax items, customer information, and settlement currency. Your server then receives a checkout URL in return, which is displayed back to your customer.
7369

7470
Upon visiting the URL, your customer is presented with a checkout page hosted on COINQVEST servers. This page displays all the information the customer needs to complete payment.
7571

7672
```javascript
77-
client.post('/checkout/hosted',
78-
{
79-
charge:{
80-
customerId: customerId, // associates this charge with a customer as crated by POST /customer
81-
billingCurrency: 'USD', // a billing currency as given by GET /currencies
82-
lineItems: [{ // a list of line items included in this charge
83-
description: 'T-Shirt',
84-
netAmount: 10,
85-
quantity: 1
86-
}],
87-
discountItems: [{ // an optional list of discounts
88-
description: 'Loyalty Discount',
89-
netAmount: 0.5
90-
}],
91-
shippingCostItems: [{ // an optional list of shipping and handling costs
92-
description: 'Shipping and Handling',
93-
netAmount: 3.99,
94-
taxable: false // sometimes shipping costs are taxable
95-
}],
96-
taxItems: [{
97-
name: 'CA Sales Tax',
98-
percent: 0.0825 // 8.25% CA sales tax
99-
}]
100-
},
101-
settlementAsset: 'USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN' // your settlement asset as given by GET /assets (or ORIGIN to omit conversion)
73+
let response = await client.post('/checkout/hosted', {
74+
charge:{
75+
customerId: customerId, // associates this charge with a customer
76+
currency: 'USD', // specifies the billing currency
77+
lineItems: [{ // a list of line items included in this charge
78+
description: 'T-Shirt',
79+
netAmount: 10,
80+
quantity: 1
81+
}],
82+
discountItems: [{ // an optional list of discounts
83+
description: 'Loyalty Discount',
84+
netAmount: 0.5
85+
}],
86+
shippingCostItems: [{ // an optional list of shipping and handling costs
87+
description: 'Shipping and Handling',
88+
netAmount: 3.99,
89+
taxable: false // sometimes shipping costs are taxable
90+
}],
91+
taxItems: [{
92+
name: 'CA Sales Tax',
93+
percent: 0.0825 // 8.25% CA sales tax
94+
}]
10295
},
103-
function (response) {
104-
105-
console.log(response.status);
106-
console.log(response.data);
96+
settlementCurrency: 'EUR' // specifies in which currency you want to settle
97+
});
10798

108-
if (response.status !== 200) {
109-
// something went wrong, let's abort and debug by looking at our log file
110-
console.log('Could not create checkout.');
111-
return;
112-
}
99+
console.log(response.status);
100+
console.log(response.data);
113101

114-
// the checkout was created
115-
// response.data now contains an object as specified in the success response here: https://www.coinqvest.com/en/api-docs#post-checkout
116-
let checkoutId = response.data['checkoutId']; // store this persistently in your database
117-
let url = response.data['url']; // redirect your customer to this URL to complete the payment
102+
if (response.status !== 200) {
103+
// something went wrong, let's abort and debug by looking at our log file
104+
console.log('Could not create checkout.');
105+
return;
106+
}
118107

119-
}
120-
);
108+
// the checkout was created
109+
// response.data now contains an object as specified in the success response here: https://www.coinqvest.com/en/api-docs#post-checkout
110+
let checkoutId = response.data['checkoutId']; // store this persistently in your database
111+
let url = response.data['url']; // redirect your customer to this URL to complete the payment
121112
```
122113

123114
**Monitor Payment State** (https://www.coinqvest.com/en/api-docs#get-checkout)
124115

125116
Once the payment is captured we notify you via email, [webhook](https://www.coinqvest.com/en/api-docs#webhook-concepts). You can also poll [GET /checkout](https://www.coinqvest.com/en/api-docs#get-checkout) for payment status updates:
126117

127118
```javascript
128-
client.get('/checkout',
129-
{id: checkoutId},
130-
function(response) {
131-
console.log(response.status);
132-
console.log(response.data);
133-
134-
if (response.status === 200) {
135-
let state = response.data['checkout']['state'];
136-
if (state === 'COMPLETED') {
137-
console.log("The payment has completed and your account was credited. You can now ship the goods.");
138-
} else {
139-
// try again in 30 seconds or so...
140-
}
141-
}
119+
let response = await client.get('/checkout', {id: checkoutId});
120+
121+
console.log(response.status);
122+
console.log(response.data);
123+
124+
if (response.status === 200) {
125+
let state = response.data['checkout']['state'];
126+
if (['COMPLETED'].includes(state)) {
127+
console.log("The payment has completed and your account was credited. You can now ship the goods.");
128+
} else {
129+
// try again in 30 seconds or so...
142130
}
143-
);
131+
}
144132
```
145133

146134
**Query your USD Wallet** (https://www.coinqvest.com/en/api-docs#get-wallet)
147135
```javascript
148-
client.get('/wallet',
149-
{assetCode: 'USD'},
150-
function(response) {
151-
console.log(response.status);
152-
console.log(response.data);
153-
}
154-
);
136+
let response = await client.get('/wallet', {assetCode: 'USD'});
137+
138+
console.log(response.status);
139+
console.log(response.data);
155140
```
156141

157142
**Query all Wallets** (https://www.coinqvest.com/en/api-docs#get-wallets)
158143
```javascript
159-
client.get('/wallets',
160-
null,
161-
function(response) {
162-
console.log(response.status);
163-
console.log(response.data);
144+
let response = await client.get('/wallets');
145+
146+
console.log(response.status);
147+
console.log(response.data);
148+
```
149+
150+
**Withdraw to your NGN Bank Account** (https://www.coinqvest.com/en/api-docs#post-withdrawal)
151+
```javascript
152+
let response = await client.post('/withdrawal', {
153+
sourceAsset: 'USD:GDUKMGUGDZQK6YHYA5Z6AY2G4XDSZPSZ3SW5UN3ARVMO6QSRDWP5YLEX', // withdraw from your USD wallet
154+
sourceAmount: 100,
155+
targetNetwork: 'NGN', // send to an NGN bank account
156+
targetAccount: {
157+
nuban: '3080494548',
158+
bankName: 'FirstBank'
164159
}
165-
);
160+
});
161+
162+
console.log(response.status);
163+
console.log(response.data);
166164
```
167165

168-
**Withdraw USDC to your Bitcoin Account** (https://www.coinqvest.com/en/api-docs#post-withdrawal)
166+
**Withdraw to your Bitcoin Account** (https://www.coinqvest.com/en/api-docs#post-withdrawal)
169167
```javascript
170-
client.post('/withdrawal',
171-
{
172-
sourceAsset: 'USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN', // withdraw from your USDC wallet
173-
sourceAmount: 100,
174-
targetNetwork: 'BITCOIN', // a target network as given by GET /networks
175-
targetAccount: {
176-
address: 'bc1qj633nx575jm28smgcp3mx6n3gh0zg6ndr0ew23'
177-
}
178-
},
179-
function (response) {
180-
console.log(response.status);
181-
console.log(response.data);
168+
let response = await client.post('/withdrawal', {
169+
sourceAsset: 'USD:GDUKMGUGDZQK6YHYA5Z6AY2G4XDSZPSZ3SW5UN3ARVMO6QSRDWP5YLEX', // withdraw from your USD wallet
170+
sourceAmount: 100,
171+
targetNetwork: 'BTC', // send to a BTC address
172+
targetAccount: {
173+
address: 'bc1qj633nx575jm28smgcp3mx6n3gh0zg6ndr0ew23'
182174
}
183-
);
175+
});
176+
177+
console.log(response.status);
178+
console.log(response.data);
184179
```
185180

186-
**Withdraw USDC to your Stellar Account** (https://www.coinqvest.com/en/api-docs#post-withdrawal)
181+
**Withdraw to your Stellar Account** (https://www.coinqvest.com/en/api-docs#post-withdrawal)
187182
```javascript
188-
client.post('/withdrawal',
189-
{
190-
sourceAsset: 'USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN', // withdraw from your USDC wallet
191-
sourceAmount: 100,
192-
targetNetwork: 'STELLAR', // a target network as given by GET /networks
193-
targetAccount: {
194-
account: 'GDONUHZKLSYLDOZWR2TDW25GFXOBWCCKTPK34DLUVSOMFHLGURX6FNU6',
195-
memo: 'Exodus',
196-
memoType: 'text'
197-
}
198-
},
199-
function (response) {
200-
console.log(response.status);
201-
console.log(response.data);
183+
let response = await client.post('/withdrawal', {
184+
sourceAsset: 'USD:GDUKMGUGDZQK6YHYA5Z6AY2G4XDSZPSZ3SW5UN3ARVMO6QSRDWP5YLEX', // withdraw from your USD wallet
185+
sourceAmount: 100,
186+
targetNetwork: 'XLM', // send to a Stellar account
187+
targetAccount: {
188+
account: 'bc1qj633nx575jm28smgcp3mx6n3gh0zg6ndr0ew23',
189+
memo: 'Exodus',
190+
memoType: 'text'
202191
}
203-
);
192+
});
193+
194+
console.log(response.status);
195+
console.log(response.data);
204196
```
205197

206198
**Update a Customer** (https://www.coinqvest.com/en/api-docs#put-customer)
207199
```javascript
208-
client.put('/customer',
209-
{customer:{id: 'CUSTOMER-ID', email: 'john@doe-2.com'}},
210-
function (response) {
211-
console.log(response.status);
212-
console.log(response.data);
213-
}
214-
);
200+
let response = await client.put('/customer', {customer:{id: 'CUSTOMER-ID', email: 'john@doe-2.com'}});
201+
202+
console.log(response.status);
203+
console.log(response.data);
215204
```
216205

217206
**Delete a Customer** (https://www.coinqvest.com/en/api-docs#delete-customer)
218207
```javascript
219-
client.delete('/customer',
220-
{id: 'CUSTOMER-ID'},
221-
function (response) {
222-
console.log(response.status);
223-
console.log(response.data);
224-
}
225-
);
208+
let response = await client.delete('/customer', {id: 'CUSTOMER-ID'});
209+
210+
console.log(response.status);
211+
console.log(response.data);
226212
```
227213

228214
**List your 250 newest customers** (https://www.coinqvest.com/en/api-docs#get-customers)
229215
```javascript
230-
client.get('/wallet',
231-
{limit: 250},
232-
function(response) {
233-
console.log(response.status);
234-
console.log(response.data);
235-
}
236-
);
237-
```
216+
let response = await client.get('/wallet', {limit: 250});
238217

239-
**List all available assets** (https://www.coinqvest.com/en/api-docs#get-assets)
240-
```javascript
241-
client.get('/assets',
242-
null,
243-
function(response) {
244-
console.log(response.status);
245-
console.log(response.data);
246-
}
247-
);
218+
console.log(response.status);
219+
console.log(response.data);
248220
```
249221

250222
**List all available networks** (https://www.coinqvest.com/en/api-docs#get-networks)
251223
```javascript
252-
client.get(
253-
'/networks',
254-
null,
255-
function(response) {
256-
console.log(response.status);
257-
console.log(response.data);
258-
}
259-
);
224+
let response = await client.get('/blockchains');
225+
226+
console.log(response.status);
227+
console.log(response.data);
260228
```
261229

262-
**The response object** ([axios](https://github.com/axios/axios) HTTP response as given to your callback function)
230+
**The response object** ([axios](https://github.com/axios/axios) HTTP response as given to your callback function)
263231
```javascript
264232
{
265233
// `data` is the response that was provided by the server
@@ -285,11 +253,11 @@ client.get(
285253
}
286254
```
287255

288-
Please inspect https://www.coinqvest.com/en/api-docs for detailed API documentation or email us at service@coinqvest.com if you have questions.
256+
Please inspect https://www.coinqvest.com/en/api-docs for detailed API documentation or send us an email to service@coinqvest.com.
289257

290258
Support and Feedback
291259
--------------------
292-
We'd love to hear your feedback. If you have specific problems or bugs with this SDK, please file an issue on GitHub. For general feedback and support requests please email service@coinqvest.com.
260+
Your feedback is appreciated! If you have specific problems or bugs with this SDK, please file an issue on Github. For general feedback and support requests, send an email to service@coinqvest.com.
293261

294262
Contributing
295263
------------

0 commit comments

Comments
 (0)