Create payment request
curl --request POST \
--url https://api.getlago.com/api/v2/payment_requests \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"payment_request": {
"external_customer_id": "customer_123",
"lago_invoice_ids": [
"1a901a90-1a90-1a90-1a90-1a901a901a90"
],
"email": "billing@acme.example",
"payment_method": {
"payment_method_type": "provider",
"payment_method_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
}
}
}
'import requests
url = "https://api.getlago.com/api/v2/payment_requests"
payload = { "payment_request": {
"external_customer_id": "customer_123",
"lago_invoice_ids": ["1a901a90-1a90-1a90-1a90-1a901a901a90"],
"email": "billing@acme.example",
"payment_method": {
"payment_method_type": "provider",
"payment_method_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
}
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
payment_request: {
external_customer_id: 'customer_123',
lago_invoice_ids: ['1a901a90-1a90-1a90-1a90-1a901a901a90'],
email: 'billing@acme.example',
payment_method: {
payment_method_type: 'provider',
payment_method_id: '1a901a90-1a90-1a90-1a90-1a901a901a90'
}
}
})
};
fetch('https://api.getlago.com/api/v2/payment_requests', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.getlago.com/api/v2/payment_requests",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'payment_request' => [
'external_customer_id' => 'customer_123',
'lago_invoice_ids' => [
'1a901a90-1a90-1a90-1a90-1a901a901a90'
],
'email' => 'billing@acme.example',
'payment_method' => [
'payment_method_type' => 'provider',
'payment_method_id' => '1a901a90-1a90-1a90-1a90-1a901a901a90'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.getlago.com/api/v2/payment_requests"
payload := strings.NewReader("{\n \"payment_request\": {\n \"external_customer_id\": \"customer_123\",\n \"lago_invoice_ids\": [\n \"1a901a90-1a90-1a90-1a90-1a901a901a90\"\n ],\n \"email\": \"billing@acme.example\",\n \"payment_method\": {\n \"payment_method_type\": \"provider\",\n \"payment_method_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.getlago.com/api/v2/payment_requests")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"payment_request\": {\n \"external_customer_id\": \"customer_123\",\n \"lago_invoice_ids\": [\n \"1a901a90-1a90-1a90-1a90-1a901a901a90\"\n ],\n \"email\": \"billing@acme.example\",\n \"payment_method\": {\n \"payment_method_type\": \"provider\",\n \"payment_method_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getlago.com/api/v2/payment_requests")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"payment_request\": {\n \"external_customer_id\": \"customer_123\",\n \"lago_invoice_ids\": [\n \"1a901a90-1a90-1a90-1a90-1a901a901a90\"\n ],\n \"email\": \"billing@acme.example\",\n \"payment_method\": {\n \"payment_method_type\": \"provider\",\n \"payment_method_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"payment_request": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"lago_customer_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"external_customer_id": "customer_123",
"email": "billing@acme.example",
"amount_cents": 100,
"currency": "USD",
"payment_status": "pending",
"lago_invoice_ids": [
"1a901a90-1a90-1a90-1a90-1a901a901a90"
],
"created_at": "2022-04-29T08:59:51.123456Z",
"updated_at": "2022-04-29T08:59:51.123456Z"
}
}{
"code": "invalid_expand",
"details": [
{
"code": "malformed",
"field": "expands",
"meta": {
"allowed_values": []
}
}
]
}{
"code": "unauthorized",
"details": []
}{
"code": "feature_unavailable",
"details": []
}{
"code": "resource_not_found",
"details": [
{
"code": "resource_not_found",
"field": "base",
"meta": {
"resource": "resource_name"
}
}
]
}{
"code": "validation_errors",
"details": [
{
"code": "value_is_mandatory",
"field": "name",
"meta": {}
}
]
}Payment requests
Create payment request
Requires a premium license.
POST
/
payment_requests
Create payment request
curl --request POST \
--url https://api.getlago.com/api/v2/payment_requests \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"payment_request": {
"external_customer_id": "customer_123",
"lago_invoice_ids": [
"1a901a90-1a90-1a90-1a90-1a901a901a90"
],
"email": "billing@acme.example",
"payment_method": {
"payment_method_type": "provider",
"payment_method_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
}
}
}
'import requests
url = "https://api.getlago.com/api/v2/payment_requests"
payload = { "payment_request": {
"external_customer_id": "customer_123",
"lago_invoice_ids": ["1a901a90-1a90-1a90-1a90-1a901a901a90"],
"email": "billing@acme.example",
"payment_method": {
"payment_method_type": "provider",
"payment_method_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
}
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
payment_request: {
external_customer_id: 'customer_123',
lago_invoice_ids: ['1a901a90-1a90-1a90-1a90-1a901a901a90'],
email: 'billing@acme.example',
payment_method: {
payment_method_type: 'provider',
payment_method_id: '1a901a90-1a90-1a90-1a90-1a901a901a90'
}
}
})
};
fetch('https://api.getlago.com/api/v2/payment_requests', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.getlago.com/api/v2/payment_requests",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'payment_request' => [
'external_customer_id' => 'customer_123',
'lago_invoice_ids' => [
'1a901a90-1a90-1a90-1a90-1a901a901a90'
],
'email' => 'billing@acme.example',
'payment_method' => [
'payment_method_type' => 'provider',
'payment_method_id' => '1a901a90-1a90-1a90-1a90-1a901a901a90'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.getlago.com/api/v2/payment_requests"
payload := strings.NewReader("{\n \"payment_request\": {\n \"external_customer_id\": \"customer_123\",\n \"lago_invoice_ids\": [\n \"1a901a90-1a90-1a90-1a90-1a901a901a90\"\n ],\n \"email\": \"billing@acme.example\",\n \"payment_method\": {\n \"payment_method_type\": \"provider\",\n \"payment_method_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.getlago.com/api/v2/payment_requests")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"payment_request\": {\n \"external_customer_id\": \"customer_123\",\n \"lago_invoice_ids\": [\n \"1a901a90-1a90-1a90-1a90-1a901a901a90\"\n ],\n \"email\": \"billing@acme.example\",\n \"payment_method\": {\n \"payment_method_type\": \"provider\",\n \"payment_method_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getlago.com/api/v2/payment_requests")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"payment_request\": {\n \"external_customer_id\": \"customer_123\",\n \"lago_invoice_ids\": [\n \"1a901a90-1a90-1a90-1a90-1a901a901a90\"\n ],\n \"email\": \"billing@acme.example\",\n \"payment_method\": {\n \"payment_method_type\": \"provider\",\n \"payment_method_id\": \"1a901a90-1a90-1a90-1a90-1a901a901a90\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"payment_request": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"lago_customer_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"external_customer_id": "customer_123",
"email": "billing@acme.example",
"amount_cents": 100,
"currency": "USD",
"payment_status": "pending",
"lago_invoice_ids": [
"1a901a90-1a90-1a90-1a90-1a901a901a90"
],
"created_at": "2022-04-29T08:59:51.123456Z",
"updated_at": "2022-04-29T08:59:51.123456Z"
}
}{
"code": "invalid_expand",
"details": [
{
"code": "malformed",
"field": "expands",
"meta": {
"allowed_values": []
}
}
]
}{
"code": "unauthorized",
"details": []
}{
"code": "feature_unavailable",
"details": []
}{
"code": "resource_not_found",
"details": [
{
"code": "resource_not_found",
"field": "base",
"meta": {
"resource": "resource_name"
}
}
]
}{
"code": "validation_errors",
"details": [
{
"code": "value_is_mandatory",
"field": "name",
"meta": {}
}
]
}API v2 is in beta. Endpoints return the
X-Lago-Endpoint-Status: beta header.This endpoint changes billing or financial records. Check the target environment, the resource identifier and the expected effect before you call it. Review the change before you run it in production.
Authorizations
Body
application/json
Request payload