paydemic-php
Paydemic.com API for PHP, (*1)
Installation
composer require paydemic/paydemic-php-sdk, (*2)
API Overview
Every resource is accessed via your paydemic instance:, (*3)
$paydemic = new PaydemicPhpSdk('<accessKey>', '<secretAccessKey>')
$paydemic->{ RESOURCE_NAME }->{ METHOD_NAME }
Every resource method returns an instance of PromiseInterface (https://promisesaplus.com/),
so you don't have to use the regular callback. E.g.
, (*4)
// Create a new purchase link:
$finalUrl = "https://paywalledsite.com/paid-access-article";
$title = "My paid access article title";
$currencyCode = "USD";
$price = 4.0;
$description = "Extra information";
$paydemic->PurchaseLinks->create(
$finalUrl,
$title,
$currencyCode,
$price,
$description
)->then(
// on success
function ($purchaseLink) { /* some code */ },
// on exception
function ($exception) { /* some error handling code */ },
)
There is also a wait() method which just waits for the Promise to complete and returns the result:, (*5)
// Create a new purchase link:
$purchaseLink = $paydemic->PurchaseLinks->create(
$finalUrl,
$title,
$currencyCode,
$price
)->wait();
, (*6)
// Retrieve an existing purchase link:
$retrieved = $paydemc->PurchaseLinks->retrieve($purchaseLink['id'])->wait();
, (*7)
// List all the existing purchase links under this project:
$listed = $paydemic->PurchaseLinks->listAll()->wait();
, (*8)
// Update an existing purchase link:
$finalUrlUpdate = $finalUrl . '#updated';
$titleUpdate = $title . ' UPDATED';
$priceUpdate = 6.0;
$descriptionUpdate = $description . ' UPDATED';
$updated = $paydemic->PurchaseLinks->update(
$purchaseLink['id'],
$finalUrlUpdate,
$titleUpdate,
$currencyCode,
$priceUpdate,
$descriptionUpdate
)->wait();
, (*9)
// Delete an existing purchase link:
$paydemic->PurchaseLinks->delete($purchaseLink['id'])->wait();
Available resources & methods
Development
Run tests locally
composer install
composer test
composer build
After it finishes, have a look in the build folder., (*10)
Contribution
- If you would like to contribute, please fork the repo and send in a pull request.