Download the PHP package capitual/cappay-php-sdk without Composer

On this page you can find all versions of the php package capitual/cappay-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cappay-php-sdk

CapPay SDK for PHP

This is CapPay's PHP SDK.

With this SDK you are able to start receiving payments in crypto-currencies in a few minutes!

Logging In

Note that you have to login to the button generator on CapPay Button Generator.

You will also need your merchant ID, that can be found on your Capitual profile.

Installing

You can either download the library or use Composer to install it directly:

After it, include the CapPay.php file on your project (or Composer's autoload file) and you are ready to start using CapPay.

Creating a new invoice

In order to send a new invoice to receive a new payment, create a new instance of the Capitual\CapPay class.

Then set your merchant ID.

Set the address of your Capitual wallet that will receive the funds for this payment. This is not a crypto-wallet address. This is the address of one of your Capitual wallets. Note that you may choose a wallet of any currency, but if the currency is different from the invoice currency (that we'll set below), an exchange rate will apply. Otherwise, no fees are involved.

Now it's time to set the payment currency and value. The value is a string. Always use dots (.) for decimals (do not worry about using the correct amount of decimals if this is not relevant for your use case), and not commas.

The currency may be one of the following:

Code Currency
BTC Bitcoin
LTC Litecoin
DSH Dash
USD US Dollar
EUR Euro
BRL Brazilian Real

Now, set the payee's email address. Note that the invoice will also be sent to his email.

If you want, you can also set a human-readable payment description for your customer:

Optionally set expiration date, as a Unix timestamp (UTC timezone).

IPN: If you want, you can set a public accessible URL that Capitual servers should call once the payment is done. You may include query string variables.

That's all! To create the invoice, just do:

After the invoice was created, you may retrieve its ID using:

You may also get its URL using:

You may redirect or create a link to this URL for your user to be able to pay.

It's also advisable to set a return URL, which your user will be redirected to after the payment (it does not work on the shortlink). To do so, just append a "return_url" query param.

Note that the user requesting your return_url does not mean the payment is complete, as crypto transactions require waiting for confirmation time. Delivering the product/service before the confirmation is dangerous and may lead to its loss, as transactions with low fees may never be confirmed. Use IPN (see next article) for checking when the transaction is confirmed.

IPN - Instant Payment Notification

The URL you set as ipn will receive HTTP POST requests (x-www-form-urlencoded) with two variables:

Variable Description
InvoiceID The invoice ID (as in $invoice->id)
Type Message type

The message type may be (notice the case):

Type Description
Received The invoice was paid, but not yet confirmed. It's not yet safe to deliver the product/service.
Paid The invoice was paid and confirmed. It's now safe to deliver the product/service.
Cancelled The invoice was cancelled (this can only be done by the invoice sender)

In a perfect situation, IPN by itself could be enough, but unfortunately we know that the bad guys are trying to break things all the time, and may discover your IPN URL and spoof the request, making your system to think a payment has been done while it hasn't. Therefore, you shall not take IPN requests as a reliable source of truth. Rather, treat it simply as a notification. You should retrieve information about the invoice when you receive a IPN request.

Retrieving information about an invoice

In order to retrieve information about an invoice, simply create a new instance of the class, passing the invoice ID as argument to the constructor:

Now, you may get every property of the class, just like you've just set it.

Note that for security reasons it's not possible to retrieve $invoice->payee using this method. You should store it on your database after creating the invoice. You may retrieve the invoice payee by logging in to your Capitual account, or by implementing the complete Capitual API.

You may get the invoice status using:

For the sake of code readability, the invoice status strings are also available as static values:


All versions of cappay-php-sdk with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package capitual/cappay-php-sdk contains the following files

Loading the files please wait ....