2017 © Pedro Peláez
 

library php-api-library

A PHP client library for accessing Adyen APIs

image

adyen/php-api-library

A PHP client library for accessing Adyen APIs

  • Friday, July 6, 2018
  • by rikterbeek
  • Repository
  • 14 Watchers
  • 37 Stars
  • 304,797 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 24 Forks
  • 1 Open issues
  • 24 Versions
  • 16 % Grown

The README.md

php, (*1)

Adyen PHP API Library

This is the officially supported PHP library for using Adyen's APIs., (*2)

version, (*3)

Supported API versions

The library supports all APIs under the following services:, (*4)

API Description Service Name Supported version
BIN Lookup API The BIN Lookup API provides endpoints for retrieving information based on a given BIN. Binlookup v54
Capital API Adyen Capital allows you to build an embedded financing offering for your users to serve their operational needs. Capital v3
Checkout API Adyen Checkout API provides a simple and flexible way to initiate and authorise online payments. You can use the same integration for payments made with cards (including 3D Secure), mobile wallets, and local payment methods (for example, iDEAL and Sofort). Checkout v71
Configuration API The Configuration API enables you to create a platform where you can onboard your users as account holders and create balance accounts, cards, and business accounts. BalancePlatform v2
DataProtection API Adyen Data Protection API provides a way for you to process Subject Erasure Requests as mandated in GDPR. Use our API to submit a request to delete shopper's data, including payment details and other related information (for example, delivery address or shopper email) DataProtection v1
Management API Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. Management v3
Payments API A set of API endpoints that allow you to initiate, settle, and modify payments on the Adyen payments platform. You can use the API to accept card payments (including One-Click and 3D Secure), bank transfers, ewallets, and many other payment methods. Payments v68
Recurring API The Recurring APIs allow you to manage and remove your tokens or saved payment details. Tokens should be created with validation during a payment request. Recurring v68
Payouts API A set of API endpoints that allow you to store payout details, confirm, or decline a payout. Payout v68
BinLookup API Endpoints for retrieving information, such as cost estimates, and 3D Secure supported version based on a given BIN. Current supported version BinLookup v54
Stored Value API Manage both online and point-of-sale gift cards and other stored-value cards. StoredValue v46
Legal Entity Management API The Legal Entity Management API enables you to manage legal entities that contain information required for verification LegalEntityManagement v3
Transfers API The Transfers API provides endpoints that you can use to get information about all your transactions, move funds within your balance platform or send funds from your balance platform to a transfer instrument. Transfers v4
Balance Control API The Balance Control API lets you transfer funds between merchant accounts that belong to the same legal entity and are under the same company account. BalanceControl v1
Hosted Onboarding API The Hosted onboarding API provides endpoints that you can use to generate links to Adyen-hosted pages, such as an onboarding page or a PCI compliance questionnaire. You can provide these links to your account holders so that they can complete their onboarding. HostedOnboardingPages v1
Account API The Account API provides endpoints for managing account-related entities on your platform. These related entities include account holders, accounts, bank accounts, shareholders, and verification-related documents. The management operations include actions such as creation, retrieval, updating, and deletion of them. Account v5
Fund API The Fund API provides endpoints for managing the funds in the accounts on your platform. These management operations include, for example, the transfer of funds from one account to another, the payout of funds to an account holder, and the retrieval of balances in an account. Fund v5
Terminal API (Cloud communications) Our point-of-sale integration. Cloud-based Terminal API Cloud-based Terminal API |
Terminal API (Local communications) Our point-of-sale integration. Local-based Terminal API Local-based Terminal API |
POS Terminal Management API This API provides endpoints for managing your point-of-sale (POS) payment terminals. You can use the API to obtain information about a specific terminal, retrieve overviews of your terminals and stores, and assign terminals to a merchant account or store. POSTerminalManagement v1
Disputes API You can use the Disputes API to automate the dispute handling process so that you can respond to disputes and chargebacks as soon as they are initiated. The Disputes API lets you retrieve defense reasons, supply and delete defense documents, and accept or defend disputes. Disputes v30
POS Mobile API The POS Mobile API is used in the mutual authentication flow between an Adyen Android or iOS POS Mobile SDK and the Adyen payments platform. The POS Mobile SDK for Android or iOS devices enables businesses to accept in-person payments using a commercial off-the-shelf (COTS) device like a phone. For example, Tap to Pay transactions, or transactions on a mobile device in combination with a card reader POS Mobile v68
Payments App API The Payments App API is used to Board and manage the Adyen Payments App on your Android mobile devices. PaymentsAppApi v1

