Coder Social home page Coder Social logo

adyen / adyen-php-api-library Goto Github PK

View Code? Open in Web Editor NEW
151.0 19.0 102.0 5.12 MB

Adyen API Library for PHP

License: MIT License

PHP 99.79% Shell 0.01% Makefile 0.03% Mustache 0.18%
adyen adyen-api php payments payment-gateway payment-integration payment api-client api-library hacktoberfest

adyen-php-api-library's Introduction

php

Adyen PHP API Library

This is the officially supported PHP library for using Adyen's APIs.

version

Supported API versions

The library supports all APIs under the following services:

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

Supported Webhook versions

The library supports all webhooks under the following model directories:

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.

Prerequisites

Legacy version support

If using PHP versions 7.2 or lower, download our library version 6.3.0.

Installation

You can use Composer. Follow the installation instructions if you do not already have composer installed.

composer require adyen/php-api-library

In your PHP script, make sure you include the autoloader:

require __DIR__ . '/vendor/autoload.php';

Alternatively, you can download the release on GitHub.

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:

$client = new \Adyen\Client();

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

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

// 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/...");

$result = $service->payments($paymentRequest);

General use with API key for live environment

$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

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

...

Instantiating the request objects through the arrayAccess implementation (for easy migration)

...

$service = new \Adyen\Service\Checkout\PaymentLinksApi($client);

$params = array(
    'merchantAccount' => "YourMerchantAccount",
    'reference' => '12345',
    'amount' => array('currency' => "BRL", 'value' => 1250),
    'countryCode' => "BR",
    'shopperReference' => "YourUniqueShopperId",
    'shopperEmail' => "[email protected]",
    '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

...

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

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

Using Management Webhooks

...

$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.

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.

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.

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.

Support

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

For other questions, contact our Support Team.

Licence

This repository is available under the MIT license.

See also

adyen-php-api-library's People

Contributors

acampos1916 avatar adyenautomationbot avatar aleffio avatar alexandrosmor avatar aprasker avatar averias avatar candemiralp avatar cangelis avatar carlosperales95 avatar cyattilakiss avatar dependabot[bot] avatar djoykeabyah avatar fabricioblz avatar georgegg avatar jillingk avatar jocel1 avatar kadobot avatar lancergr avatar michaelpaul avatar msilvagarcia avatar peterojo avatar renovate-bot avatar renovate[bot] avatar rikterbeek avatar rkewlani avatar rvitaliy avatar soarecostin avatar szepeviktor avatar wboereboom avatar wilsonpinto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adyen-php-api-library's Issues

Throwing AdyenException for successful response

PHP version: 7.3
Library version: 6.0.1
Description

Adyen library is throwing the AdyenException for successful api results in transferFunds calls.

See the stacktrace.

Adyen\AdyenException: {"pspReference":"4215852201976584","resultCode":"Received","merchantReference":"RefundFee_4515852201309999"} in /tmp/vendor/adyen/php-api-library/src/Adyen/HttpClient/CurlClient.php:289
Stack trace:
#0 /tmp/vendor/adyen/php-api-library/src/Adyen/HttpClient/CurlClient.php(97): Adyen\HttpClient\CurlClient->handleResultError('{"pspReference"...', Object(Monolog\Logger))
#1 /tmp/vendor/adyen/php-api-library/src/Adyen/Service/AbstractResource.php(83): Adyen\HttpClient\CurlClient->requestJson(Object(Adyen\Service\Fund), 'https://cal-liv...', Array, NULL)
#2 /tmp/vendor/adyen/php-api-library/src/Adyen/Service/Fund.php(113): Adyen\Service\AbstractResource->request(Array)
#3 /var/task/app/Services/Adyen.php(161): Adyen\Service\Fund->transferFunds(Array)

[PW-2782] Testing environment is incompatible with declared support php versions

Hi
i noticed what phpunit/phpunit: 9.1 support php: ^7.3 but this project declare support for php >= 5.3, i suppose that this environment are not covered by tests and that the support must been dropped.

Then, if support for old php version is dropped we can start to upgrade code base to typed properties and return types or this lib must rollback phpunit to support oldest php versions.
I suggest to drop old php versions, but it's code owner decision.

If you tell me how you prefer to move, I can help you solve the problem and prepare a PR.

Facing issue during installation - monolog/monolog 2.0.2

PHP version: PHP 7.2
Library version: ^6.0
Description
Facing issue during installation - monolog/monolog 2.0.2 with Laravel. Package requires a lower version of monolog and laravel is having higher version (conflict with version).

Adyen\AdyenException: Not allowed?!

PHP version: 7.2
Library version: 1.5.4
Description
Im running the example code and getting Adyen\AdyenException: Not allowed.

Under transactions dashboard I can see that the transaction is there with the status "Rejected".

Can anyone help me in this case?! Or is this by design?!

Thank you

Correction code

PHP version: > 5.6.0
Library version: @latest
Description

$client = new \Adyen\Client();
$client->setApplicationName("Adyen PHP Api Library Example");
$client->setUsername("YOUR USERNAME");
$client->setPassword("YOUR PASSWORD");
$client->setEnvironment(\Adyen\Environment::TEST);
//Add namespace to \Adyen
$service = new \Adyen\Service\Payment($client);

$json = '{
"card": {
"number": "4111111111111111",
"expiryMonth": "6",
"expiryYear": "2016",
"cvc": "737",
"holderName": "John Smith"
},
"amount": {
"value": 1500,
"currency": "EUR"
},
"reference": "payment-test",
"merchantAccount": "YOUR MERCHANT ACCOUNT"
}';

