paydemic/paydemic-php-sdk

PHP SDK for Paydemic.com REST API.

1.1.0 2018-09-24 20:07 UTC

This package is not auto-updated.

Last update: 2020-11-17 08:51:06 UTC


README

Paydemic.com API for PHP

Installation

composer require paydemic/paydemic-php-sdk

API Overview

Every resource is accessed via your paydemic instance:

$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.

// 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:

// Create a new purchase link:
$purchaseLink = $paydemic->PurchaseLinks->create(
    $finalUrl,
    $title,
    $currencyCode,
    $price
)->wait();

// Retrieve an existing purchase link:
$retrieved = $paydemc->PurchaseLinks->retrieve($purchaseLink['id'])->wait();

// List all the existing purchase links under this project:
$listed = $paydemic->PurchaseLinks->listAll()->wait();

// 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();

// Delete an existing purchase link:
$paydemic->PurchaseLinks->delete($purchaseLink['id'])->wait();

Available resources & methods

Development

Run tests locally

composer install
composer test

Run static analysis tools, run tests with coverage and generate API Doc

composer build

After it finishes, have a look in the build folder.

Contribution

  • If you would like to contribute, please fork the repo and send in a pull request.