I can get the .php file to work with the sample data in it. However, I have tried several ways to get an html form to post the variables into the php. What is the best way to do this? I am attaching the .php with the sample data in it that works on the site. When I try to use an .html file and post to this it stops at the BluPay.php file and nothing happens and the transaction fails to send the data. This is only test data so nothing is real inside for credit card information.
<?php
/**
* BluePay PHP Sample Code
*
* This code sample runs a $3.00 Credit Card Sale transaction
* against a customer using test payment information.
* If using TEST mode, odd dollar amounts will return
* an approval and even dollar amounts will return a decline.
*
*/
include('BluePay.php');
$accountID = "XXXXXXXX";
$secretKey = "XXXXXXXXXXXXXX";
$mode = "TEST";
$payment = new BluePay(
$accountID,
$secretKey,
$mode
);
$payment->setCustomerInformation(array(
'firstName' => 'Bob',
'lastName' => 'Tester',
'addr1' => '1234 Test St.',
'addr2' => 'Apt #500',
'city' => 'Testville',
'state' => 'IL',
'zip' =>'54321',
'country' => 'USA',
'phone' => '1231231234',
'email' => 'test@bluepay.com'
));
$payment->setCCInformation(array(
'cardNumber' => '4111111111111111', // Card Number: 4111111111111111
'cardExpire' => '1217', // Card Expire: 12/15
'cvv2' => '123' // Card CVV2: 123
));
$payment->sale('3.00'); // Sale Amount: $3.00
// Makes the API request with BluePAy
$payment->process();
// Reads the response from BluePay
if($payment->isSuccessfulResponse()){
echo
'Transaction Status: '. $payment->getStatus() . "
" .
'Transaction Message: '. $payment->getMessage() . "
" .
'Transaction ID: '. $payment->getTransID() . "
" .
'AVS Response: ' . $payment->getAVSResponse() . "
" .
'CVS Response: ' . $payment->getCVV2Response() . "
" .
'Masked Account: ' . $payment->getMaskedAccount() . "
" .
'Card Type: ' . $payment->getCardType() . "
" .
'Authorization Code: ' . $payment->getAuthCode() . "
";
} else{
echo $payment->getMessage() . "
";
}
?>
Here is one of the html I was using to post to the php above after I removed the values:
<form action="ccpost.php" method="post">
<input type="hidden" name="accountID" value="XXXXXXXXXX" />
<input type="hidden" name="secretKey" value="XXXXXXXXXXX" />
<input type="hidden" name="mode" value="TEST" />
First Name: <input type="text" name="firstName"><br>
Last Name: <input type="text" name="lastName"><br>
Address 1: <input type="text" name="addr1"><br>
Address 2: <input type="text" name="addr2"><br>
City: <input type="text" name="city"><br>
State: <input type="text" name="state"><br>
Zip Code: <input type="text" name="zip"><br>
Country: <input type="text" name="country"><br>
Phone: <input type="text" name="phone"><br>
E-mail: <input type="text" name="email"><br>
Card Number: <input type="text" name="cardNumber"><br>
Card Expire: <input type="text" name="cardExpire"><br>
Cvv: <input type="text" name="cvv2"><br>
Sale: <input type="text" name="sale"><br>
<input type="submit">
</form>
This is the current php I am trying to post to. So I took the variables and use the $_POST. However I am getting an PHP Parse error: syntax error, unexpected ';' around the accountID line.
<?php
include('BluePay.php');
$payment = new BluePay(
$accountID = $_POST["accountID"];
$secretKey = $_POST["secretKey"];
$mode = $_POST["mode"];
);
$payment->setCustomerInformation(array(
$firstName = $_POST["firstName"];
$lastName = $_POST["lastName"];
$addr1 = $_POST["addr1"];
$addr2 = $_POST["addr2"];
$city = $_POST["city"];
$state = $_POST["state"];
$zip = $_POST["zip"];
$country = $_POST["country"];
$phone = $_POST["phone"];
$email = $_POST["email"];
));
$payment->setCCInformation(array(
'cardNumber' => '4111111111111111', // Card Number: 4111111111111111
'cardExpire' => '1217', // Card Expire: 12/15
'cvv2' => '123' // Card CVV2: 123
));
$payment->sale('3.00'); // Sale Amount: $3.00
// Makes the API request with BluePay
$payment->process();
// Reads the response from BluePay
if($payment->isSuccessfulResponse()){
echo
'Transaction Status: '. $payment->getStatus() . "
" .
'Transaction Message: '. $payment->getMessage() . "
" .
'Transaction ID: '. $payment->getTransID() . "
" .
'AVS Response: ' . $payment->getAVSResponse() . "
" .
'CVS Response: ' . $payment->getCVV2Response() . "
" .
'Masked Account: ' . $payment->getMaskedAccount() . "
" .
'Card Type: ' . $payment->getCardType() . "
" .
'Authorization Code: ' . $payment->getAuthCode() . "
";
} else{
echo $payment->getMessage() . "
";
}
?>