vatly/vatly-api-php

Vatly API client for PHP

Maintainers

Package info

github.com/Vatly/vatly-api-php

Homepage

Issues

pkg:composer/vatly/vatly-api-php

Statistics

Installs: 200

Dependents: 1

Suggesters: 0

Stars: 1


README

Latest Version on Packagist Tests Total Downloads

Sell worldwide, today, with Vatly. Dedicated to EU based SAAS merchants and software companies, accept creditcard, PayPal, ApplePay, iDEAL and more.

Installation

You can install the package via composer:

composer require vatly/vatly-api-php

Usage

use Vatly\API\VatlyApiClient;

$vatly = new VatlyApiClient();
$vatly->setApiKey('test_your_api_key_here');

$vatly->checkouts->create([...]);

Idempotency

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();

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Send in a Pull Request if you'd like to contribute to this package.

Security Vulnerabilities

In case of a security vulnerability, please shoot us an email at security@vatly.com.

Credits

License

The MIT License (MIT). Please see License File for more information.