bigfish/delivery-gateway-php-sdk

BIG FISH Delivery Gateway PHP SDK

0.0.3 2024-04-16 07:53 UTC

This package is auto-updated.

Last update: 2024-10-16 09:07:23 UTC


README

Installation

composer require bigfish/delivery-gateway-php-sdk

Examples

// Using predefined variables $currency, $user and $address.

$client = Client::make(
    Config::make('<MERCHANT-ID>', '<ACCESS-TOKEN>')
        ->useSandbox()
);

$input = DTO\Session\Create::make()
    ->setCurrency(Enums\CurrencyEnum::make($currency))
    ->setCustomer(
        DTO\Session\Create\Customer::make()
            ->setReferenceId($user->id)
            ->setAddresses([
                DTO\Session\Create\Address::make()
                    ->setReferenceId($address->id)
                    ->setRecipient(
                        DTO\Recipient::make()
                            ->setFirstName($user->firstName)
                            ->setLastName($user->lastName)
                            ->setLanguage(Enums\LanguageEnum::make($user->language))
                    )
                    ->setAddress(
                        DTO\Address::make()
                            ->setCountry(Enums\CountryEnum::make($address->country))
                            ->setPostalCode($address->postalCode)
                            ->setCity($address->city)
                            ->setAddressLine1($address->addressLine1)
                    )
            ])
    )
    ->setPickupPoint(
        DTO\Session\Create\PickupPoint::make()
            ->setEnabled(true)
            ->setProviders([
                DTO\Session\Create\PickupPoint\Provider::make()
                    ->setProvider(Enums\ProviderEnum::make('GLS')),
            ])
    );

$session = $client->createSession($input);

// Pass $session->id to frontend SDK.