$params = json_decode($json, true);

$result = $service->authorise($params);

Adyen\ConfigInterface is missing functions

PHP version: all
Library version: 1.4.0
Description
The interface for the config object is missing, at least, the getEnvironment() function. It should be added if it's required to implement it (a service can't be created without it), an Exception is thrown (which, by the way, says corect instead of correct).

countryCode is required for a DirectoryRequest

The manual states:

"All the fields mentioned in the request example (currencyCode, merchantAccount, paymentAmount, skinCode, merchantReference, sessionValidity and merchantSig), except countryCode, are mandatory."

However, the countryCode in the directoryRequest is set to mandatory. I've fixed it for now by giving it a value of 0, but it would be lovely to just supply the request with the right parameters.

Please supply paymentDetails when using recurring payment library

I am using recurring payment to add customer card on Adyen with the help of given code which is

            $client = new \Adyen\Client();
            $client->setApplicationName("");
            $client->setUsername("");
            $client->setPassword("");
            $client->setEnvironment(\Adyen\Environment::TEST);
             $service = new \Adyen\Service\Payment($client);
             $recurring = array('contract' => \Adyen\Contract::RECURRING);
             $amount = array(
                "value" => 2400,
                "currency"=> "EUR"
             );
             $request = array(
                "selectedRecurringDetailReference" => "LATEST",
                "merchantAccount" => "",
                "amount" => $amount,
                "reference" => "recurring",
                "card" => $data['adyen-encrypted-data'],
                "shopperEmail" => "[email protected]",
                "shopperReference" => "TheShopperreference",
                "recurring" => $recurring['contract'],
                "shopperInteraction" => "ContAuth"
             );
             $result = $service->authorise($request);
             print_r("Payment Result:\n");
             print_r("- pspReference: " . $result['pspReference'] . "\n");
             print_r("- resultCode: " . $result['resultCode']. "\n");
             print_r("- authCode: " . $result['authCode']. "\n");
             print_r("- refusalReason: " . $result['refusalReason']. "\n");

it say's Please supply paymentDetails I am using CSE on client side.

Unable to decrypt data

PHP version: 7.2.24
Library version: 4.2.0
Description
Hi,
I'm facing an "Unable to decrypt data" exception (status 422) while trying to integrate a card payment using secured fields, as described in the documentation:
https://docs.adyen.com/checkout/drop-in-web#step-2-add-drop-in

