1. Go to this page and download the library: Download licensespring/plugin-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/ */
licensespring / plugin-php example snippets
// your script will return JSON string
header('Content-type:application/json');
// ce, if your PHP script is in /php/api/v1/ folder relative to the document root then use: (provided by LicenseSpring platform)
$webhook = new LSWebhook("api_key", "secret_key");
// capture any POST data (should be from your frontend part)
$frontend_payload = file_get_contents('php://input');
// if POST data was not from your frontend or was wrong format, getLicenseKeys() method will throw an exception so be sure to check for that too.
try {
// this will obtain license keys for sent products echo that back to frontend.
echo $webhook->getLicenseKeys($frontend_payload);
} catch (\Exception $e) {
// in this case, just generate and echo a failure response for frontend part of your app.
echo $webhook->generateResponse($success = false, $message = $e->getMessage());
}
// your script will return JSON string
header('Content-type:application/json');
// ce, if your PHP script is in /php/api/v1/ folder relative to the document root then use: (provided by LicenseSpring platform)
$webhook = new LSWebhook("api_key", "secret_key");
// capture any POST data (should be from PayPal only)
$paypal_payload = file_get_contents('php://input');
// if POST data was not from PayPal, generateOrderFromPayPal() method will throw an exception so be sure to check for that too.
try {
// this will "translate" PayPal order data to valid LicenseSpring order data
$ls_order_data = $webhook->generateOrderFromPayPal($paypal_payload);
} catch (Exception $e) {
// in this case, just generate and echo a failure response for frontend part of your app and exit PHP script.
echo $webhook->generateResponseForFrontend($success = false, $message = $e->getMessage());
exit();
}
// this creates order in LicenseSpring platform and returns response.
$response = $webhook->createOrder($ls_order_data);
// return this response to frontend.
echo $response;
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.