Supported Webhook versions

The library supports all webhooks under the following model directories:, (*5)

Webhooks Description Model Name Supported Version
Authentication Webhooks Adyen sends this webhook when the process of cardholder authentication is finalized, whether it is completed successfully, fails, or expires. AcsWebhooks v1
Configuration Webhooks You can use these webhooks to build your implementation. For example, you can use this information to update internal statuses when the status of a capability is changed. ConfigurationWebhooks v2
Transfer Webhooks You can use these webhooks to build your implementation. For example, you can use this information to update balances in your own dashboards or to keep track of incoming funds. TransferWebhooks v4
Transaction Webhooks Adyen sends webhooks to inform your system about incoming and outgoing transfers in your platform. You can use these webhooks to build your implementation. For example, you can use this information to update balances in your own dashboards or to keep track of incoming funds. TransactionWebhooks v4
Report Webhooks You can download reports programmatically by making an HTTP GET request, or manually from your Balance Platform Customer Area ReportWebhooks v1
Management Webhooks Adyen uses webhooks to inform your system about events that happen with your Adyen company and merchant accounts, stores, payment terminals, and payment methods when using Management API. ManagementWebhooks v3
Notification Webhooks We use webhooks to send you updates about payment status updates, newly available reports, and other events that you can subscribe to. For more information, refer to our documentation Notification v1

For more information, refer to our documentation or the API Explorer., (*6)

Prerequisites

Legacy version support

If using PHP versions 7.2 or lower, download our library version 6.3.0., (*7)

Installation

You can use Composer. Follow the installation instructions if you do not already have composer installed., (*8)

~~~~ bash composer require adyen/php-api-library, (*9)


In your PHP script, make sure you include the autoloader: ~~~~ php require __DIR__ . '/vendor/autoload.php';

Alternatively, you can download the release on GitHub., (*10)

Using the library

General use with API key

Set up the client as a singleton resource; you'll use it for the API calls that you make to Adyen:, (*11)

~~~~ php, (*12)

$client = new \Adyen\Client();, (*13)

$client->setXApiKey("YOUR API KEY"); $client->setEnvironment(\Adyen\Environment::TEST); $client->setTimeout(30);, (*14)

$service = new \Adyen\Service\Checkout\PaymentsApi($client);, (*15)

// Create PaymentMethod object $paymentMethod = new \Adyen\Model\Checkout\CheckoutPaymentMethod(); $paymentMethod ->setType("scheme") ->setEncryptedBankAccountNumber("test_4111111111111111") ->setEncryptedExpiryMonth("test_03") ->setEncryptedExpiryYear("test_2030") ->setEncryptedSecurityCode("test_737"); // Creating Amount Object $amount = new \Adyen\Model\Checkout\Amount(); $amount ->setValue(1500) ->setCurrency("EUR"); // Create the actual Payments Request $paymentRequest = new \Adyen\Model\Checkout\PaymentRequest(); $paymentRequest ->setMerchantAccount("YOUR MERCHANT ACCOUNT") ->setPaymentMethod($paymentMethod) ->setAmount($amount) ->setReference("payment-test") ->setReturnUrl("https://your-company.com/...");, (*16)

$result = $service->payments($paymentRequest);, (*17)


### General use with API key for live environment ~~~~ php $client = new \Adyen\Client(); $client->setXApiKey("YOUR API KEY"); $client->setEnvironment(\Adyen\Environment::LIVE, 'Your live URL prefix'); $client->setTimeout(30); ...

General use with basic auth

~~~~ php $client = new \Adyen\Client(); $client->setUsername("YOUR USERNAME"); $client->setPassword("YOUR PASSWORD"); $client->setEnvironment(\Adyen\Environment::TEST); $client->setTimeout(30);, (*18)

..., (*19)


