Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Latest commit

 

History

History
79 lines (64 loc) · 2.44 KB

README.md

File metadata and controls

79 lines (64 loc) · 2.44 KB

Satispay Online API PHP SDK

Packagist Version Packagist Downloads

Installation

Run the following command:

composer require satispay/online-api-php-sdk

If you do not wish to use Composer, import the init.php file.

require_once('/path/init.php');

Documentation

https://s3-eu-west-1.amazonaws.com/docs.online.satispay.com/index.html

Authentication

Sign in to your Dashboard at business.satispay.com, click "Negozi Online" in the menu on the left, and then click on "Genera un token di attivazione" to generate an activation token.

Use the activation token with the authenticateWithToken function to generate and exchange a pair of RSA keys.

Save the keys in your database or in a safe place not accesibile from your website.

// Initialize an empty Api
$api = new \SatispayOnline\Api();

// Authenticate and generate the keys
$api->authenticateWithToken("XXXXXX");

// Export the keys
$publicKey = $api->getPublicKey();
$privateKey = $api->getPrivateKey();
$keyId = $api->getKeyId();
$serverPublicKey = $api->getServerPublicKey();

To reuse the keys after authentication, pass them as an argument in the \SatispayOnline\Api constructor.

// Keys variables
$publicKey = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhk...";
$privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBg...";
$keyId = "ldg9sbq283og7ua1abpj989kbbm2g60us6f18c1sciq...";
$serverPublicKey = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhk...";

// Pass keys to Api constructor
$api = new \SatispayOnline\Api([
  "publicKey" => $publicKey,
  "privateKey" => $privateKey,
  "keyId" => $keyId,
  "serverPublicKey" => $serverPublicKey
]);

// Test the authentication
try {
  $api->testAuthentication();
} catch(\Exception $ex) {
  echo $ex->message;
  exit;
}

Enable Sandbox

To enable sandbox pass sandbox with value true as an argument in the \SatispayOnline\Api constructor.

// Pass sandbox = true to Api constructor
$api = new \SatispayOnline\Api([
  "sandbox" => true
  // Other arguments
]);

You can also use the setSandbox function.

$api->setSandbox(true);