Skip to content

feat: add Invoices#download_link and query params on Subscriptions#get - #13

Merged
gastonrey merged 1 commit into
mainfrom
feat/download-link-and-get-params
Oct 6, 2026
Merged

gastonrey merged 1 commit into
mainfrom
feat/download-link-and-get-params

Conversation

@gastonrey

Copy link
Copy Markdown
Collaborator

Why

The Customer Portal needs a browser-openable link to an invoice or credit-note PDF for Hyperline-billed companies, like the download_url Chargebee returns. GET /v2/invoices/{id}/download answers with a 302 to a signed, short-lived S3 URL, but Invoices#download follows the redirect and returns the bytes. Separately, Subscriptions#get accepted no query params, so callers embedded ?include_live_billing=true in the id.

What

  • Invoices#download_link(id, **params) calls GET /v2/invoices/{id}/download without following the redirect and returns a Hyperline::DownloadLink (url, expires_at).
    • expires_at is computed from X-Amz-Date + X-Amz-Expires (UTC).
    • It works for credit notes too, which are invoice documents of type refund.
    • If the API answers 200 with the PDF instead, url is nil and callers fall back to download.
    • 4xx/5xx raise the usual errors.
    • The API key is never sent to S3.
  • Subscriptions#get(id, **params) sends params as the query string, e.g. include_live_billing: true. get(id) sends exactly the same request as before.

Verification

  • bundle exec rspec: 150 examples, 0 failures, also under a non-UTC TZ. rubocop: no offenses.
  • Read-only against the Hyperline sandbox: download_link returned the signed S3 URL, valid for 60 minutes, for an invoice and for a credit note. get(id, include_live_billing: true) returned live_billing.
  • Version not bumped; entries are under ## [Unreleased] in the CHANGELOG.

@gastonrey
gastonrey marked this pull request as ready for review October 6, 2026 10:53
@gastonrey
gastonrey merged commit dc97e5a into main Oct 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants