getlago / lago-api Goto Github PK
View Code? Open in Web Editor NEWOpen Source Metering and Usage Based Billing
Home Page: https://www.getlago.com/
License: GNU Affero General Public License v3.0
Open Source Metering and Usage Based Billing
Home Page: https://www.getlago.com/
License: GNU Affero General Public License v3.0
Sentry Issue: API-3
LoadError: cannot load such file -- factory_bot_rails
bootsnap (1.10.3) lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:27:in `require'
zeitwerk (2.5.4) lib/zeitwerk/kernel.rb:35:in `require'
db/seeds.rb:3:in `<main>'
require 'factory_bot_rails'
bootsnap (1.10.3) lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:48:in `load'
bootsnap (1.10.3) lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:48:in `load'
...
(46 additional frame(s) were not displayed)
GraphQL errors should be typed directly by the back end schema definition
https://height.app/GJLAkYTZn5/T-906
api_key
fieldapi_key
right after the organization creationapi_key
field into the GraphQL Organization's typeUse a gem like https://github.com/paper-trail-gem/paper_trail to track changes on sensitive resources like plan
, billable_metrics
or customer
For GraphQL mutation, we should improve the way validation errors are sent to the front.
It will allow the front end to properly handle translations and field errors
In order to do to so, in case of unprocessable_entity
error, an extension property of the GraphQL error will give the full detail of what went wrong when processing the mutation on the model.
Example of payload:
{
"customer_id": ["already_taken"],
"country": ["invalid"]
}
Today we use the same service method for creating a customer with the API and the GraphQL endpoints.
We must create a dedicated method for GraphQL since the logic is a bit different :
Sentry issue: API-B
We must add the webhook logic that will be triggered when the invoice is processed
sum
and max
agg type instead of only integerIf we downgrade a subscription, we should have only one pending subscription.
If any subscription is pending, we cancel it.
We also should filter subscriptions for the graphQL endpoint and do not return cancelled
{}
by defaultToday we use the customer.customer_id
to create a subscription from API or GraphQL.
To avoid misleading, we should use the customer.id
on our GraphQL mutation
We recently introduce numerical validations on the vat_rate
attribute of organizations
and customers
.
Since this validations have an impact on the graphQL API, we need to add error codes to allow the front end to properly handle and translate them.
DELETE /api/v1/subscriptions/terminate
, we should use DELETE /api/v1/subscriptions/:id
We should add an API route to allow users to retrieve the public key used to verify the webhook signature.
On each subscription fee creation:
end_of_trial = subscription_date + plan.trial_period
if to_date of invoice < end_of_trial
amount = 0
elsif from_date < end_of_trial && to_date > end_of_trial
amount = pro-rata on days to bill
else # from_date > end_of_trial
amoun = full amount
end
Add a property to the invoices table to store the number of free days to prevent recomputing it each time
DB resources should not be hard deleted, instead, we should add a deleted_at
.
Soft deleted resources should not be exposed in GraphQL or API but remain present in DB for tracking purpose.
Warning: this will impact all DB indexes based on unique constraint, the deleted_at
field should be part of the index
Since we do not use frequency anymore (one_shot
or recurring
) we must remove frequency
on charges
Possible problems:
MAX
and SUM
aggregation, field value is expected to be an integer.
ActiveRecord::StatementInvalid
is raised by rails. Today it is handled at aggregation time but it fails for all the billing periodMAX
, SUM
and COUNT UNIQUE
, a property is expected in the event payload.
In both cases, we should detect it, filter invalid events from the aggregation and let the user/developer know there is an issuer with the event.
The proper solution to let the user know still as to be discussed with the product team
Today, when checking for upgrade/downgrade of plan, we compare plan amount_cents no mater if the plan is yearly or monthly.
To have a proper base of comparison, we should divide multiply the amount by 12 when the plan is monhtly
updateOrganization
mutation on GraphQL
webhook_url
only for nowLinked to getlago/lago#12
API end-point as well as response and errors should be fully documented in the public documentation.
Sentry issue: API-8
remove helm values from repository
Describe the bug
When no customer is linked to a plan, we should be able to edit the plan (infos, model and charges). We have to be able to:
To Reproduce
Expected behavior
We shoud be able to edit a plan if no active subscription is assigned for this plan
Sentry Issue: API-2
ArgumentError: bad argument (expected URI object or URI string)
lib/lago_http_client/lago_http_client/client.rb:8:in `initialize'
@uri = URI(url)
app/services/webhooks/base_service.rb:16:in `new'
http_client = LagoHttpClient::Client.new(current_organization.webhook_url)
app/services/webhooks/base_service.rb:16:in `call'
http_client = LagoHttpClient::Client.new(current_organization.webhook_url)
app/jobs/send_webhook_job.rb:13:in `perform'
Webhooks::InvoicesService.new(object).call
...
(74 additional frame(s) were not displayed)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.