Skip to content
On this page

Downloading Packages

There are a few ways for package downloads to be initiated once a client has successfully authenticated with a Payment Gateway. When downloading paid packages on a repository, the client will make the following request.

GET /v2/download?packageId=my.example.tweak&version=1.2.1

WARNING

The client will make download requests for both free and paid packages.

Successful Request

The Payment Gateway is expected to respond with a JSON body containing a URL to the direct download of the debian package. An example has been provided below:

json
{
	"url": "https://mygateway.com/download/blob/foo.deb"
}

Download without Payment

If the user has not paid for the package, the Payment Gateway should return a status code of 402 Payment Required and may also supply an optional JSON body which contains a message for the client to display to the user. An example is provided below:

json
{
	"message": "Uh oh. It seems like you did not pay for this package!"
}

Direct Repository Downloads

If the specific package to download is not hosted on a CDN controlled by the Payment Gateway, it may return a blank response with a status code of 204 No Content. The client will handle this response by defaulting to the normal behavior of APT, where it will download the debian package from the Filename key on the package.

This is especially important for packages which use a Payment Gateway on a per package basis. For example, a developer may choose to serve beta versions of their package and would rather have the purchase UX over locking down the download.

WARNING

Please keep in mind that attaching a Payment Gateway to an individual package is mostly to promote proper UX and allow a user to purchase the tweak that they may want to download from a separate source. However, the purchase should also work on the main repository.

Unauthenticated Downloads

If for some reason, the request from the client is unauthenticated, the Payment Gateway should return 401 Unauthorized and may also supply an optional message for the client to show the user. An example is provided below:

json
{
	"message": "It appears you are not logged in. Please authenticate!"
}

TIP

If a Payment Gateway does not return the optional responses on failed download attempts, the client will show the user a generic error message.