<?php

namespace litle\sdk;

require_once realpath(__DIR__) . '/../../vendor/autoload.php';
#Sale
$sale_info = array('orderId' => '1', 'amount' => '10010', 'orderSource' => 'ecommerce', 'billToAddress' => array('name' => 'John Smith', 'addressLine1' => '1 Main St.', 'city' => 'Burlington', 'state' => 'MA', 'zip' => '01803-3747', 'country' => 'US'), 'card' => array('number' => '5112010000000003', 'expDate' => '0112', 'cardValidationNum' => '349', 'type' => 'MC'));
$config_hash = array('user' => 'BATCHSDKA', 'password' => 'certpass', 'merchantId' => '101', 'sftp_username' => 'sdk', 'sftp_password' => 'Zj8I8Ly5', 'batch_url' => 'prelive.litle.com', 'batch_requests_path' => '/usr/local/litle-home/twang/git/batches', 'litle_requests_path' => '/usr/local/litle-home/twang/git/batches');
$batch_dir = '/usr/local/litle-home/twang/git/batches';
$litle_request = new LitleRequest($config_hash);
$batch_request = new BatchRequest($batch_dir);
# add a sale to the batch
$batch_request->addSale($sale_info);
# close the batch, indicating that we intend to add no more sales
$batch_request->closeRequest();
# add the batch to the litle request
$litle_request->addBatchRequest($batch_request);
# close the litle request, indicating that we intend to add no more batches
$litle_request->closeRequest();
# send the batch to litle via SFTP
$response_file = $litle_request->sendToLitleStream();
# process the response file
$processor = new LitleResponseProcessor($response_file);
while ($txn = $processor->nextTransaction()) {
    echo "Transaction Type : " . $txn->getName() . "\n";
    echo "Transaction Id: " . $txn->litleTxnId . " \n";
    if ($txn->message != 'Approved') {
        throw new \Exception('ConfiguredLitleBatchRequestsMaually does not get the right response');
    }
}
<?php

namespace litle\sdk;

require_once realpath(__DIR__) . '/../../vendor/autoload.php';
$request = new LitleRequest();
$batch = new BatchRequest();
$sale_info = array('orderId' => '1', 'amount' => '10010', 'orderSource' => 'ecommerce', 'billToAddress' => array('name' => 'John Smith', 'addressLine1' => '1 Main St.', 'city' => 'Burlington', 'state' => 'MA', 'zip' => '01803-3747', 'country' => 'US'), 'card' => array('number' => '5112010000000003', 'expDate' => '0112', 'cardValidationNum' => '349', 'type' => 'MC'));
$batch->addSale($sale_info);
$request->addBatchRequest($batch);
$response_file = $request->sendToLitleStream();
$proc = new LitleResponseProcessor($response_file);
$raw_response = $proc->nextTransaction(true);
$sxe = new \SimpleXMLElement($raw_response);
echo "name:" . $sxe->message[0] . "\n";
echo "Response Raw XML: " . $raw_response;
if ($sxe->message[0] != 'Approved') {
    throw new \Exception('RawProcessing does not get the right response');
}
예제 #3
0
<?php

namespace litle\sdk;

require_once realpath(__DIR__) . '/../../vendor/autoload.php';
# this is a really big request
$request = new LitleRequest();
$batch = new BatchRequest();
$hash_in = array('card' => array('type' => 'VI', 'number' => '4100000000000001', 'expDate' => '1213', 'cardValidationNum' => '1213'), 'orderId' => '2111', 'orderSource' => 'ecommerce', 'id' => '654', 'amount' => '123');
$batch->addAuth($hash_in);
$hash_in = array('card' => array('type' => 'VI', 'number' => '4100000000000001', 'expDate' => '1213', 'cardValidationNum' => '1213'), 'id' => '654', 'orderId' => '2111', 'orderSource' => 'ecommerce', 'amount' => '123');
$batch->addSale($hash_in);
$request->addBatchRequest($batch);
$resp = new LitleResponseProcessor($request->sendToLitle());
while ($txn = $resp->nextTransaction()) {
    echo "Transaction Type : " . $txn->getName() . "\n";
    echo "Transaction Id: " . $txn->litleTxnId . " \n";
    echo "Message: " . $txn->message . " \n";
    if ($txn->message != 'Approved') {
        throw new \Exception('MechaBatch does not get the right response');
    }
}
예제 #4
0
 public function testInvalid()
 {
     $this->target->setRequest(new Request(array(), array('batch' => json_encode(array('requests' => array(array('url' => '/hoge', 'method' => null, 'params' => array()), array('url' => null, 'method' => 'post', 'params' => array())))))));
     $result = $this->target->post();
     $this->assertSame(array('data' => array(array('request' => '/hoge', 'method' => null, 'error' => 'invalid argument. url or method is null', 'result' => null), array('request' => null, 'method' => 'post', 'error' => 'invalid argument. url or method is null', 'result' => null))), $result->getData());
 }