PHP code example of atpay / atpay_php

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

    

atpay / atpay_php example snippets






$session = new \AtPay\Session(partner_id, public_key, private_key);

$invoice_token = new \AtPay\Token\Targeted($session, 20, '[email protected]');
echo $invoice_token->to_s();

$bulk_token = new \AtPay\Token\Bulk($session, 30);
echo $bulk_token->to_s();

$invoice_token = new \AtPay\Token\Targeted($session, 20, '[email protected]');
$invoice_token->auth_only();
echo $invoice_token->to_s();

$invoice_token = new \AtPay\Token\Targeted($session, 20, '[email protected]');
$invoice_token->expires_in_seconds(60 * 60 * 24 * 7); // one week
echo $invoice_token->to_s();
 

$invoice_token = new \AtPay\Token\Targeted($session, 20, '[email protected]');
$invoice_token->url('https://example.com/invoices/123');
echo $invoice_token->to_s();
 

$invoice_token = new \AtPay\Token\Targeted($session, 20, '[email protected]');
$invoice_token->request_custom_data('gift_message', true); //Input name , 

$invoice_token = new \AtPay\Token\Targeted($session, 20, '[email protected]');
$registration = $invoice_token->register();

echo $registration->url();
=> "https://example.secured.atpay.com/{token_identifier}"

echo $registration->short();
=> "atpay://{token_identifier}"

$invoice_token = new \AtPay\Token\Targeted($session, 20, '[email protected]');
$invoice_token->name("A Cool Offer");
echo $invoice_token->to_s();
 

$invoice_token = new \AtPay\Token\Targeted($session, 20, '[email protected]');
$invoice_token->set_item_details("Lorem Ipsum ...");
echo $invoice_token->to_s();
 

$invoice_token = new \AtPay\Token\Targeted($session, 20, '[email protected]');
$invoice_token->set_item_quantity(3);
echo $invoice_token->to_s();
 

$invoice_token = new \AtPay\Token\Targeted($session, 20, '[email protected]');
$token_token->estimated_fulfillment_days(3)      # The token is now auth-only!
email(token.to_s, receipient_address)

$invoice_token = new \AtPay\Token\Targeted($session, 20, '[email protected]');
$invoice_token->custom_user_data("{foo => bar}");
echo $invoice_token->to_s();


  // Include @Pay's PHP SDK
       # when using composer.

  // Configure with your keys:
  $partner_id       = '';
  $public_key       = '';
  $private_key      = '';

  $session = new \AtPay\Session($partner_id, $public_key, $private_key);

  // Generate a new Invoice Token for $150
  $total_price    = 150;
  $customer_email = "[email protected]";


  $invoice_token = new \AtPay\Token\Targeted($session, $total_price, $customer_email);
  $token         = $invoice_token->to_s();

  // Send an Email to the Customer
  $subject = "You Abandoned Your Cart!";
  $from    = "[email protected]";

  $headers  = 'MIME-Version: 1.0' . "\r\n";
  $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  $headers .= 'From: '.$from."\r\n";
  $message  = '<a href="mailto:[email protected]?subject='.urlencode('PHP Token').'&body='.urlencode($token).'">Click to Buy</a>'; # creates a mailto with generated invoice token that will send to @Pay to process

  // Send the email
  mail($customer_email, $subject, $message, $headers);

  // Done
  echo "Invoice Sent!";
bash
$ curl -O -L http://github.com/atpay/atpay_php/releases/download/2.0.2/atpay_php.phar
json
{
  "ay/atpay_php": "2.0.5"
  }
}

$invoice_token = new \AtPay\Token\Targeted($session, 20, '[email protected]');
$invoice_token->