2017 © Pedro Peláez
 

library paydemic-php-sdk

PHP SDK for Paydemic.com REST API.

image

paydemic/paydemic-php-sdk

PHP SDK for Paydemic.com REST API.

  • Friday, September 9, 2016
  • by paydemic
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

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

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

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.

The Versions