PHP code example of laraworld / adyen

1. Go to this page and download the library: Download laraworld/adyen library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

laraworld / adyen example snippets


use Laraworld\Adyen\AdyenClient;
use Laraworld\Adyen\Generated\Checkout\PaymentsApi;

$adyen = app(AdyenClient::class);
$payments = $adyen->api(PaymentsApi::class);

$payments = $adyen->api(PaymentsApi::class, 'checkout');

$adyen = app(AdyenClient::class);

$businessLines = $adyen->businessLines();
$legalEntities = $adyen->legalEntities();
$onboarding = $adyen->hostedOnboarding();
$accountHolders = $adyen->balancePlatformAccountHolders();
$cloudDevice = $adyen->cloudDevice();

$orders = $adyen->orders();
$transfers = $adyen->transfers();
$users = $adyen->usersCompanyLevel();

$checkoutPayments = $adyen->checkoutPayments();
$paymentPayments = $adyen->paymentPayments();
$documentCollector = $adyen->documentCollectorDocuments();

$result = $adyen->transfers()->getAllTransfers(
    createdSince: new DateTimeImmutable('-1 day'),
    createdUntil: new DateTimeImmutable(),
);

$result = $businessLines->getBusinessLine($businessLineId, requestOptions: [
    'headers' => ['X-Custom-Header' => 'value'],
    'idempotencyKey' => $idempotencyKey,
]);

use Laraworld\Adyen\Exceptions\ApiException;

try {
    $result = $adyen->checkoutPayments()->payments($request);
} catch (ApiException $exception) {
    report($exception);

    $status = $exception->statusCode();
    $response = $exception->responseBody();
}

use Laraworld\Adyen\Generated\TerminalApi\Model\MessageCategory;
use Laraworld\Adyen\Generated\TerminalApi\Model\MessageClass;
use Laraworld\Adyen\Generated\TerminalApi\Model\MessageHeader;
use Laraworld\Adyen\Generated\TerminalApi\Model\MessageType;
use Laraworld\Adyen\Generated\TerminalApi\Model\SaleToPOIRequest;
use Laraworld\Adyen\Generated\TerminalApi\Model\TerminalAPIRequest;

$request = new TerminalAPIRequest([
    'saleToPOIRequest' => new SaleToPOIRequest([
        'messageHeader' => new MessageHeader([
            'messageClass' => MessageClass::SERVICE,
            'messageCategory' => MessageCategory::PAYMENT,
            'messageType' => MessageType::REQUEST,
            'serviceID' => $serviceId,
            'saleID' => $saleId,
            'pOIID' => $deviceId,
        ]),
        'paymentRequest' => $paymentRequest,
    ]),
]);

$response = $cloudDevice->sendSyncDeviceMessageRequest(
    $merchantAccount,
    $deviceId,
    $request,
);
bash
php artisan vendor:publish --tag=adyen-config