Skip to content
Checkout SDK for PHP
Branch: master
Clone or download
Latest commit 2260afb Mar 5, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Intial commit Jan 31, 2019
src Close #89 Mar 5, 2019
tests Support to custom configuration. Mar 1, 2019
.editorconfig
.gitignore
LICENSE
README.md Fixed composer package name Feb 23, 2019
checkout.php Intial commit Jan 31, 2019
composer.json
phpunit.xml Intial commit Jan 31, 2019

README.md

The Checkout SDK for PHP enables developers to easily work with Checkout.com APIs. It requires PHP 5.6.

Getting Help

If you encounter a bug with Checkout SDK for PHP please search the existing issues and try to make sure your problem doesn’t already exist before opening a new issue. The GitHub issues are intended for bug reports and feature requests. For help and questions with using Checkout SDK for PHP please contact our integration support team.

For full usage details, see the Wiki.

Installation

Installation with Composer (Recommended)

Either run the following command in the root directory of your project:

composer require checkout/checkout-sdk-php

Or require the Checkout.com package inside the composer.json file of your project:

"require": { "php": ">=5.6", "checkout/checkout-sdk-php": "1.0.0"}.

Clone repository

Alternatively you can clone the repository from GitHub with git clone

git clone git@github.com:checkout/checkout-sdk-php.git

Quickstart

Include a checkout-sdk-php/checkout.php to access the operations for each API:

use Checkout\CheckoutApi;
use Checkout\Models\Tokens\Card;
use Checkout\Models\Payments\TokenSource;
use Checkout\Models\Payments\Payment;

// Set the secret key
$secretKey = 'sk_test_key';

// Initialize the Checkout API
$checkout = new CheckoutApi($secretKey);


// Create a Card token
$card = new Card('4242424242424242', 12, 2020);
$card->cvv = 100;
$token = $checkout->tokens()->request($card);


// Create a payment method instance with card details
$method = new TokenSource($token->getId());

// Prepare the payment parameters
$payment = new Payment($method, 'GBP');
$payment->amount = 1000; // = 10.00

// Send the request and retrieve the response
$response = $checkout->payments()->request($payment);

Tests

Install PHPUnit by running composer require --dev phpunit/phpunit and execute the tests with ./vendor/bin/phpunit.

You can’t perform that action at this time.