Assistance with CC Processing script

Posted by JM4 on Stack Overflow See other posts from Stack Overflow or by JM4
Published on 2010-05-18T20:09:07Z Indexed on 2010/05/22 9:40 UTC
Read the original article Hit count: 164

Filed under:
|
|

I am currently implementing a credit card processing script, most as provided by the merchant gateway. The code calls functions within a class and returns a string based on the response. The end php code I am using (details removed of course) with example information is:

<?php
$gw = new gwapi;
$gw->setLogin("username", "password");
$gw->setBilling("John","Smith","Acme, Inc.","888","Suite 200", "Beverly Hills",
        "CA","77777","US","555-555-5555","555-555-5556","[email protected]",
        "www.example.com");
//        "CA","90210","US","[email protected]");
$gw->setOrder("1234","Big Order",1, 2, "PO1234","65.192.14.10");

$r = $gw->doSale("1.00","4111111111111111","1010");
print $gw->responses['responsetext'];

?>

where setlogin allows me to login, setbilling takes the sample consumer information, set order takes the order id and description, dosale takes the amount charged, cc number and exp date.

when all the variables are sent validated then sent off for processing, a string is returned in the following format:

response=1&responsetext=SUCCESS&authcode=123456&transactionid=23456&avsresponse=M&orderid=&type=sale&response_code=100

where:

  • response = transaction approved or declined
  • response text = textual response
  • authcode = transaction authorization code
  • transactionid = payment gateway tran id
  • avsresponse = avs response code
  • orderid = original order id passed in tran request
  • response_code = numeric mapping of processor response

I am trying to solve for the following:

  1. How do I take the data which is passed back and display it appropriately on the page - If the transaction failed or AVS code doesnt match my liking or something is wrong, an error is displayed to the consumer; if the transaction processed, they are taken to a completion page and the transaction id is sent in SESSION as output to the consumer
  2. If the response_code value matches a table of values, certain actions are taken, i.e. if code =100, take to success page, if code = 300 print specific error on original page to customer, etc.

© Stack Overflow or respective owner

Related posts about php

Related posts about curl