judopay / judopay-sdk
SDK for the Judopay API
Requires
- php: >=5.5
- ext-curl: *
- ext-json: *
- ext-openssl: >=0.0.0
- guzzlehttp/guzzle: ~6.0 | ^7.0
- pimple/pimple: ~3.0
- psr/log: ^1.0
Requires (Dev)
- bossa/phpspec2-expect: ~1.0
- phpdocumentor/reflection-docblock: ^2.0
- phpspec/phpspec: ^2.0
- phpunit/phpunit: ^5.0
- squizlabs/php_codesniffer: ^2.0
- symfony/console: ~2.3
- symfony/finder: ~2.1
- symfony/process: ^2.6
- symfony/yaml: ~2.1
- dev-master
- 5.3.0
- 5.2.0
- 5.1.0
- 5.0.0
- 4.6.0
- 4.5.0
- 4.4.0
- 4.3.0
- 4.2.0
- 4.1.0
- 4.0.0
- 3.1.0
- 3.0.0
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.0
- 2.2.0
- 2.1.1
- 2.1.0
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-BE-9039-DeprecatedNotice
- dev-chore/NONE/packagist-symfony-process-vulnerability
- dev-chore/NONE/packagist-phpunit-phpunit-vulnerability
- dev-chore/NONE/bossa-phpspec2-expect-1.x
- dev-chore/DO-2234/remove-sonarscan
- dev-PHPAddressExample-JR-3941
This package is auto-updated.
Last update: 2026-03-24 08:53:37 UTC
README
Deprecated
This SDK has been deprecated and will not receive further updates. For help using the Judopay API from a PHP application see https://docs.judopay.com/migrating-from-php-sdk-to-direct-api-integration
Requirements
In order for the Judo PHP library to work correctly with your development setup, please ensure the following requirements are met:
- PHP 5.5 and above
- Composer
Getting started
1. Integration
Installation of the SDK is implemented via the Composer package manager. Add the judopay package to your composer.json file:
"require": { "judopay/judopay-sdk": "5.0.0" }
And then execute:
$ composer install
Make sure you require the 'vendor/autoload.php' file, so that the Judopay SDK classes are available to your application. For more information on getting started with Composer, see Composer intro.
2. Setup
To start using the SDK, create a new Judopay object with your API credentials:
$judopay = new Judopay( array( 'apiToken' => 'your-token', 'apiSecret' => 'your-secret', 'judoId' => 'your-judo-id' ) );
3. Make a payment
To make a new payment with full card details:
$payment = $judopay->getModel('Payment'); $payment->setAttributeValues( array( 'judoId' => 'your_judo_id', 'yourConsumerReference' => '12345', 'yourPaymentReference' => '12345', 'amount' => 1.01, 'currency' => 'GBP', 'cardNumber' => '4976000000003436', 'expiryDate' => '12/25', 'cv2' => 452 ) );
Note: Please make sure that you are using a unique Consumer Reference for each different consumer, and a unique Payment Reference for each transaction.
Card address details can optionally be included for use in AVS checks as follows, (see full list of parameters here)
$payment = $judopay->getModel('Payment'); $payment->setAttributeValues( array( 'judoId' => 'your_judo_id', 'yourConsumerReference' => '12345', 'yourPaymentReference' => '12345', 'amount' => 1.01, 'currency' => 'GBP', 'cardNumber' => '4976000000003436', 'expiryDate' => '12/25', 'cv2' => 452, 'cardAddress' => array('address1' => '1 Market Street', 'postCode' => 'E20 6PQ', 'countryCode' => 826) ) );
You can check on the required fields and the format of each field in the Judopay REST API reference. To send the request to the API, call:
$response = $payment->create();
4. Check the payment result
If the payment is successful, you'll receive a response array like this (see full response here):
Array ( [receiptId] => 520882 [type] => Payment [createdAt] => 2014-08-18T16:28:39.6164+01:00 [result] => Success ... [amount] => 10.00 ... [yourPaymentReference] => 12345 )
Also important to handle different exceptions in your code. See more details in our error handling section.
try { $response = $payment->create(); if ($response['result'] === 'Success') { echo 'Payment successful'; } else { echo 'There were some problems while processing your payment'; } } catch (JudopayExceptionValidationError $e) { echo $e->getSummary(); } catch (JudopayExceptionApiException $e) { echo $e->getSummary(); } catch (Exception $e) { echo $e->getMessage(); }
Next steps
The Judo PHP SDK supports a range of customization options. For more information on using Judo see our documentation.
License
See the LICENSE file for license rights and limitations (MIT).