public function testBasicInvoiceTokenEncoder() { $partner_id = "1"; $private_key = "DW93ArFKshINPeZOCfYer3riymL+HoRlZj92BNjek+Y="; $public_key = "qIcshFT1NEh2JWPEp7+wVV8ibUFHKNew5apbNLGVqgI="; $atpay_public_key = "DjnbXwK20VZpir+RLWsrLVwUinAkdeAmvla4M509GXQ="; $session = new \AtPay\Session($partner_id, $private_key, $public_key, $atpay_public_key); $session->noncer = new MockNoncer(); $session->encrypter = new MockBox(); $invoice_token = new \AtPay\Token\Invoice($session, 20, '*****@*****.**', 'sku-123'); $invoice_token->expires = 0 + 60 * 60 * 24 * 7; $this->assertEquals($invoice_token->to_s(), '@MTIzAAAAAAAAAAFlbWFpbDx0ZXN0QGV4YW1wbGUuY29tPi9BoAAAAAk6gC97ImN1c3RvbV9maWVsZHMiOltdfQ==@'); }
<?php require_once 'atpay.phar'; # include php archive. Require "atpay/tokens": "1.0" if using Composer to manage packages. $session = new \AtPay\Session(partner_id, public_key, private_key); $invoice_token = new \AtPay\Token\Invoice($session, 20, '*****@*****.**', 'sku-123'); $token = $invoice_token->to_s(); if ($token) { $from = "*****@*****.**"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: ' . $from . "\r\n"; $subject = "Email Offer"; $message = '<a href="mailto:transactions@.atpay.com?subject=PHP Token&body=' . $token . '">Click to Buy</a>'; # creates a mailto with generated invoice token that will send to @Pay to process mail($target, $subject, $message, $headers); # send email to target. Adjust if invoice token echo "Tokenized link emailed."; }