Sell worldwide, today, with Vatly. Dedicated to EU based SAAS merchants and software companies, accept creditcard, PayPal, ApplePay, iDEAL and more.
You can install the package via composer:
composer require vatly/vatly-api-phpuse Vatly\API\VatlyApiClient;
$vatly = new VatlyApiClient();
$vatly->setApiKey('test_your_api_key_here');
$vatly->checkouts->create([...]);The SDK automatically sends an Idempotency-Key header on every POST and PATCH request.
$checkout = $vatly->checkouts->create([
'products' => [
['id' => 'plan_abc123', 'quantity' => 1],
],
'redirectUrlSuccess' => 'https://yourapp.com/success',
'redirectUrlCanceled' => 'https://yourapp.com/canceled',
]);To set a custom key for the next mutating request, use setIdempotencyKey(). The manual key is cleared after the request is sent.
$vatly->setIdempotencyKey('checkout-create-123');
$checkout = $vatly->checkouts->create([
'products' => [
['id' => 'plan_abc123', 'quantity' => 1],
],
'redirectUrlSuccess' => 'https://yourapp.com/success',
'redirectUrlCanceled' => 'https://yourapp.com/canceled',
]);Some endpoint methods also accept a per-request idempotencyKey option:
$checkout = $vatly->checkouts->create([...], [
'idempotencyKey' => 'checkout-create-123',
]);
$subscription = $vatly->subscriptions->update('subscription_123', [
'quantity' => 2,
], [
'idempotencyKey' => 'subscription-update-123',
]);You can replace or disable the automatic generator when needed:
$vatly->setIdempotencyKeyGenerator(new MyIdempotencyKeyGenerator());
$vatly->clearIdempotencyKeyGenerator();composer testPlease see CHANGELOG for more information on what has changed recently.
Send in a Pull Request if you'd like to contribute to this package.
In case of a security vulnerability, please shoot us an email at security@vatly.com.
The MIT License (MIT). Please see License File for more information.