LicenseSpring-PayPal 与 PHP 后端的集成。

v1.0.1 2019-09-11 12:23 UTC

This package is not auto-updated.

Last update: 2024-09-20 12:23:10 UTC


README

LicenseSpring-PayPal 与 PHP 后端的集成。

安装

composer require licensespring/paypal

注意

此包用于通过 LicenseSpring JS 库使用 LicenseSpring 进行 PayPal 集成。您可以在以下示例中查看: https://github.com/sean-censedata/LicenseSpring-PayPal-Integration-example

用法

从 LicenseSpring 平台获取许可证密钥

创建此 PHP 脚本,例如命名为 php/api/licensespring/acquire-licenses.php。当使用 LicenseSpring JS 库时,您需要在前端使用此路径。

<?php
// your script will return JSON string
header("Content-type:application/json");

// require autoload.php.
// set path differently if your PHP script doesn't reside three levels deep.
// for instance, if your PHP script is in /api/ folder relative to the document root then use: require_once '../vendor/autoload.php';
require_once "../../../vendor/autoload.php";

// initialize new LSWebhook object and give it your UUID and your Shared key (provided by LicenseSpring platform)
$webhook = new LicenseSpring\Webhook("insert-your-UUID-here", "insert-your-shared-key-here");

// capture any POST data (should be from your frontend part)
$frontend_payload = file_get_contents("php://input");

// this obtains license keys from LicenseSpring platform and returns response to frontend.
echo $webhook->acquireLicenses($frontend_payload);

在 LicenseSpring 平台上创建订单

创建此 PHP 脚本,例如命名为 php/api/licensespring/create-order.php。当使用 LicenseSpring JS 库时,您需要在前端使用此路径。

<?php
// your script will return JSON string
header("Content-type:application/json");

// require autoload.php.
// set path differently if your PHP script doesn't reside three levels deep.
// for instance, if your PHP script is in /api/ folder relative to the document root then use: require_once '../vendor/autoload.php';
require_once "../../../vendor/autoload.php";

// initialize new LSWebhook object and give it your UUID and your Shared key (provided by LicenseSpring platform)
$webhook = new LicenseSpring\Webhook("insert-your-UUID-here", "insert-your-shared-key-here");

// capture any POST data (should be from your frontend part)
$frontend_payload = file_get_contents("php://input");

// this creates order in LicenseSpring platform and returns response to frontend.
echo $webhook->createOrder($frontend_payload);