$paymentData = filter_input(INPUT_POST, 'payment_data');
$paymentMethod = json_decode($paymentData, true);

$result = $service->payments([
    "amount" => array(
      "currency" => "EUR",
      "value" => 1000
    ),
    "reference" => $order_key,
    "paymentMethod" => $paymentMethod['paymentMethod'],
    "returnUrl" => "http://{$_SERVER['HTTP_HOST']}/return.php",
    "merchantAccount" => $merchant_account
  ]);

In addition, the same problem is present testing the api with the api explorer:
https://docs.adyen.com/api-explorer/#/PaymentSetupAndVerificationService/v51/payments__example_payments-card-securedfields

Error code: 174. Unable to decrypt data.

{
  "status": 422,
  "errorCode": "174",
  "message": "Unable to decrypt data",
  "errorType": "validation"
}

Thanks for your support.
Massimo

Util/Util::calculateSha256Signature not valid for HMAC Notification signatures?

PHP version: 7.2.1
Library version: 1.5.0
Description

I'm trying to verify the HMAC signature provided by notifications, and thought I could use the util included in this library for that.

But it looks like that's not valid for notifications, as it uses a different signature format?

In particular, to get the right signature to be calculated, I needed to change these lines:

    // Sort the array by key using SORT_STRING order
    ksort($params, SORT_STRING);

    // Generate the signing data string
    $signData = implode(":", array_map($escapeval, array_merge(array_keys($params), array_values($params))));

To the following to (1) avoid it from messing up the order; in the calling code I'm constructing $params in the field order as defined in the documentation and (2) to not include the parameter key names into the $signData.

    // Sort the array by key using SORT_STRING order
    // Remove: ksort($params, SORT_STRING);

    // Generate the signing data string
    $signData = implode(":", array_map($escapeval, array_values($params)));

Is it expected that this utility can't be used for notifications or is this a bug?

Market Pay Account/Fund ?

Hi there,

If I'm right, the package didn't manage the Market Pay Account/Fund services ?

Is it planned or should I extend the package on my own ?

Thanks in advance !

Idempotency-Key support

PHP version: 7.0
Library version: 3.0.0
Description

  • please add support for the header Idempotency-Key: in the library

How to use it without composer?

Hi,

Would like to know how to use the SDK without composer. Can't find any include.php/autoload.php/includes.php. There is no clear documentation on this either. Please respond.

CurlClient exception handling

In Adyen\HttpClient\CurlClient there are 2 private methods:

  • handleCurlError
  • handleResultError

They both returns the same exception: \Adyen\AdyenException
So there's no way to distinguish connection errors and "api result" errors (i.e that would allow to decide to retry payment or not.)

My proposal is to return two different exceptions:

  • \Adyen\ConnectionExceptionin handleCurlError
  • \Adyen\AdyenException in handleResultError

bug in script

PHP version: 1.4
Library version: 1.4
Description
i create a index.php at root and include vender folder autoload.php in it and when run throw Fatal error: Class 'Service\Payment' not found ,error please suggest me

Adyen - Unable to decrypt data

Am facing an issue as "Unable to decrypt data" when i try to authorize the payment.

I have used CSE method and generated the encrypted form data.

I have referred documentation from below url and send encrypted form value in card.encrypted.json. But am not sure what i am doing wrong. I have updated the username and password details from my WS user details.

http://adyen.github.io/adyen-php-api-library/payment.html
{
"amount": {
"value": 1499,
"currency": "GBP"
},
"reference": "payment-test",
"merchantAccount": "MY_MERCHANT_ACCOUNT",
"additionalData": {
"card.encrypted.json": "MY_ENCRYPTION_DATA"
}
}

CurlClient using incorrect content-type?

PHP version: 7.0.27
Library version: 1.4.1
Description

When trying to call the DirectoryLookup service, I receive the following response:

