Download the PHP package afterpay-global/afterpay-sdk-php without Composer

On this page you can find all versions of the php package afterpay-global/afterpay-sdk-php. 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 afterpay-sdk-php

Build

Official Afterpay SDK for PHP

Prerequisites

Minimum requirements:

Optional recommendations:

Installation

Install with Composer.

For Production

For production usage, ensure the dist install method is used. This will exclude development resources such as tests and sample code.

For Development

For development purposes, install from source using the --prefer-source option. This will include development resources such as tests and sample code.

Note: If you need to switch between source and dist installations, you will need to first remove the package using the following command, then reinstall using one of the require commands above.

Configuration

Environment variables are expected to be defined in a PHP file, located at ./vendor/afterpay-global/afterpay-sdk-php/.env.php.

A sample file is provided at ./vendor/afterpay-global/afterpay-sdk-php/sample.env.php - use this file as a template to create your own environment configuration file.

It is possible to configure the SDK without this expected file, by manually setting the configuration options on each of the appropriate classes before using them in your application. As a last resort, the SDK will attempt to load its environment variables from the system with getenv.

Testing

Test with PHPUnit. Ensure you have the appropriate version of PHPUnit installed based on your PHP version.

Each release is verified in the following test environments:

PHP MySQL PHPUnit
5.6 5.6 5
7.0 5.7 6
7.1 5.7 7
7.2 5.7 8
7.3 5.7 9
7.4 8.0 9
8.0 8.0 9
8.1 8.0 9
8.2 8.0 9

However, it is always recommended to also test all software in your own unique environment prior to deploying to production.

Unit Tests

These tests do not require any networking or persistent storage.

Service Tests

These tests assume you have configured a persistent storage provider in your .env.php configuration file. For example, if you provide credentials for a MySQL database, the SDK will verify that it can connect to the database with write access.

Network Tests

These tests will verify that the SDK can communicate with the necessary external services using PHP's native cURL libraries.

Integration Tests

These tests assume you have configured valid Merchant credentials for the Afterpay/Clearpay Online API in your .env.php configuration file. If so, the SDK will verify that it can send requests to the API, and that the API responds as expected.

Usage

Constructing Data Models

All the model classes are available in src/Model. These classes are intended to reflect the data models described in the official online documentation for both Afterpay and Clearpay. By using these model classes to construct HTTP Requests, validity of request format can be verified at runtime.

Sample code is provided in the sample directory:

Making HTTP Requests

Most API endpoints require authentication (with the exception of Ping). You can define your API credentials for your Afterpay/Clearpay merchant account using several different methods. You will also need to specify the ISO 3166-1 alpha-2 two-character country code of the merchant account. The following methods of specifying these details are supported:

  1. Inside your .env.php file, as the merchantId, secretKey and countryCode properties of the $afterpay_sdk_env_config array.
  2. As the MERCHANT_ID, SECRET_KEY and COUNTRY_CODE environment variables.
  3. By manually defining an object of class \Afterpay\SDK\MerchantAccount, passing your account details using its setMerchantId, setSecretKey and setCountryCode methods, then passing this object to the the HTTP Request object using its setMerchantAccount method.

Sample code is provided in the sample directory:

Troubleshooting

How To Retrieve Raw HTTP Logs

All Response objects provide a getRawLog method for returning a raw HTTP log. This is often the most useful data to facilitate an investigation, should a scenario be encountered where the Afterpay API does not behave as expected.

Note: By default, any potentially sensitive information is obfuscated for privacy reasons. It is strongly recommended that this feature is not disabled, unless extraordinary precautions are taken to ensure the raw HTTP logs are not stored for any extended period of time, and destroyed immediately after their intended purpose has been fulfilled.

For example:

Contributing

See CONTRIBUTING.md.


All versions of afterpay-sdk-php 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 afterpay-global/afterpay-sdk-php contains the following files

Loading the files please wait ....