First Data Global Gateway API Plugin Component

This article is also available in the following languages:
By chronon
The Ggapi component simplifies credit card processing using the First Data/Yourpay/Linkpoint Global Gateway API. It supports testing and live configurations, along with local to remote field mapping.

Once configured, all you have to do is feed the component an array of order data (fields used are up to you) and it will map the fields, build the XML string, submit the string, read the response from the gateway, and convert the response back into an array.
Requirements: PHP5 with curl support and a Global Gateway API account (live or testing).

Example controller code:

Controller Class:

<?php 
// attempt the charge (array $data, boolean $testing)
$response $this->Ggapi->ggProcess($datatrue);

// update the order table with the response
if ($response) {
    if (
$response['r_approved'] == 'APPROVED') {
        
// merge the response data with the order data
        
$this->data['Order'] = array_merge($this->data['Order'], $response);
    } else {
        
// card was DECLINED
        
$error explode(':'$response['r_error']);
        
$this->Session->setFlash(
            
'Your credit card was declined. The message was: '.$error[1],
            
'modal',
            array(
'class' => 'modal error')
        );
        
$this->redirect(array('controller' => 'orders''action' => 'checkout'));
    }
} else {
    
// no response from the gateway
    
$this->Session->setFlash(
        
'There was a problem connecting to our payment gateway, please try again.',
        
'modal',
        array(
'class' => 'modal error')
    );
    
$this->redirect(array('controller' => 'orders''action' => 'checkout'));
}
?>

Download/git clone at http://github.com/chronon/ggapi.

Comments

  • Posted 04/19/11 06:42:54 PM
    Can you please post an example of how I could map my form fields to $config['Ggapi']['fields']? How would I use that in my code? I see that $response = $this->Ggapi->ggProcess($data, true) has $data passed in. So, does that mean that my $this->data['Model']['chargetotal'] matches up with $config['Ggapi']['fields']['order_total']? In other words, do I match up my form values to the right side of $config['Ggapi']['fields'] ('chargetotal' in this case)?

    Thanks in advance.
    -Keith
  • Posted 03/25/11 05:37:21 PM
    Does this component work with the FDGG "Web Services" API, or just the normal API? I want to use it on a shared server that forces me to use port 443 (Web Services API).
  • Posted 12/20/10 04:35:17 PM
    I'll admit I'm not terribly familiar with the FDGG API, but I seem to be a little confused by the "configfile" field in settings.php. What config file is this in reference to and what sort of content do I need to include in it? Besides that, your component looks great! Looking forward to implementing it fully.
    • Posted 02/17/11 10:25:35 AM
      [quote] I'll admit I'm not terribly familiar with the FDGG API, but I seem to be a little confused by the "configfile" field in settings.php. What config file is this in reference to and what sort of content do I need to include in it?
      [end quote]
      The "configfile" field is actually your FDGG store number, and a required field for any transaction. Don't ask me why they named this field "configfile" when designing their API. The FDGG API user manual has more information on this field if you need it.

Comments are closed for articles over a year old