Invalid Request
Unfortunately we were unable to process this request

Error: Skin null does not exist

(Note: these error messages are not visible on the live platform)

This also happens when i run the DirectoryLookupTest in PHPUnit.

I noticed that in the CurlClient.php class, the cURL request in requestPost() has a Content-Type of application/json.

        //Set the content type to application/json and use the defined userAgent
        $headers = array(
            'Content-Type: application/json',
            'User-Agent: ' . $userAgent
        );

Given that the postfields are being set using http_build_query:

curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));

I believe the Content-Type should be application/x-www-form-urlencoded instead of json. Making this change in CurlClient.php manually fixed the issue for me.

     //Set the content type to application/json and use the defined userAgent
        $headers = array(
            'Content-Type: application/x-www-form-urlencoded',
            'User-Agent: ' . $userAgent
        );

Can you please confirm?
(Note: these tests are skipped by default as no valid skin configuration is set in the repo)

Invalid Card details or other Error codes produce PHP Fatal Error Uncaught exception 'Adyen\AdyenException'

If I create payments using your examples in a AJAX called PHP Script any error Message like "Invalid Card Details" or "request already processed or in progress", etc. will result in an Internal Server Error 500 and produce an PHP Fatal Error Uncaught exception 'Adyen\AdyenException' in php log file.

The specific line is 97 in CurlClient.php: Adyen\HttpClient\CurlClient->handleResultError(.....)

// result not 200 throw error
		if ($httpStatus != 200 && $result) {
			$this->handleResultError($result, $logger); 
		} elseif (!$result) {
			$this->handleCurlError($requestUrl, $errno, $message, $logger);
		}

If I comment "$this->handleResultError($result, $logger); " then I receive the full error JSON and can process the result.

Monolog conflict using 'composer require'

New API looks great, would love to integrate this. However when I try to install via the composer require adyen/php-api-library there seems to be a conflict with the monolog versioning.... It's tiny but annoying, would rather not fork, would it be as simple as updating your composer.json as per this commit from @rikterbeek ?

Here is the error:

composer require adyen/php-api-library
(....processing ..... )

Your requirements could not be resolved to an installable set of packages.

Problem 1
- Can only install one of: monolog/monolog[1.18.0, 1.16.0].
- Can only install one of: monolog/monolog[1.16.0, 1.18.0].
- Can only install one of: monolog/monolog[1.16.0, 1.18.0].
- adyen/php-api-library 1.0.0 requires monolog/monolog 1.16.0 -> satisfiable by monolog/monolog[1.16.0].
- Installation request for adyen/php-api-library ^1.0 -> satisfiable by adyen/php-api-library[1.0.0].
- Installation request for monolog/monolog == 1.18.0.0 -> satisfiable by monolog/monolog[1.18.0].

Installation failed, reverting ./composer.json to its original content.

Composer tries to install the master 1.0.0 branch, so I'm not sure if the #1 which is not yet pushed to the release version will fix this? If so, when would you update to a new release? thank you!

Adyen 010 refused payment

Getting
( [errorType] => security [errorCode] => 010 [message] => Not allowed [pspReference] => 8614834610386710 [status] => 403 )

When trying to pay from : (I set correctly username and password with merchant account)

