PHP code example of paydemic / paydemic-php-sdk

1. Go to this page and download the library: Download paydemic/paydemic-php-sdk 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/ */

    

paydemic / paydemic-php-sdk example snippets


$paydemic = new PaydemicPhpSdk('<accessKey>', '<secretAccessKey>')
$paydemic->{ RESOURCE_NAME }->{ METHOD_NAME }

// 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 */ },
)

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