-
Notifications
You must be signed in to change notification settings - Fork 1
API Docs
Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.
An API for customers and payments with Stripe.
Base URLs:
- HTTP Authentication, scheme: bearer An http bearer auth token is required for all secured routes. An auth grant can be obtained from
/user/loginand/user/register
Code samples
const inputBody = '{
"userName": "Alan Turing",
"email": "aturing@gmail.com",
"password": "password"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'application/json',
'Authorization':'Bearer {access-token}'
};
fetch('/user',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});POST /user
Body parameter
{
"userName": "Alan Turing",
"email": "aturing@gmail.com",
"password": "password"
}| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | CreateUserDto | true | none |
Example responses
201 Response
{
"userId": "5f9f1c9b9c9c9c9c9c9c9c9c",
"userName": "Alan Turing",
"email": "aturing@gmail.com",
"customerId": "cus_1234567890"
}| Status | Meaning | Description | Schema |
|---|---|---|---|
| 201 | Created | none | ReturnUserDto |
Code samples
const headers = {
'Accept':'application/json',
'Authorization':'Bearer {access-token}'
};
fetch('/user',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});GET /user
Example responses
200 Response
[
{
"userId": "5f9f1c9b9c9c9c9c9c9c9c9c",
"userName": "Alan Turing",
"email": "aturing@gmail.com",
"customerId": "cus_1234567890"
}
]| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | none | Inline |
Status Code 200
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| anonymous | [ReturnUserDto] | false | none | none |
| » userId | string | true | none | The user's id in Mongodb. |
| » userName | string | true | none | The user's name. |
| string | true | none | The user's email address. | |
| » customerId | string | false | none | The user's Stripe customer id. Users without transactions do not have a customer id. |
Code samples
const headers = {
'Accept':'application/json',
'Authorization':'Bearer {access-token}'
};
fetch('/user/{id}',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});GET /user/{id}
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| id | path | string | true | none |
Example responses
200 Response
{
"userId": "5f9f1c9b9c9c9c9c9c9c9c9c",
"userName": "Alan Turing",
"email": "aturing@gmail.com",
"customerId": "cus_1234567890"
}| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | none | ReturnUserDto |
Code samples
const inputBody = '{
"userName": "Alan Turing",
"email": "aturing@gmail.com",
"customerId": "cus_1234567890"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'application/json',
'Authorization':'Bearer {access-token}'
};
fetch('/user/{id}',
{
method: 'PATCH',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});PATCH /user/{id}
Body parameter
{
"userName": "Alan Turing",
"email": "aturing@gmail.com",
"customerId": "cus_1234567890"
}| Name | In | Type | Required | Description |
|---|---|---|---|---|
| id | path | string | true | none |
| body | body | UpdateUserDto | true | none |
Example responses
200 Response
{
"userId": "5f9f1c9b9c9c9c9c9c9c9c9c",
"userName": "Alan Turing",
"email": "aturing@gmail.com",
"customerId": "cus_1234567890"
}| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | none | ReturnUserDto |
Code samples
const headers = {
'Accept':'application/json',
'Authorization':'Bearer {access-token}'
};
fetch('/user/{id}',
{
method: 'DELETE',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});DELETE /user/{id}
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| id | path | string | true | none |
Example responses
200 Response
{
"userId": "5f9f1c9b9c9c9c9c9c9c9c9c",
"userName": "Alan Turing",
"email": "aturing@gmail.com",
"customerId": "cus_1234567890"
}| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | none | ReturnUserDto |
Code samples
const inputBody = '{
"userName": "Alan Turing",
"email": "aturing@gmail.com",
"password": "password"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'application/json'
};
fetch('/user/register',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});POST /user/register
Body parameter
{
"userName": "Alan Turing",
"email": "aturing@gmail.com",
"password": "password"
}| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | CreateUserDto | true | none |
Example responses
201 Response
{
"access_token": "string"
}| Status | Meaning | Description | Schema |
|---|---|---|---|
| 201 | Created | none | AuthGrantDto |
Code samples
const inputBody = '{
"email": "aturing@gmail.com",
"password": "password"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'application/json'
};
fetch('/user/login',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});POST /user/login
Body parameter
{
"email": "aturing@gmail.com",
"password": "password"
}| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | LoginUserDto | true | none |
Example responses
201 Response
{
"access_token": "string"
}| Status | Meaning | Description | Schema |
|---|---|---|---|
| 201 | Created | none | AuthGrantDto |
Code samples
const headers = {
'Accept':'application/json',
'Authorization':'Bearer {access-token}'
};
fetch('/payment',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});GET /payment
Example responses
200 Response
[
{
"id": "pi_1H7jg1CZ6F7J6I8jW2Q2c2jG",
"amount": 2000,
"currency": "usd",
"status": "pending",
"paymentMethod": "pm_1H7jg1CZ6F7J6I8jW2Q2c2jG"
}
]| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | none | Inline |
Status Code 200
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| anonymous | [ReturnPaymentDto] | false | none | none |
| » id | string | true | none | Payment Intent ID. |
| » amount | number | true | none | Amount in cents. |
| » currency | string | true | none | Currency code. See https://stripe.com/docs/currencies. |
| » status | string | true | none | Payment Intent status. See https://stripe.com/docs/payments/payment-intents#intent-statuses. |
| » paymentMethod | string | true | none | Stripe payment method |
Code samples
const inputBody = '{
"cuid": "cjld2cjxh0000qzrmn831i7rn"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'application/json',
'Authorization':'Bearer {access-token}'
};
fetch('/payment',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});POST /payment
Body parameter
{
"cuid": "cjld2cjxh0000qzrmn831i7rn"
}| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | CreatePaymentDto | true | none |
Example responses
201 Response
{
"id": "pi_1H7jg1CZ6F7J6I8jW2Q2c2jG",
"amount": 2000,
"currency": "usd",
"status": "pending",
"paymentMethod": "pm_1H7jg1CZ6F7J6I8jW2Q2c2jG",
"clientSecret": "Jreaw828oaooi3j3r"
}| Status | Meaning | Description | Schema |
|---|---|---|---|
| 201 | Created | none | PaymentCreatedDto |
Code samples
const headers = {
'Accept':'application/json',
'Authorization':'Bearer {access-token}'
};
fetch('/payment/{id}',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});GET /payment/{id}
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| id | path | string | true | none |
Example responses
200 Response
{
"id": "pi_1H7jg1CZ6F7J6I8jW2Q2c2jG",
"amount": 2000,
"currency": "usd",
"status": "pending",
"paymentMethod": "pm_1H7jg1CZ6F7J6I8jW2Q2c2jG"
}| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | none | ReturnPaymentDto |
Code samples
const inputBody = '{
"cuid": "cjld2cjxh0000qzrmn831i7rn",
"paymentId": "pi_1H4Q2cKZ4Z4Z4Z4Z4Z4Z4Z4Z",
"paymentMethodId": "pm_1H7jg1CZ6F7J6I8jW2Q2c2jG"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'application/json',
'Authorization':'Bearer {access-token}'
};
fetch('/payment/confirm',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});POST /payment/confirm
Body parameter
{
"cuid": "cjld2cjxh0000qzrmn831i7rn",
"paymentId": "pi_1H4Q2cKZ4Z4Z4Z4Z4Z4Z4Z4Z",
"paymentMethodId": "pm_1H7jg1CZ6F7J6I8jW2Q2c2jG"
}| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | ConfirmPaymentDto | true | none |
Example responses
201 Response
{
"id": "pi_1H7jg1CZ6F7J6I8jW2Q2c2jG",
"amount": 2000,
"currency": "usd",
"status": "pending",
"paymentMethod": "pm_1H7jg1CZ6F7J6I8jW2Q2c2jG"
}| Status | Meaning | Description | Schema |
|---|---|---|---|
| 201 | Created | none | ReturnPaymentDto |
{
"userName": "Alan Turing",
"email": "aturing@gmail.com",
"password": "password"
}
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| userName | string | true | none | The user's name. |
| string | true | none | The user's email address. | |
| password | string | true | none | The user's password. |
{
"userId": "5f9f1c9b9c9c9c9c9c9c9c9c",
"userName": "Alan Turing",
"email": "aturing@gmail.com",
"customerId": "cus_1234567890"
}
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| userId | string | true | none | The user's id in Mongodb. |
| userName | string | true | none | The user's name. |
| string | true | none | The user's email address. | |
| customerId | string | false | none | The user's Stripe customer id. Users without transactions do not have a customer id. |
{
"userName": "Alan Turing",
"email": "aturing@gmail.com",
"customerId": "cus_1234567890"
}
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| userName | string | false | none | The user's name. |
| string | false | none | The user's email address. | |
| customerId | string | false | none | The user's Stripe customer id. |
{
"access_token": "string"
}
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| access_token | string | true | none | The access token. |
{
"email": "aturing@gmail.com",
"password": "password"
}
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| string | true | none | The user's email address. | |
| password | string | true | none | The user's password. |
{
"id": "pi_1H7jg1CZ6F7J6I8jW2Q2c2jG",
"amount": 2000,
"currency": "usd",
"status": "pending",
"paymentMethod": "pm_1H7jg1CZ6F7J6I8jW2Q2c2jG"
}
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| id | string | true | none | Payment Intent ID. |
| amount | number | true | none | Amount in cents. |
| currency | string | true | none | Currency code. See https://stripe.com/docs/currencies. |
| status | string | true | none | Payment Intent status. See https://stripe.com/docs/payments/payment-intents#intent-statuses. |
| paymentMethod | string | true | none | Stripe payment method |
{
"cuid": "cjld2cjxh0000qzrmn831i7rn"
}
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| cuid | string | true | none | CUID (collision resistant id) that identifies the user session. Use https://github.com/paralleldrive/cuid to generate them. This is used as an idempotency key for the payment intent creation. Thus, they should be unique foreach payment intent creation but remain constant between retries. |
{
"id": "pi_1H7jg1CZ6F7J6I8jW2Q2c2jG",
"amount": 2000,
"currency": "usd",
"status": "pending",
"paymentMethod": "pm_1H7jg1CZ6F7J6I8jW2Q2c2jG",
"clientSecret": "Jreaw828oaooi3j3r"
}
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| id | string | true | none | Payment Intent ID. |
| amount | number | true | none | Amount in cents. |
| currency | string | true | none | Currency code. See https://stripe.com/docs/currencies. |
| status | string | true | none | Payment Intent status. See https://stripe.com/docs/payments/payment-intents#intent-statuses. |
| paymentMethod | string | true | none | Stripe payment method |
| clientSecret | string | true | none | Client secret for the payment intent. |
{
"cuid": "cjld2cjxh0000qzrmn831i7rn",
"paymentId": "pi_1H4Q2cKZ4Z4Z4Z4Z4Z4Z4Z4Z",
"paymentMethodId": "pm_1H7jg1CZ6F7J6I8jW2Q2c2jG"
}
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| cuid | string | true | none | CUID (collision resistant id) that identifies the user session. Use https://github.com/paralleldrive/cuid to generate them. This is used as an idempotency key for the payment intent creation. Thus, they should be unique foreach payment intent creation but remain constant between retries. |
| paymentId | string | true | none | Payment intent id. |
| paymentMethodId | string | true | none | Payment method id. |