`$request = array(
"merchantAccount" => "XXXXX",
"amount.currency" => "EUR",
"amount.value" => "1990",
"reference" => "TEST-PAYMENT-" . date("Y-m-d-H:i:s"),
//"shopperIP" => "ShopperIPAddress",
"shopperEmail" => "[email protected]",
"shopperReference" => "12348",
"fraudOffset" => "0",

 	"card.billingAddress.street" => "Simon Carmiggeltstraat",
 	"card.billingAddress.postalCode" => "1011 DJ",
 	"card.billingAddress.city" => "Amsterdam",
 	"card.billingAddress.houseNumberOrName" => "6-50",
 	"card.billingAddress.stateOrProvince" => "",
 	"card.billingAddress.country" => "NL",

 	"card.expiryMonth" => "06",
 	"card.expiryYear" => "2018",
 	"card.holderName" => "John Smith",
 	"card.number" => "4111111111111111",
 	"card.cvc" => "004",
 	);
 
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, "https://pal-test.adyen.com/pal/servlet/Payment/v18/authorise");
 curl_setopt($ch, CURLOPT_HEADER, false); 
 curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC  );
 curl_setopt($ch, CURLOPT_USERPWD, "ws@myCompany:myPassword");   
 curl_setopt($ch, CURLOPT_POST,1);
 curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($request));
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

 $result = curl_exec($ch);
 
 if($result === false)
 	echo "Error: " . curl_error($ch);
 else{
 	/**
	 * If the payment passes validation a risk analysis will be done and, depending on the
	 * outcome, an authorisation will be attempted. You receive a
	 * payment response with the following fields:
	 * - pspReference: The reference we assigned to the payment;
	 * - resultCode: The result of the payment. One of Authorised, Refused or Error;
	 * - authCode: An authorisation code if the payment was successful, or blank otherwise;
	 * - refusalReason: If the payment was refused, the refusal reason.
	 */ 

 	parse_str($result,$result);
 	echo "==== OUTPUT ";
 	print_r(($result));
 }
 
 curl_close($ch);`

Thank you

Keep getting 'Not allowed'

Hi,
I have a small problem, i keep getting this message :

AdyenException in CurlClient.php line 226:
Not allowed

The test payment is listed (with a psp ref) in my adyen.com test account but it's always 'not allowed'

Package update but no version released

We started getting an error on our tests because some public methods have been renamed from client on an update 8 days ago but no version was released for that changes, this is a BC break. We were hoping these changes would be in a 1.5.4, but instead the commit hash for 1.5.3 changed to a different one.

Do you follow semver?

Change: 5d8cad3#diff-abc460192ba028e993913c78030f5e15L231

Problem in screen shots:

image

image

Internal server error 500 using Boleto as payment method

PHP version: 7.2.13
Library version: 1.6.0
Environment: Using Docker for windows
Magento version: 2.3.0
Description

When I use boleto bancario as payment method the request response is:

AdyenLoggerTest.INFO: JSON Response is: {"status":500,"errorCode":"000","message":"HTTP Status Response - Internal server error","errorType":"internal"} {"is_exception":false} []
AdyenLoggerTest.ERROR: 000: HTTP Status Response - Internal server error {"is_exception":false} []

This error only appear inthis payment method, whe I use HPP the payment are processed correctly.

I'm debugging and I find that the error in the response is in this file:

<magento_base_dir>\src\vendor\adyen\php-api-library\src\Adyen\HttpClient\CurlClient.php

On the line 84:

list($result, $httpStatus) = $this->curlRequest($ch);

FYI

AdyenLoggerTest.INFO: Request url to Adyen: https://pal-test.adyen.com/pal/servlet/Payment/v40/authorise {"is_exception":false} []
AdyenLoggerTest.INFO: JSON Request to Adyen:
{
	"merchantAccount":"*****************",
	"shopperReference":"5",
	"shopperEmail":"*****@*******",
	"shopperIP":"******",
	"billingAddress":{
		"street":"Roque Petroni Jr",
		"postalCode":"04787910",
		"city":"Sa\u0303o Paulo",
		"houseNumberOrName":"",
		"stateOrProvince":"SP",
		"country":"BR"
	},
	"deliveryAddress":{
		"street":"Roque Petroni Jr",
		"postalCode":"04787910",
		"city":"Sa\u0303o Paulo",
		"houseNumberOrName":"",
		"stateOrProvince":"SP",
		"country":"BR"
	},
	"amount":{
		"currency":"BRL",
		"value":85779
	},
	"reference":"12000000049",
	"fraudOffset":"0",
	"browserInfo":{
		"userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/72.0.3626.109 Safari\/537.36",
		"acceptHeader":"*\/*"
	},
	"enableOneClick":true,
	"enableRecurring":false,
	"socialSecurityNumber":"56861752509",
	"selectedBrand":"boletobancario_santander",
	"shopperName":{
		"firstName":"Jose\u0301","lastName":"Silva"
	},
	"deliveryDate":"2019-03-01T14:33:08 ",
	"applicationInfo":{
		"adyenLibrary":{
			"name":"adyen-php-api-library",
			"version":"1.6.0"
		},
		"adyenPaymentSource":{
			"version":"3.0.0",
			"name":"adyen-magento2"
		},
		"externalPlatform":{
			"version":"2.3.0",
			"name":"Magento"
		}
	}
} {"is_exception":false} []

