From 61e3216764296ba00ac441156660b29e8509d54e Mon Sep 17 00:00:00 2001 From: Jeremy Denquin Date: Mon, 20 Nov 2023 14:08:58 +0100 Subject: [PATCH] feat(customers): Add checkout_url endpoint --- lib/lago/api/resources/customer.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/lago/api/resources/customer.rb b/lib/lago/api/resources/customer.rb index c1b17b4..6101635 100644 --- a/lib/lago/api/resources/customer.rb +++ b/lib/lago/api/resources/customer.rb @@ -41,6 +41,16 @@ def portal_url(external_customer_id) JSON.parse(response.to_json, object_class: OpenStruct).portal_url end + def checkout_url(external_customer_id) + uri = URI( + "#{client.base_api_url}#{api_resource}/#{external_customer_id}/checkout_url", + ) + + response = connection.post(uri, identifier: nil)[root_name] + + JSON.parse(response.to_json, object_class: OpenStruct).checkout_url + end + def whitelist_params(params) result_hash = { external_id: params[:external_id],