GithubHelp home page GithubHelp logo

isabella232 / checkout-sdk-php-beta Goto Github PK

View Code? Open in Web Editor NEW

This project forked from checkout/checkout-sdk-php-beta

0.0 0.0 0.0 345 KB

Checkout PHP SDK v2 beta

License: MIT License

PHP 100.00%

checkout-sdk-php-beta's Introduction

Checkout.com PHP SDK beta

This is a temporary development Checkout PHP SDK project that was archived and transferred to the official repository.

build-main GitHub license GitHub release Quality Gate Status

Getting started

Packages and sources are available from Packagist.

Composer

"require": {
    "php": ">=7.4",
    "checkout/checkout-sdk-php-beta": "version"
}

Please check in GitHub releases for all the versions available.

How to use the SDK

This SDK can be used with two different pair of API keys provided by Checkout. However, using different API keys imply using specific API features. Please find in the table below the types of keys that can be used within this SDK.

Account System Public Key (example) Secret Key (example)
default pk_g650ff27-7c42-4ce1-ae90-5691a188ee7b sk_gk3517a8-3z01-45fq-b4bd-4282384b0a64
Four pk_pkhpdtvabcf7hdgpwnbhw7r2uic sk_m73dzypy7cf3gf5d2xr4k7sxo4e

Note: sandbox keys have a test_ or sbox_ identifier, for Default and Four accounts respectively.

PLEASE NEVER SHARE OR PUBLISH YOUR CHECKOUT CREDENTIALS.

If you don't have your own API keys, you can sign up for a test account here.

Default

Default keys client instantiation can be done as follows:

$builder = CheckoutDefaultSdk::staticKeys();
$builder->setPublicKey("public_key");
$builder->setSecretKey("secret_key");
$builder->setEnvironment(Environment::sandbox()); // or production()
$builder->setHttpClientBuilder(); // optional, for a custom HTTP client
$defaultApi = $builder->build();

$paymentsClient = $defaultApi->getPaymentsClient();
$paymentsClient->refundPayment("payment_id");

Four

If your pair of keys matches the Four type, this is how the SDK should be used:

$builder = CheckoutFourSdk::staticKeys();
$builder->setPublicKey("public_key");
$builder->setSecretKey("secret_key");
$builder->setEnvironment(Environment::sandbox()); // or production()
$builder->setHttpClientBuilder(); // optional, for a custom HTTP client
$fourApi = $builder->build();

$paymentsClient = $fourApi->getPaymentsClient();
$paymentsClient->refundPayment("payment_id");

The SDK supports client credentials OAuth, when initialized as follows:

$builder = CheckoutFourSdk::oAuth();
$builder->clientCredentials("client_id", "client_secret");
$builder->scopes([FourOAuthScope::$Files, FourOAuthScope::$Flow]); // array of scopes
$builder->setEnvironment(Environment::sandbox()); // or production()
$builder->setHttpClientBuilder(); // optional, for a custom HTTP client
$fourApi = $builder->build();

$paymentsClient = $fourApi->getPaymentsClient();
$paymentsClient->refundPayment("payment_id");

PHP Settings

For operations that require file upload (Disputes or Marketplace) the configuration extension=fileinfo must be enabled in the php.ini.

Exception handling

All the API responses that do not fall in the 2** status codes will cause a CheckoutApiException. The exception encapsulates the requestId, httpStatusCode and a map of errorDetails, if available.

More documentation related to Checkout API and the SDK is available at:

Building from source

Once you checkout the code from GitHub, the project can be built using composer:

composer update

The execution of integration tests require the following environment variables set in your system:

  • For Default account systems: CHECKOUT_PUBLIC_KEY & CHECKOUT_SECRET_KEY
  • For Four account systems: CHECKOUT_FOUR_PUBLIC_KEY & CHECKOUT_FOUR_SECRET_KEY
  • For Four account systems (OAuth): CHECKOUT_FOUR_OAUTH_CLIENT_ID & CHECKOUT_FOUR_OAUTH_CLIENT_SECRET

Code of Conduct

Please refer to Code of Conduct

Licensing

MIT

checkout-sdk-php-beta's People

Contributors

a-ibarra avatar alegladchteinparser avatar bonafede avatar rsaestrela avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.