Thx.

Cristian

Error when using PreAuth on Terminal API (Cloud Sync)

PHP version: 7.2.24
Library version: 6.0.1
Description
I'm trying to PreAuth with the Terminal API (Cloud Sync https://docs.adyen.com/point-of-sale/pre-authorisation).

From documentation, if we add "authorisationType=PreAuth" to "SaleToAcquirerData" it should work. When we make this Request from Postman or own curl library, it works, but when using this library it does not work.
Debugging code we see that Adyen\Service\AbstractResource changes this field on the method handleApplicationInfoInRequestPOS, it adds:
"applicationInfo":{"adyenLibrary":{"name":"adyen-php-api-library","version":"6.0.1"}} and changes format to base64encoded json (without urlencode!).

Then we receive a NonAuthorized error code.

when try payment with "Pay later with Klarna." using Drop-in method produce PHP Fatal error: Uncaught Adyen\AdyenException: ReflectiveOperationException java.util.List

PHP version: 7.2
Library version: 5.0
Description

When i try to make payment using "Pay later with Klarna" using /payment function then got error like,

Fatal error: Uncaught Adyen\AdyenException: ReflectiveOperationException java.util.List in C:\wamp64\www*******\vendor\adyen\php-api-library\src\Adyen\HttpClient\CurlClient.php on line 279

Is anyone got solution for this error?

Error Class Service\Payment

PHP version => 7.1.20
Library version => "adyen/php-api-library" : "1.5.0"

Hi, I installed the library via composer, and I try to create a payment request on Test with the sample code => but I receive an error : Class 'Service\Payment' not found. What can it be, can someone help me?

$client = new \Adyen\Client();
$client->setApplicationName("Adyen PHP Api Library Example");
$client->setUsername("YOUR USERNAME");
$client->setPassword("YOUR PASSWORD");
$client->setEnvironment(\Adyen\Environment::TEST);
$service = new Service\Payment($client);
$json = '{
"card": {
"number": "4111111111111111",
"expiryMonth": "6",
"expiryYear": "2016",
"cvc": "737",
"holderName": "John Smith"
},
"amount": {
"value": 1500,
"currency": "EUR"
},
"reference": "payment-test",
"merchantAccount": "YOUR MERCHANT ACCOUNT"
}';

$params = json_decode($json, true);
$result = $service->authorise($params);

screen shot 2018-09-21 at 17 23 42

Constant names for directory lookup on Client

PHP version: all
Library version: 1.4.0
Description
A bit of a nitpick, but the constant names for the directory lookup on the Client class are missing the D on ENDPOINT.

ENPOINT_TEST_DIRECTORY_LOOKUP and ENPOINT_LIVE_DIRECTORY_LOOKUP.

Is there any official Omnipay integration?

You can see that Omnipay has a lot of integrations.
https://omnipay.thephpleague.com/gateways/community/

Also it belongs to PHP League, what assures a high-quality code. And it's used by a lot of projects because it is compatible with a lot of payment processors.

But where is the official support for it?
I want to use Adyen with Laravel, and there is no way unless developing all my code, I think it can help Adyen to integrate with more projects as Omnipay is already there.

Support for Adyen MarketPay

