PHP code example of payload / payload-api

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

    

payload / payload-api example snippets





ayload\API as pl;

use Payload\API as pl;
pl::$api_key = 'secret_key_3bW9JMZtPVDOfFNzwRdfE';


# Create a Customer
$customer = Payload\Customer::create(array(
    'email'=>'[email protected]',
    'name'=>'Matt Perez'
));


# Create a Payment
$payment = Payload\Transaction::create(array(
    'amount'=>100.0,
    'type'=>'payment',
    'payment_method'=>new Payload\PaymentMethod(array(
        'card'=>array('card_number'=>'4242 4242 4242 4242'),
        'type'=>'card'
    ))
));


$customer->name;


# Updating a customer's email
$customer->update(array( 'email'=>'[email protected]' ))


# Select a customer by email
$customers = Payload\Customer::filter_by(
    pl::attr()->email->eq('[email protected]')
);

$payments = Payload\Transaction::filter_by(
    pl::attr()->amount->gt(100),
    pl::attr()->amount->lt(200),
    pl::attr()->description->contains("Test"),
    pl::attr()->created_at->gt('2019-02-01')
)->all()

sudo apt install php-curl
  ./vendor/bin/phpunit Tests/{__FILENAME__}.php