### Instantiating the request objects through the arrayAccess implementation (for easy migration) ~~~~ php ... $service = new \Adyen\Service\Checkout\PaymentLinksApi($client); $params = array( 'merchantAccount' => "YourMerchantAccount", 'reference' => '12345', 'amount' => array('currency' => "BRL", 'value' => 1250), 'countryCode' => "BR", 'shopperReference' => "YourUniqueShopperId", 'shopperEmail' => "test@email.com", 'shopperLocale' => "pt_BR", 'billingAddress' => array(...), 'deliveryAddress' => array(...), ); $createPaymentLinkRequest = new \Adyen\Model\Checkout\PaymentLinkRequest($params); $result = $service->paymentLinks($createPaymentLinkRequest); $paymentLink = $result->getUrl(); // or use $result['url'] if you want to use arrayAccess

Using Banking Webhooks

~~~~ php ..., (*20)

$jsonString = 'webhook_payload'; $isValid = $hmac->validateHMAC("YOUR_HMAC_KEY", "YOUR_HMAC_SIGN", $jsonString);, (*21)

if ($isValid) { $webhookParser = new \Adyen\Service\BankingWebhookParser($jsonString); $result = $webhookParser->getGenericWebhook(); }, (*22)

### Using Management Webhooks
~~~~ php
...

$jsonString = 'webhook_payload';
$isValid = $hmac->validateHMAC("YOUR_HMAC_KEY", "YOUR_HMAC_SIGN", $jsonString);

if ($isValid) {
    $webhookParser = new \Adyen\Service\ManagementWebhookParser($jsonString);
    $result = $webhookParser->getGenericWebhook();
}

Example integration

For a closer look at how our PHP library works, clone our Laravel example integration. This includes commented code, highlighting key features and concepts, and examples of API calls that can be made using the library., (*23)

Running the tests

For the test cases you need the PCI permission enabled on you account. There are no test cases for CSE because credit card data is encrypted through our javascript library. By default the test will then be skipped. If you have these permissions fill in your account details in the config/test.ini file to let the test work. To make the automatic testing cases work for your account change the credentials in the config/test.ini file., (*24)

Feedback

We value your input! Help us enhance our API Libraries and improve the integration experience by providing your feedback. Please take a moment to fill out our feedback form to share your thoughts, suggestions or ideas., (*25)

Contributing

We encourage you to contribute to this repository, so everyone can benefit from new features, bug fixes, and any other improvements. Have a look at our contributing guidelines to find out how to raise a pull request., (*26)

Support

If you have a feature request, or spotted a bug or a technical problem, create an issue here., (*27)

For other questions, contact our Support Team., (*28)

Licence

This repository is available under the MIT license., (*29)

See also

The Versions

06/07 2018

dev-master

9999999-dev https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

06/07 2018

1.5.0

1.5.0.0 https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

05/07 2018

dev-develop

dev-develop https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

04/07 2018

dev-removeRequiredFields

dev-removeRequiredFields https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

04/07 2018

dev-terminal_apitimeout

dev-terminal_apitimeout https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

25/06 2018

dev-paymentsession_result

dev-paymentsession_result https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

18/06 2018

dev-PW-448

dev-PW-448 https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

09/05 2018

dev-PW-241

dev-PW-241 https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

30/04 2018

dev-terminalApiCloud

dev-terminalApiCloud https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

14/02 2018

1.4.2

1.4.2.0 https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

13/02 2018

dev-directorylookup-fix

dev-directorylookup-fix https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

08/02 2018

1.4.1

1.4.1.0 https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

08/01 2018

dev-fix-issue-40

dev-fix-issue-40 https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

21/12 2017

dev-packH-check

dev-packH-check https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

03/11 2017

dev-minor-fixes

dev-minor-fixes https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

27/10 2017

dev-github-templates

dev-github-templates https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

23/10 2017

1.4.0

1.4.0.0 https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

23/10 2017

dev-add-recurring-version

dev-add-recurring-version https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

07/08 2017

1.3.0

1.3.0.0 https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

07/08 2017

dev-develop-rik

dev-develop-rik https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

25/11 2016

1.2.0

1.2.0.0 https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

26/10 2016

1.1.0

1.1.0.0 https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

07/03 2016

1.0.1

1.0.1.0 https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen

09/02 2016

1.0.0

1.0.0.0 https://github.com/Adyen/adyen-php-api-library

A PHP client library for accessing Adyen APIs

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

adyen