Currenly looking at Adyen MarketPay, which seems quite interesting to be able to split incoming payments. However this API seems not to support this yet? Am I missing something, or is it scheduled to be supported?

Could not verify Adyen's SSL certificate.

Hi,

I am getting the following error when i made request on my local to create payments.
Fatal error: Uncaught exception 'Adyen\AdyenException' with message 'Could not verify Adyen's SSL certificate. Please make sure that your network is not intercepting certificates. (Try going to https://pal-test.adyen.com/pal/servlet/Payment/v18/authorise in your browser.) If this problem persists, (Network error [errno 60]: SSL certificate problem: unable to get local issuer certificate)' in C:\xampp\htdocs\test\vendor\adyen\php-api-library\src\Adyen\HttpClient\CurlClient.php:210 Stack trace: #0 C:\xampp\htdocs\test\vendor\adyen\php-api-library\src\Adyen\HttpClient\CurlClient.php(74): Adyen\HttpClient\CurlClient->handleCurlError('https://pal-tes...', 60, 'SSL certificate...', Object(Monolog\Logger)) #1 C:\xampp\htdocs\test\vendor\adyen\php-api-library\src\Adyen\Service\AbstractResource.php(42): Adyen\HttpClient\CurlClient->requestJson(Object(Adyen\Service\Payment), 'https://pal-tes...', Array) #2 C:\xampp\htdocs\test\vendor\adyen\php-api-library\src\Adyen\Service\Payment.php(22): Adyen\Service\AbstractResource->request in C:\xampp\htdocs\test\vendor\adyen\php-api-library\src\Adyen\HttpClient\CurlClient.php on line 210

Here is the code which i am using to create payments

<?php error_reporting(E_ALL);
ini_set('display_errors', 1);
include 'vendor/autoload.php';
if(isset($_POST['adyen-encrypted-data']))
{
	echo 'test';
	$client = new \Adyen\Client();
	$client->setApplicationName("Adyen PHP Api Library Example");
	$client->setUsername("myusername");
	$client->setPassword("mypassword");
	$client->setEnvironment(\Adyen\Environment::TEST);

	$service = new Adyen\Service\Payment($client);

	$json = '{
			  "amount": {
			    "value": 1499,
			    "currency": "GBP"
			  },
			  "reference": "payment-test",
			  "merchantAccount": "mymerchantaccount",
			  "additionalData": {
			    "card.encrypted.json": "'.$_POST["adyen-encrypted-data"].'"
			  }
			}';

	$params = json_decode($json, true);

	$result = $service->authorise($params);
	var_dump($result);
}
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title></title>
	<link rel="stylesheet" href="">
</head>
<body>
<script type="text/javascript" src="https://test.adyen.com/hpp/cse/js/8214937568103526.shtml"></script>
	<form method="POST" action="pay.php" id="adyen-encrypted-form">
	    <input type="text" size="20" data-encrypted-name="number"/>
	    <input type="text" size="20" data-encrypted-name="holderName"/>
	    <input type="text" size="2" data-encrypted-name="expiryMonth"/>
	    <input type="text" size="4" data-encrypted-name="expiryYear"/>
	    <input type="text" size="4" data-encrypted-name="cvc"/>
	    <input type="hidden" value="<?php echo date('Y-m-d').'T'.date('H:i:s', time()).'000Z'; ?>"  data-encrypted-name="generationtime"/>
	    <input type="submit" value="Pay"/>
	</form>
	<script>
	// The form element to encrypt.
	var form = document.getElementById('adyen-encrypted-form');
	// See https://github.com/Adyen/CSE-JS/blob/master/Options.md for details on the options to use.
	var options = {};
	// Bind encryption options to the form.
	adyen.createEncryptedForm(form, options);
	</script>
</body>
</html> 

can you please let me know that what is the issue or i am missing something?

Invalid PayWithGoogle token

PHP version:5.5.9
Library version: 1
Description

  • After go live I got error :Invalid PayWithGoogle token.. Other payment methods working fine.

