You can sign up for an Oyst account at https://backoffice.oyst.com.
Add the repository
"repositories": [
{
"type": "vcs",
"url": "https://github.com/oystparis/oyst-php"
}
]
Then run the composer installer: composer require oyst/oyst-php
To use the bindings, use Composer's autoload:
require_once('vendor/autoload.php');
You can download the latest release. Then, run the composer install: composer install --no-dev
to install dependencies.
Then, to use the bindings, include the autoload.php
file.
require_once('vendor/autoload.php');
Simple usage looks like:
$userAgent = new \Oyst\Classes\OystUserAgent('MY_WEBSITE_NAME', 'MY_PACKAGE_VERSION', 'MY_PLATFORM_VERSION');
$oystClient = new \Oyst\Api\OystApiClientFactory::getClient('oneclick', 'eFcaDouev63YVsJ3wM2ovY7ewCwrQMLHaw4tWHxXQT7cmErWKkZU4pTRt6npwb8p', $userAgent);
$notification = new \Oyst\Classes\OneClickNotifications();
$notification->setUrl('https://1click-demo.sandbox.oyst.eu/notification.php');
// 1-click order
$price = new \Oyst\Classes\OystPrice(42, 'EUR');
$oystProduct = new \Oyst\Classes\OystProduct('rubikscube', 'Rubiks Cube 3x3', $price, 1);
$oystClient->authorizeOrderV2(array($oystProduct), $notification);
The class OystApiClientFactory
is used to get the right client to communicate with the API.
Note: It would be interesting to process it the right way with an abstract method called by the parent like process() which is called by a public method access such as exec() or start() for example.
/** @var AbstractOystApiClient $apiWrapper */
$apiWrapper = OystApiClientFactory::getClient($entityName, $apiKey, OystUserAgent $userAgent, $environment, $url);
This method take several parameters as:
-
entityName (constants available in
Oyst\Api\OystApiClientFactory
), could be:- catalog
- oneclick
- order
- payment
-
apiKey
- The API key is the key that was given to you by Oyst (if you don't have one you can go to the https://backoffice.oyst.com and create an account).
-
userAgent
- To know the origin of the request (PrestaShop / Magento / WooComerce / Elsewhere...).
You have have to instantiate a new
Oyst\Classes\OystUserAgent
, the constructor will show you needed info, and pass it togetClient
.
- To know the origin of the request (PrestaShop / Magento / WooComerce / Elsewhere...).
You have have to instantiate a new
-
environment (Optional, by default prod ; constants available in
Oyst\Api\OystApiClientFactory
), takes two values:- sandbox
- prod
-
url (Optional)
- The custom URL with which the APIs are to be called (if you don't want to use the default one set for the environment)
Please see https://one-click-api.readme.io for up-to-date documentation.
Moreover you can see the content of DSL files description_[entityName].json to know in details the payload for each API. Theses files use Guzzle Service Description.
Install dependencies: composer install
Install dependencies as mentioned above (which will resolve PHPUnit), then you can run the test suite:
To run unit tests:
./vendor/bin/phpunit -c phpunit.xml.dist --testsuite unitary
./vendor/bin/phpunit -c phpunit.xml.dist --testsuite functional
For functional
tests, copy src/Config/parameters_api.sample.yml
as src/Config/parameters_api.yml
and fill apiKey
.