Create a payment request
Creates a payment request and returns a checkout_url the recipient
opens to pay with Apple Pay or card. Funds settle directly to your
connected Stripe account. A payment request is independent of any chat;
to associate one with a chat for your records, store the chat id in
metadata. Requires your connected account to be charges_enabled
(returns 403 otherwise).
Set mode: subscription with a recurring price_id from your connected
Stripe account to start an auto-renewing subscription instead of a
one-time charge — the recipient pays the first invoice at checkout and
the response’s stripe object carries the customer and subscription ids
for the ongoing lifecycle in your own Stripe account. See the
Subscriptions section of the tag overview.
In either mode, pass customer_id to attach the request to an
existing Customer on your connected account instead of creating a
new one — see Pre-created customers in the tag overview.
Create a payment request
import LinqAPIV3 from '@linqapp/sdk';
const client = new LinqAPIV3({
apiKey: process.env['LINQ_API_V3_API_KEY'], // This is the default and can be omitted
});
const paymentRequest = await client.paymentRequests.create({
amount: 497,
currency: 'usd',
description: 'Coffee with Ava',
metadata: { order_id: 'order_8675309' },
});
console.log(paymentRequest.id);{
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"amount": 497,
"checkout_url": "https://zero.linqapp.com/pay/tomo?session=tok_abc123",
"created_at": "2019-12-27T18:11:19.117Z",
"currency": "usd",
"mode": "payment",
"object": "payment_request",
"status": "requested",
"description": "description",
"expires_at": "2019-12-27T18:11:19.117Z",
"interval": "day",
"interval_count": 0,
"metadata": {
"foo": "string"
},
"natural": {
"payment_request_id": "payment_request_id",
"transaction_id": "transaction_id"
},
"paid_at": "2019-12-27T18:11:19.117Z",
"price_id": "price_id",
"quantity": 0,
"rail": "stripe",
"stripe": {
"customer_id": "cus_QAbCdEfGhIjKlMn",
"payment_intent_id": "pi_3QAbCdEfGhIjKlMn",
"subscription_id": "sub_1QAbCdEfGhIjKlMn"
},
"trial_end": "2019-12-27T18:11:19.117Z",
"updated_at": "2019-12-27T18:11:19.117Z"
}{
"error": {
"status": 400,
"code": 1002,
"message": "Phone number must be in E.164 format",
"doc_url": "https://docs.linqapp.com/error/codes/1xxx/1002/"
},
"success": false
}{
"error": {
"status": 401,
"code": 2004,
"message": "Unauthorized - missing or invalid authentication token",
"doc_url": "https://docs.linqapp.com/error/codes/2xxx/2004/"
},
"success": false
}{
"error": {
"status": 403,
"code": 2005,
"message": "Access denied - insufficient permissions for this resource",
"doc_url": "https://docs.linqapp.com/error/codes/2xxx/2005/"
},
"success": false
}{
"error": {
"status": 409,
"code": 2013,
"message": "This chat is unavailable",
"doc_url": "https://docs.linqapp.com/error/codes/2xxx/2013/"
},
"success": false
}{
"error": {
"status": 500,
"code": 3006,
"message": "Internal server error",
"doc_url": "https://docs.linqapp.com/error/codes/3xxx/3006/"
},
"success": false
}Returns Examples
{
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"amount": 497,
"checkout_url": "https://zero.linqapp.com/pay/tomo?session=tok_abc123",
"created_at": "2019-12-27T18:11:19.117Z",
"currency": "usd",
"mode": "payment",
"object": "payment_request",
"status": "requested",
"description": "description",
"expires_at": "2019-12-27T18:11:19.117Z",
"interval": "day",
"interval_count": 0,
"metadata": {
"foo": "string"
},
"natural": {
"payment_request_id": "payment_request_id",
"transaction_id": "transaction_id"
},
"paid_at": "2019-12-27T18:11:19.117Z",
"price_id": "price_id",
"quantity": 0,
"rail": "stripe",
"stripe": {
"customer_id": "cus_QAbCdEfGhIjKlMn",
"payment_intent_id": "pi_3QAbCdEfGhIjKlMn",
"subscription_id": "sub_1QAbCdEfGhIjKlMn"
},
"trial_end": "2019-12-27T18:11:19.117Z",
"updated_at": "2019-12-27T18:11:19.117Z"
}{
"error": {
"status": 400,
"code": 1002,
"message": "Phone number must be in E.164 format",
"doc_url": "https://docs.linqapp.com/error/codes/1xxx/1002/"
},
"success": false
}{
"error": {
"status": 401,
"code": 2004,
"message": "Unauthorized - missing or invalid authentication token",
"doc_url": "https://docs.linqapp.com/error/codes/2xxx/2004/"
},
"success": false
}{
"error": {
"status": 403,
"code": 2005,
"message": "Access denied - insufficient permissions for this resource",
"doc_url": "https://docs.linqapp.com/error/codes/2xxx/2005/"
},
"success": false
}{
"error": {
"status": 409,
"code": 2013,
"message": "This chat is unavailable",
"doc_url": "https://docs.linqapp.com/error/codes/2xxx/2013/"
},
"success": false
}{
"error": {
"status": 500,
"code": 3006,
"message": "Internal server error",
"doc_url": "https://docs.linqapp.com/error/codes/3xxx/3006/"
},
"success": false
}