1. Go to this page and download the library: Download assur-connect/api-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
assur-connect / api-php example snippets
// API initialization.
$api = new \AssurConnect\Api\AssurConnectApi;
// Use Sandbox environment.
$api->useSandbox();
// Or use Staging environment.
$api->useStaging();
// Authentication.
$clientRequestResource = new \AssurConnect\Api\Resources\Request\Auth\ClientResource(
'9a250da6d-6209-4f91-8b69-1682976a7404',
'test_c7c1d293-7a0b-45b5-8416-b9cff99270da',
'TEST',
'92284041-cca2-453c-a488-bfbc42a8a559',
);
$token = $api->authToken->call($clientRequestResource);
$api->setToken($token);
// Change language.
// $api->setLanguage('fr');
// Get Pricing for BeSafe insurance product.
$pricingRequestResource = new \AssurConnect\Api\Resources\Request\Besafe\PricingResource;
$pricingRequestResource->setDuration(1, 'day');
$pricingRequestResource->setBeneficiariesCount(2);
$pricingRequestResource->addActivity('VTT');
// Add Discount Code.
// $pricingRequestResource->setDiscountCode('MYDISCOUNTCODE');
$pricingResponseResource = $api->besafePricing->call($pricingRequestResource);
var_dump($pricingResponseResource);
/*
object(AssurConnect\Api\Resources\Response\Besafe\PricingResource)#8 (2) {
["price"]=> float(4)
["currency"]=> string(3) "EUR"
}
*/
// Check Subscription information for BeSafe insurance product.
$subscriberEntity = new \AssurConnect\Api\Resources\Request\Besafe\Entities\SubscriberEntity();
$subscriberEntity->setLastname('Eiffel');
$subscriberEntity->setFirstname('Tower');
$subscriberEntity->setAddress('Champ de Mars');
$subscriberEntity->setAdditionalAddress('5 avenue Anatole France');
$subscriberEntity->setZipCode('75007');
$subscriberEntity->setCity('Paris');
$subscriberEntity->setBirthdate('1989-03-31');
$subscriberEntity->setEmail('[email protected]');
$subscriberEntity->setPhone('0892701239');
$subscriptionRequestResource = \AssurConnect\Api\Resources\Request\Besafe\SubscriptionResource::createFromPricingRequestResource($pricingRequestResource, $pricingResponseResource);
$subscriptionRequestResource->setSubscriber($subscriberEntity);
$subscriptionRequestResource->addBeneficiaryFromSubscriber();
$subscriptionRequestResource->addBeneficiary(
'Triomphe', // lastname
'Arc', // firstname
'1986-07-29' // birthDate
);
$subscriptionRequestResource->setEffectiveDate(new DateTime());
// $subscriptionRequestResource->setTransactionReference('TEST_000001');
$subscriptionCheckResponseResource = $api->besafeSubscriptionCheck->call($subscriptionRequestResource);
var_dump($subscriptionCheckResponseResource);
/*
object(AssurConnect\Api\Resources\Response\Besafe\SubscriptionResource)#11 (1) {
["confirmation"]=>
string(23) "Check Integrity Data OK"
}
*/
// Create Subscription information for BeSafe insurance product (be sure to have a valid payment before).
$subscriptionResponseResource = $api->besafeSubscriptionCreate->call($subscriptionRequestResource);
var_dump($subscriptionResponseResource);
/*
object(AssurConnect\Api\Resources\Response\Besafe\SubscriptionResource)#11 (1) {
["confirmation"]=>
string(19) "Subscription saved."
}
*/
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.