010 Not allowed error

Hello I receive this error when using your code sample. Can you please advice where the problem might be the web service user I'm using has all the available permissions (see attached). Thank you in advance!
screen shot 2017-04-27 at 2 04 29 pm

Class 'Adyen\PrestaShop not found

PHP version: 17.2
Library version: last
Description
prestashop 1.6.1

sorry for my bad language

it is impossible to use the module for prestashop, after installing the composer I have several errors example line 1
Fatal error: Uncaught Error: Class 'Adyen\PrestaShop\service\Adyen\Helper\DataFactory' not found in modules/adyen/adyen.php:53 Stack trace: #0 [internal function]: Adyen->__construct() #1
so I log in ssh and I notice that in vendor / adyen / there is no prestashop directory as indicated by the error
'Adyen \ PrestaShop \ service \ Adyen \ Helper \ DataFactory', I already have to install more than one issue ever since it's the first time if you can help me

line 53

        $adyenHelperFactory = new \Adyen\PrestaShop\service\Adyen\Helper\DataFactory();
        $this->helper_data = $adyenHelperFactory->createAdyenHelperData(
            \Configuration::get('ADYEN_MODE'),
            _COOKIE_KEY_
        );

Release schedule

Library version: 5.x.x
Description

Can you please share the release schedule so we can plan our releases accordingly as the library already released doesn't meet the official documentation?

No status send in error exception

Error handling api docs says that every error response contains these data:

{
    "errorType" : "security",
    "errorCode" : "901",
    "message" : "Invalid Merchant Account",
    "status" : "403"
}

But in library method that handle this kind of errors (handleResultError in CurlClient) there are forwarded ONLY message and errorCode.

if(isset($decodeResult['message']) && isset($decodeResult['errorCode'])) {
    $logger->error($decodeResult['errorCode'] . ': ' . $decodeResult['message']);
    throw new \Adyen\AdyenException($decodeResult['message'], $decodeResult['errorCode']);
}

It would be a lot easier to handle errors if exceptions throws by "adyen-php-api-library" contains also status field.

Regards
Przemek

Fatal error: Class 'Adyen\TestCase' not found

I am trying to use php library but it giving me error "Fatal error: Class 'Adyen\TestCase' not found" I have tried all version but giving same issue.
I had tried it with xampp and wamp server and also with with live server where I have SSL installed
Please help me to resolve issue
I had tried to install library via composer to but is keep showing same

How to get username and password

I have implemented this code and it's throwing error Fatal error: Uncaught Adyen\AdyenException: Invalid Merchant Account in C:\wamp64\www\xmiu\vendor\adyen\php-api-library\src\Adyen\HttpClient\CurlClient.php on line 279
Adyen\AdyenException: Invalid Merchant Account in C:\wamp64\www\xmiu\vendor\adyen\php-api-library\src\Adyen\HttpClient\CurlClient.php on line 279

Can anyone please tell me from where did I get the username and password.
==> $client->setUsername("YOUR USERNAME");
==> $client->setPassword("YOUR PASSWORD");

API param's names inconsistency

PHP version: 7.2.19
Library version: 3.87.18
Description

$service = new Checkout(...);
$result = $service->payments(...);

This call returns array which contains data section which in turn contains MD, PaReq and TermUrl items. Then in case of RedirectShopper is should make "POST redirect" with that data section as POST params. And later on TermUrl call i will get MD and PaRes. And finally here in callback i should do next:

$service = new Payment(...);
$result = $service->authorise3D($params);

Where is $params contains those MD and PaRes. And in that case i get Configuration Problem mpiImplementation error becuse /authorise3d require md parameter but not MD.
Also it require paResponse but in TermUrl handler i got PaRes. Fortunately (or not) /authorise3d consume both.

P.S. Also if to change API_PAYMENT_VERSION from v40 to v49 (in Adyen\Client) it works well, but in documentation v46 is latest.

Could you keep your code, API and documentation consistent?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.