LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
curl --location --request POST "$LAGO_URL/api/v1/applied_coupons" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"applied_coupon": {
"external_customer_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"coupon_code": "startup_deal",
"amount_cents": 2500,
"amount_currency": "EUR",
"frequency": "recurring",
"frequency_duration": 3
}
}'
from lago_python_client.client import Client
from lago_python_client.exceptions import LagoApiError
from lago_python_client.models import AppliedCoupon
client = Client(api_key='__YOUR_API_KEY__')
applied_coupon = AppliedCoupon(
external_customer_id="5eb02857-a71e-4ea2-bcf9-57d8885990ba",
coupon_code="startup_deal",
amount_cents=2500,
amount_currency="EUR",
frequency="recurring",
frequency_duration=3
)
try:
client.applied_coupons.create(applied_coupon)
except LagoApiError as e:
repair_broken_state(e) # do something on error or raise your own exception
require 'lago-ruby-client'
client = Lago::Api::Client.new({api_key: '__YOUR_API_KEY__'})
client.applied_coupons.create(
external_customer_id: "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
coupon_code: "startup_deal",
amount_cents: 2500,
amount_currency: "EUR",
frequency: "recurring",
frequency_duration: 3
)
const appliedCouponObject = {
external_customer_id: "5eb02857-a71e-4ea2-bcf9-57d8885990ba",
coupon_code: "startup_deal",
amount_cents: 2500,
amount_currency: "EUR",
frequency: "recurring" as AppliedCouponObject["frequency"],
frequency_duration: 3,
};
await client.appliedCoupons.applyCoupon({
appliedCoupon: appliedCouponObject,
});
import "fmt"
import "github.com/getlago/lago-go-client"
func main() {
lagoClient := lago.New().
SetApiKey("__YOUR_API_KEY__")
applyCouponInput := &lago.ApplyCouponInput{
ExternalCustomerID: "5eb02857-a71e-4ea2-bcf9-57d8885990ba",
CouponCode: "startup_deal",
Frequency: lago.CouponFrequencyRecurring,
FrequencyDuration: 3
}
appliedCoupon, err := lagoClient.Coupon().ApplyToCustomer(applyCouponInput)
if err != nil {
// Error is *lago.Error
panic(err)
}
// appliedCoupon is *lago.AppliedCoupon
fmt.Println(appliedCoupon)
}
using System.Collections.Generic;
using System.Diagnostics;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;
namespace Example
{
public class ApplyCouponExample
{
public static void Main()
{
Configuration.Default.BasePath = "https://api.getlago.com/api/v1";
// Configure HTTP bearer authorization: bearerAuth
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new CouponsApi(Configuration.Default);
var appliedCouponInput = new AppliedCouponInput(); // AppliedCouponInput | Apply coupon payload
try
{
// Apply a coupon to a customer
AppliedCoupon result = apiInstance.ApplyCoupon(appliedCouponInput);
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling CouponsApi.ApplyCoupon: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Bearer authorization: bearerAuth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\Client\Api\CouponsApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$applied_coupon_input = new \OpenAPI\Client\Model\AppliedCouponInput(); // \OpenAPI\Client\Model\AppliedCouponInput | Apply coupon payload
try {
$result = $apiInstance->applyCoupon($applied_coupon_input);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling CouponsApi->applyCoupon: ', $e->getMessage(), PHP_EOL;
}