public function test5Transactions() { $inputFile = fopen('php://memory', 'w+'); $outputFile = fopen('php://memory', 'w+'); $csv = array(array('AMOUNT' => 100, 'OPERATIONTYPE' => 'payment', 'CARDCODE' => '5555556778250000', 'CARDVALIDITYDATE' => $this->tools->getFutureValidityDate(), 'CARDCVV' => '123', 'CARDFULLNAME' => 'John Doe', 'ORDERID' => 'order_' . time(), 'CLIENTIDENT' => 'john.doe', 'CLIENTEMAIL' => 'john.doe42', 'CLIENTEMAIL' => '*****@*****.**', 'DESCRIPTION' => 'Test', 'CLIENTUSERAGENT' => 'firefox', 'CLIENTIP' => '1.2.3.4', 'VERSION' => '2.0'), array('AMOUNT' => 100, 'OPERATIONTYPE' => 'payment', 'CARDCODE' => '5555554530114002', 'CARDVALIDITYDATE' => $this->tools->getFutureValidityDate(), 'CARDCVV' => '123', 'CARDFULLNAME' => 'John Doe', 'ORDERID' => 'order_' . time(), 'CLIENTIDENT' => 'john.doe', 'CLIENTEMAIL' => 'john.doe42', 'CLIENTEMAIL' => '*****@*****.**', 'DESCRIPTION' => 'Test', 'CLIENTUSERAGENT' => 'firefox', 'CLIENTIP' => '1.2.3.4', 'VERSION' => '2.0'), array('AMOUNT' => 100, 'OPERATIONTYPE' => 'payment', 'CARDCODE' => '', 'CARDVALIDITYDATE' => $this->tools->getFutureValidityDate(), 'CARDCVV' => '123', 'CARDFULLNAME' => 'John Doe', 'ORDERID' => 'order_' . time(), 'CLIENTIDENT' => 'john.doe', 'CLIENTEMAIL' => 'john.doe42', 'CLIENTEMAIL' => '*****@*****.**', 'DESCRIPTION' => 'Test', 'CLIENTUSERAGENT' => 'firefox', 'CLIENTIP' => '1.2.3.4', 'VERSION' => '2.0'), array('AMOUNT' => 100, 'OPERATIONTYPE' => 'payment', 'CARDCODE' => '5555556778250000', 'CARDVALIDITYDATE' => $this->tools->getFutureValidityDate(), 'CARDCVV' => '123', 'CARDFULLNAME' => 'John Doe', 'ORDERID' => 'order_' . time(), 'CLIENTIDENT' => 'john.doe', 'CLIENTEMAIL' => 'john.doe42', 'CLIENTEMAIL' => '*****@*****.**', 'DESCRIPTION' => 'Test', 'CLIENTUSERAGENT' => 'firefox', 'CLIENTIP' => '1.2.3.4', 'VERSION' => '2.0')); fputcsv($inputFile, array_keys(current($csv)), ';'); foreach ($csv as $line) { fputcsv($inputFile, $line, ';'); } rewind($inputFile); $batchApi = Be2bill_Api_ClientBuilder::buildSandboxBatchClient($this->getIdentifier(), $this->getPassword()); $batchApi->setInputFile($inputFile); $batchApi->attach(new Be2bill_Api_Batch_Observer_Debug()); $batchApi->attach(new Be2bill_Api_Batch_Observer_FileReport($outputFile)); $batchApi->run(); rewind($outputFile); $i = 0; while (!feof($outputFile)) { $line = fgetcsv($outputFile, null, ';'); // HACK for phpunit version >= 5.2 if ($line) { $i++; } } $this->expectOutputRegex('/Line 1.+\\nLine 2.+\\nLine 3.+\\nLine 4.+\\n/'); $this->assertEquals(5, $i); }
public function testRefund() { $api = Be2bill_Api_ClientBuilder::buildSandboxDirectLinkClient(BE2BILL_TEST_IDENTIFIER, BE2BILL_TEST_PASSWORD); $tools = new Be2bill_Api_Test_Tools(); $result = $this->api->payment('5555556778250000', $this->tools->getFutureValidityDate(), 132, 'john doe', '1000', 'order-' . time(), 'john doe', '*****@*****.**', '1.2.3.4', 'desc', 'firefox'); $result = $this->api->refund($result['TRANSACTIONID'], 'order-' . time(), 'desc'); $this->assertTransactionSucceeded($result); }
public function testAuthorizationFormDisplay() { $formApi = Be2bill_Api_ClientBuilder::buildSandboxFormClient(BE2BILL_TEST_IDENTIFIER, BE2BILL_TEST_PASSWORD); $html = $formApi->buildAuthorizationFormButton('1000', 'order-' . time(), 'ident', 'desc'); $inputs = $this->getInputsFromHtml($html); $action = $this->getFormActionFromHtml($html); $result = $this->request($action, $inputs); $inputs = $this->getInputsFromHtml($result); $this->assertArrayHasKey('IDENTIFIER', $inputs); }
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script> </head> <body> <script type="text/javascript"> $(document).ready(function () { $("#myform").submit(); }); </script> <?php error_reporting(E_ALL); ini_set('display_errors', 1); require 'config.php'; require '../src/Be2bill/Api/Autoloader.php'; Be2bill_Api_Autoloader::registerAutoloader(); // Use fallback URL // Be2bill_Api_ClientBuilder::switchUrls(); // Just implement BE2BILL_IDENTIFIER and BE2BILL_PASSWORD as defined $be2bill = Be2bill_Api_ClientBuilder::buildSandboxFormClient(BE2BILL_IDENTIFIER, BE2BILL_PASSWORD); echo $be2bill->buildPaymentFormButton(15387, 'order_' . time(), 'user_123456', 'Payment sample', $htmlOptions = array('SUBMIT' => array("value" => "Pay with be2bill", "style" => "display: none;"), 'FORM' => array('id' => 'myform', "target" => "be2bill-frame"))); ?> <iframe name="be2bill-frame" /> </body> </html>
/** * Instanciate */ public function __construct() { parent::__construct(); $this->api = Be2bill_Api_ClientBuilder::buildSandboxDirectLinkClient($this->getIdentifier(), $this->getPassword()); $this->tools = new Be2bill_Api_Test_Tools(); }
/** * Use another production URL */ public static function switchProductionUrls() { self::$productionUrls = array_reverse(self::$productionUrls); }