Test PHP

I am text block. Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

I am text block. Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

I am text block. Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

function testXmlQuery($username, $password, $constraints)
{
// transactionFields has all of the fields we want to validate
// in the transaction tag in the XML output
    $transactionFields = array(
        'transaction_id',
        'transaction_type',
        'condition',
        'order_id',
        'authorization_code',
        'ponumber',
        'order_description', //change the orderdescription
        'avs_response',
        'csc_response',

        'first_name',
        'last_name',
        'address_1',
        'address_2',
        'company',
        'city',
        'state',
        'postal_code',
        'country',
        'email',
        'phone',
        'fax',
        'cell_phone',
        'customertaxid',
        'customerid',
        'website',

        'shipping_last_name',
        'shipping_address_1',
        'shipping_address_2',
        'shipping_company',
        'shipping_city',
        'shipping_state',
        'shipping_postal_code',
        'shipping_country',
        'shipping_email',
        'shipping_carrier',
        'tracking_number',

        'cc_number',
        'cc_hash',
        'cc_exp',
        'cc_bin',
        'avs_response',
        'csc_response',
        'cardholder_auth',

        'processor_id',

        'tax');
// actionFields is used to validate the XML tags in the
// action element
    $actionFields = array(
        'amount',
        'action_type',
        'date',
        'success',
        'ip_address',
        'source',
        'response_text'
    );

    $ch = curl_init(); // Initialize curl handle

    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

    //curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
    curl_setopt($ch, CURLOPT_POST, 1);

    $postStr = 'username=' . $username . '&password=' . $password . $constraints;
    $url = "https://payzang.transactiongateway.com/api/query.php?" . $postStr;
    curl_setopt($ch, CURLOPT_URL, $url);

    if (!($data = curl_exec($ch))) {
        return ERROR;
    }

    $testXmlSimple = new SimpleXMLElement($data);

    $xmlString = $testXmlSimple->saveXML();
    print $testXmlSimple->saveXML();

    if (!isset($testXmlSimple->transaction)) {
        print ('No transactions returned');
    }

    $transNum = 1;
    foreach ($testXmlSimple->transaction as $transaction) {
        foreach ($transactionFields as $xmlField) {
            if (!isset($transaction->{$xmlField}[0])) {
                print('Error in transaction_id:' . $transaction->transaction_id[0] . ' id  Transaction tag is missing  field ' . $xmlField);
            }
        }
        if (!isset ($transaction->action)) {
            print('Error, Action tag is missing from transaction_id ' . $transaction->transaction_id[0]);
        }

        $actionNum = 1;
        foreach ($transaction->action as $action) {
            foreach ($actionFields as $xmlField) {
                if (!isset($action->{$xmlField}[0])) {
                    print('Error with transaction_id' . $transaction->transaction_id[0] . 'Action number ' . $actionNum . ' Action tag is missing field ' . $xmlField);
                }
            }
            $actionNum++;
        }
        $transNum++;
    }

    return;
}

try {
    //tx id = 3243202914
    //$constraints = "&action_type=sale&start_date=20160427";
    //$constraints = "&action_type=sale&start_date=20160816";
    $constraints = "&transaction_id=3183517874";
    //$result = testXmlQuery('pzdktest', 'furelise540', $constraints);
    $result = testXmlQuery('test124', 'furelise124', $constraints);
    print $result;
    print "Success.\n";

} catch (Exception $e) {

    $e->outputText();

}

I am text block. Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.


PayZang 1-800-838-8651

Payzang