PHP code example of recurringstack / recurringstack-php

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

    

recurringstack / recurringstack-php example snippets




$rs = new recurringstack\api([
  'key' => "rs_key_....",
  'user_key' => "rs_user_....",
  'brand_id' => "",
  'response_format' => 'xml', //xml or json
  'response_type' => 'clean' //empty or clean (returns results as object)
]);

try { 

    # Delete a customer account
    $rs->deleteAccount('8247cf79-9296-4372-b39c-6370c70372ee');

} catch (recurringstack\apiException $e) { 

    /* The following custom error handling functions are available /*

    $debug = debugError(); //Return the exception message, code, request, and the response as an object. Great for debugging!
    $errorObj = $e->errorAsObject(); //Return the code and message in an object
    $errorMesage = getExceptionMessage(); //Return just the message
    $errorCode = getExceptionCode(); //Return just the code

    }

# List one or multiple customer accounts
$rs->listAccount(array('customer_account_id' => '8247cf79-9296-4372-b39c-6370c70372ee'))

# Delete a customer account
$rs->deleteAccount('8247cf79-9296-4372-b39c-6370c70372ee');

# Create a new subscription for a customer
$subConfig = array(
  "customer_account_id" => '8247cf79-9296-4372-b39c-6370c70372ee',
  "product_id" => "",
  "auto_pay" => "",
  "override_initial_billing" => ""
);

$rs->createSubscription($subConfig);

# Manually create an invoice for a customer
$invoiceConfig = array(
 "attached_items" => '[{"item_name":"Programming Services Base Charge","item_price":"25.00","tax_exempt":"N"},{"item_name":"25 Hours of Programming","item_price":"250.00","tax_exempt":"Y"}]',
 "custom_field_1" => '',
 "custom_field_2" => ''
);

$rs->createInvoice($invoiceConfig);
bash
composer