Easy step-by-step
PREREQUISITE: Obtain your API credentials (5 mins to 10 mins)
- Already a client? You should have received an email "API Credentials - Start integrating your solution now!"
- Not yet a client? You can test SlimPay integration into your system by generating random API credentials here.
- Download our official PHP client here and unzip the file (without any extra folder on top) (5 mins)
- Place the client folder onto your website HTTP server (5 mins)
- Create a new PHP page that will appear when you request the payment (5 mins) Example: Your page has a button "Sign" or "Pay". It redirects to a new page "slimpay.php"
- Insert the following code snippet in this new page (10 mins)
Do not forget to update the credentials with your values in the below code<?php // Instructions: https://github.com/SlimPay/hapiclient-php require_once 'vendor/autoload.php'; use \HapiClient\Http; use \HapiClient\Hal; // The HAPI Client $hapiClient = new Http\HapiClient( 'https://api.preprod.slimpay.com', '/', 'https://api.slimpay.net/alps/v1', new Http\Auth\Oauth2BasicAuthentication( '/oauth/token', 'yourAppID', 'yourAppSecret' ) ); // The Relations Namespace $relNs = 'https://api.slimpay.net/alps#'; // Follow create-orders $rel = new Hal\CustomRel($relNs . 'create-orders'); $follow = new Http\Follow($rel, 'POST', null, new Http\JsonBody( [ 'started' => true, 'creditor' => [ 'reference' => 'yourCreditorReference' ], 'subscriber' => [ 'reference' => 'theSubscriberReference' ], 'items' => [ [ 'type' => 'signMandate', 'autoGenReference' => true, 'mandate' => [ 'signatory' => [ 'billingAddress' => [ 'street1' => '27 rue des fleurs', 'street2' => 'Bat 2', 'city' => 'Paris', 'postalCode' => '75008', 'country' => 'FR' ], 'honorificPrefix' => 'Mr', 'familyName' => 'Doe', 'givenName' => 'John', 'email' => 'change.me@slimpay.com', 'telephone' => '+33612345678' ], 'standard' => 'SEPA' ] ] ] ] )); $res = $hapiClient->sendFollow($follow); $url = $res->getLink('https://api.slimpay.net/alps#user-approval')->getHref(); header('Location:' . $url); exit; ?>
<?php // Instructions: https://github.com/SlimPay/hapiclient-php require_once 'vendor/autoload.php'; use \HapiClient\Http; use \HapiClient\Hal; // The HAPI Client $hapiClient = new Http\HapiClient( 'https://api.preprod.slimpay.com', '/', 'https://api.slimpay.net/alps/v1', new Http\Auth\Oauth2BasicAuthentication( '/oauth/token', 'yourAppID', 'yourAppSecret' ) ); // The Relations Namespace $relNs = 'https://api.slimpay.net/alps#'; // Follow create-orders $rel = new Hal\CustomRel($relNs . 'create-orders'); $follow = new Http\Follow($rel, 'POST', null, new Http\JsonBody( [ 'started' => true, 'creditor' => [ 'reference' => 'yourCreditorReference' ], 'subscriber' => [ 'reference' => 'testphpclient01' ], 'items' => [ [ 'type' => 'signMandate', 'autoGenReference' => true, 'mandate' => [ 'signatory' => [ 'billingAddress' => [ 'street1' => '27 rue des fleurs', 'street2' => 'Bat 2', 'city' => 'Paris', 'postalCode' => '75008', 'country' => 'FR' ], 'honorificPrefix' => 'Mr', 'familyName' => 'Doe', 'givenName' => 'John', 'email' => 'change.me@slimpay.com', 'telephone' => '+33612345678' ], 'standard' => 'SEPA' ], [ 'type' => 'payment', 'action' => 'create', 'payin' =>[ 'amount' => '29.99', 'scheme' => null, 'reference' => null, 'label' => 'First payment for your subscription', 'executionDate' => null ] ] ] ] ] )); $res = $hapiClient->sendFollow($follow); $url = $res->getLink('https://api.slimpay.net/alps#user-approval')->getHref(); header('Location:' . $url); exit; ?>
- Test the flow by accessing your website (5 mins)
Next Step
Now that SlimPay is integrated, you need to replace default values with your own values (example: firstName, givenName, address...).
Here is a sample:
'honorificPrefix' => $title,
'familyName' => $family_name,
'givenName' => $given_name,
'email' => $client_email,
Ensure that the following attributes are always filled so that SlimPay can sign a mandate (and debit your client):
'Creditor {reference}'
'Subscriber {reference}'
'Street1'
'City'
'PostalCode'
'Country'
'HonoricPrefix'
'FamilyName'
'GivenName'