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

Latest commit

 

History

History
67 lines (51 loc) · 2.11 KB

README.md

File metadata and controls

67 lines (51 loc) · 2.11 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.

$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.

$api = new \SatispayOnline\Api();

// Keys
$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;
}