Linkpoint API Payment Module

Contrib type: 
Module
Status: 
Complete and working
Moderation: 
Failed code review
Compatibility: 
Ubercart 1.x

This is a current working version of the Linkpoint API module that was posted on the forums awhile back.

To install this module, extract the uc_linkpoint_api.zip file to your modules/ubercart/payment folder. After, go to the modules section in drupal admin (http://www.yoursite.com/admin/build/modules) and scroll down to the "Ubercart - Payment" modules section. Enable "Linkpoint API".

In order to communicate with your linkpoint account, you will need to get a file called a PEM file from linkpoint. To get it, go to Linkpoint Central -> Support -> Download Center. Save that file to your modules/ubercart/payment/uc_linkpoint_api folder.

Once you've done that, navigate over to the Payment settings in ubercart (http://www.yoursite.com/admin/store/settings/payment/edit/gateways). Click on "Linkpoint API settings" and where it says PEM file, fill in the absolute path to your PEM file (example: /home/domain/public_html/modules/ubercart/payment/uc_linkpoint_api/123456.pem).

The Linkpoint API module submits the following information to Linkpoint Central:

    Billing Address:
    • Name
    • Company
    • Address 1
    • Address 2
    • City
    • State/Province
    • Zip/Postal Code
    • Country

    Shipping Address:

    • Name
    • Address 1
    • Address 2
    • City
    • State/Province
    • Zip/Postal Code
    • Country

    Contact Information:

    • Phone
    • E-Mail
    • IP Address

    Credit Card Information:

    • Card Number
    • Card Expiration Month
    • Card Expiration Year in 2 digits (00, 01, 02, etc)
    • CVM Value

    Payment Information

    • Total Amount

It will also pass all of the item descriptions and attributes to the Linkpoint Central comments section. To disable this, scroll down to line 191 and comment it out so it looks like this:

  //$xml .="<comments>" . $description . "</comments>";

All issues addressed in my old post and the post by guest have been addressed and corrected.

PreviewAttachmentSize
uc_linkpoint_api.zip3.81 KB
Joined: 08/17/2007
Juice: 90

I was getting an error telling me the Credit Card Expiration Year was incorrect when I tried to process credit cards. I did a little more research and found linkpoint needs the years to be in 2 digits instead of 4 digits.

In the linkpoint module there is a line that is supposed to truncate the year down to 2 digits:

$xml .="<cardexpyear>" . date('y', $order->payment_details['cc_exp_year']) . "</cardexpyear> ";

This wasn't working for me so I removed that line and replaced it with:

$cardexpyr = substr($order->payment_details['cc_exp_year'], 2, 2);
$xml .="<cardexpyear>" . $cardexpyr . "</cardexpyear> ";

As of 10/8/2007 this module appears to be fully functioning for me.

Guest (not verified)
Guest's picture

Another issue with Linkpoint is the country code is supposed to be 2 letters. For example:

US for USA
CA for Canada.

The problem is Ubercart stores the countries as numbers. For example:

USA is 840
CA is 124

For the time being, I devised a ghetto little rig to convert these numbers to the 2 letters needed by Linkpoint.

Add the lines to the uc_linkpoint_api.module file:

Original file:

$description = substr($description, 0, 255);
*/

  $xml ="<order>";

Modified file:

$description = substr($description, 0, 255);
*/

$countrybill = $order->billing_country;
  if ($countrybill == 840) {
    $countrybill = "US";
  } else if ($countrybill == 124) {
    $countrybill = "CA";
  }

  $xml ="<order>";

After you do that, find the line that says:

$xml .="<country>" . $order->billing_country . "</country>";

and replace it with:

  $xml .="<country>" . $countrybill . "</country>";
pat
pat's picture
Joined: 11/22/2007
Juice: 7

This module contains some code from the linkpoint lphp.php file decodeXML function. This file has a copyright notice on it.

I have a rewritten module without copyright code I will post soon.

Joined: 01/15/2008
Juice: 42

Some non-dedicated hosting companies do not give cURL access to certain ports.

This means that GoDaddy will NOT work with this module if you have a shared hosting server.

Joined: 01/10/2008
Juice: 28

I posted this in the general forum in error as I thought I was adding it to this thread of nick's.
http://www.ubercart.org/forum/general_discussion/3064/linkpoint_yourpay_...

Question as posted:

Ubercart tells me "Your order is complete!" I get no other feedback. And there is nothing in watchdog indicating any errors. This is LIVE Production mode.
When I check for the transaction on the linkpoint/yourpay site there is none.

Linkpoint_api_module here:
/home/xxx/www/mydomain.com/sites/all/modules/ubercart/payment/uc_linkpoint_api/uc_linkpoint_api.module

pem file here:
/home/xxx/www/mydomain.com/sites/all/modules/ubercart/payment/uc_linkpoint_api/1234567890.pem

What is the best way to debug this? How to see what is being passed to linkpoint?

apologies for the "double" post

Joined: 08/17/2007
Juice: 90

What I did to see more debug info was edit the following lines:

'message' => t('Credit card payment declined: !text', array('!text' => $x_response_text)),

'message' => t('Credit card payment processed successfully. Approval code: !code', array('!code' => $approved_text)),

to

'message' => t('x_response_code:'. $x_response_code .'<br />x_approval_code:'.$x_approval_code.'<br />xml: '.$xml.'<br />Credit card payment declined: !text', array('!text' => $x_response_text)),

'message' => t('x_response_code:'. $x_response_code .'<br />x_approval_code:'.$x_approval_code.'<br />xml: '.$xml.'<br />Credit card payment processed successfully. Approval code: !code', array('!code' => $approved_text)),

Joined: 01/10/2008
Juice: 28

Thanks for the code, Nick. Assuming I installed it correctly I still get no feed back except the standard "Order complete."
So I don't know if linkpoint is receiving anything or not.
I am using the standard test number 4111111111111111. (Linkpoint tech told me it is not a problem using that number)
Any ideas on how I can tell if my server is shaking hands with theirs?

Another issue in looking at the order report under the admin/store/orders/69/payments there is no info recorded regarding the payment. It's all blank. This indicates to me something is not being completed even though the cart says it is.

Joined: 08/07/2007
Juice: 392

Hi,

I keep trying to process a card (i'm going through ubercarts backend) and it keeps going blank after i go to charge card.

Does nayone know why this is?

I cant seem to get this to work =/

Joined: 08/07/2007
Juice: 392

I transfered servers and now the module works...SO it mustve been something with my server configuration.

Thanks nick for the great module

Joined: 03/07/2008
Juice: 5

Just wanted to toss this out to whomever is using this API. I'm using linkpnt via YourPay and found an issue with this where I'd get errors: SGS-020003.
This is an invalid XML error. After much lack of help from their support,
I found this in their manual:

SGS-020003: Invalid XML

There are a couple different things that will cause this error.

1. Make sure the amount for chargetotal is not blank.
2. Make sure expiration year is only 2 digits
3. Make sure there is no dollar sign for the amount.
4. Make sure there are no symbols like an ampersand,
apostrophe, or letters with accents
5. If there is no shipping make sure you pass zero for the amount
6. Make sure there are no commas in the amount for chargetotal

The issue I have is a LOT of my commercial customers have an & or an
apostrophe in their company names.

I had to add the following to the module:

/* remove ampersand and appostrophes from text */
$xml = str_replace("&", "and", $xml);
$xml = str_replace("'", " ", $xml);
/* end scrub */

Now things are happier.

R. Marc

Joined: 07/24/2008
Juice: 14

Hello Linkpoint API Module Crew,

I am having a problem when clicking "Submit Order" on the "Review order" page, e.g. https://www.domain.com/cart/checkout/review , the form submit hangs for a while then I get these error messages on a blank white page:

Warning: MySQL server has gone away
couldn't connect to host
Credit card declined: $0.50
Payment failed: Credit card payment declined: Sorry - Could not connect to payment gateway.

I assume SSL is working fine since https://www.domain.com/cart/checkout/review works ok.

I checked to see what my absolute path was and if curl is enabled using the following php code and received the output below:

$_SERVER['DOCUMENT_ROOT']
output: /home/account_name/public_html

var_dump(curl_version())
output: libcurl/7.18.2 OpenSSL/0.9.7a zlib/1.2.1.2 libidn/0.5.6

My settings at store/settings/payment/edit/gateways for the Linkpoint API are:

Store Number: xxxxxxxxxx (10 digits)
PEM File: /home/account_name/public_html/modules/ubercart/payment/uc_linkpoint_api/xxxxxxxxxx.pem
Transaction mode: Production
Transaction Type: Sale

I noticed that Linkpoint also gave me a 6 digit user id that is the same as the last 6 digits in the 10 digit store number. Should I be using the 6 digits instead of the 10 digits for the Store Number field?

Also, I noticed that when I first extracted the module into the /home/account_name/public_html/modules/ubercart/payment/uc_linkpoint_api directory, there is an 000000.pem.txt file in there with the instructions: "Delete all text within this file, then copy and paste your key from Linkpoint API here. Do not leave any whitespaces or returns at the end of the file. Then rename this file to your store id, 6 digits, with .pem as the file extension."

However, when I download my PEM file from Linkpoint, the file is named xxxxxxxxxx.pem (10 digits) and it has a trailing line break on the end of the file.

I have tried using the 6 digit user id as my store number, switching to the xxxxxx.pem (6 digit version with no trailing line break and no white space), switched between production and test modes, and still receive the same errors that I listed above.

Has anyone ran into a similar problem, or know of anything to fix this problem? Thanks!

Joined: 07/26/2008
Juice: 67

I did a few fixes for this module since I ran into a few issues:

- Added breakout of subtotal, tax, shipping and total cost so your customer doesn't get "shipping cost: 0, tax: 0"
- Added check for subtotal since payment will fail if subtotal <= zero. If this happens, reverts to using total only (no breakout of tax/shipping etc). Why would you ever have negative subtotal? We're using userpoints as payment and may have the situation that userpoints paid is less than total but more than subtotal.
- Fixed a few bugs related to the way the module formatted and sent credit card expiration date and security code.

UPDATE: sorry just saw there's a later update of this module which might already include these fixes... I was running 5.x-1.0-alpha6c

AttachmentSize
patch.txt 2.5 KB
Joined: 08/20/2008
Juice: 9

I'm getting this error:

"unable to use client certificate (no key found or wrong pass phrase?)"

This is my first setup and after using test gateway, then switching to processing an order using a real credit card via the LinkPoint API, in production mode.

Could there be something wrong with my pem file?

Thanks,

Robert

Joined: 08/20/2008
Juice: 9

Ahh - must have been some issue with the path - I repasted it in and now it works fine.

Robert

Joined: 08/12/2008
Juice: 33

It turns out if that if the linkpoint terminal had been previously used and there are already orders in there that match the order id the transaction will be denied.

I'm not sure what the best solution is, but in my case, I simply appended some letters to the order id so there wouldn't be a conflict -- in other words, instead of sending the #3 as order id, it sends UC3

Joined: 09/30/2008
Juice: 8

I have been trying to debug my Drupal-Ubercart with linkpoint api and have finally got to the point where it seems to send the order but returns a "Credit Card Denied" error with different known good cards.

I am wondering if I have the most current version as the file attached to the top message seems to be dated from 2007 but after reading message 12 it seems to indicate a more current 2008 version.

Could anyone point me to the most recent version and help me with what might be causing the "Credit Card Denied" error I keep getting.

Out of frustration I have installed Zen Cart to test to see if I might be having a server issue, but after configuring Zen Cart I was able to pass an order to linkpoint and have the transaction show up on their side. So I am thinking the problem must be with either my Drupal-Ubercart configuration or the Linkpoint api. Anyone else working with Drupal-Ubercart and Linkpoint?

Joined: 07/24/2008
Juice: 14

I was also having the same problems as rmarc71.

It turns out, the element inside the xml created by this module prints out the name of the product(s), which is "ok".

However, in some of my product names there is a "registered" ร‚ยฎ symbol, and the "trademark" รขโ€žยข symbol, which when printed into an xml file without being escaped properly causes the xml to be invalid. And hence the SGS-020003: Invalid XML error.

Hopefully this helps others. Thanks to rmarc71 for steering me in the right direction.

Joined: 11/14/2008
Juice: 2

The PEM file should not be accessible via the web (i.e. it should not be in your public_html folder). Ideally it should be uploaded to your root folder so Ubercart can get to it, but anonymous visitors to your website cannot.

A better location to upload it would be /home/domain/123456.pem instead.

Joined: 02/26/2009
Juice: 2

I was just wondering if there was a plan to update this module to be compatible with Drupal 6.x and Ubercart 2.x?

Joined: 01/19/2009
Juice: 61

How did you append the letters to the orders?

Joined: 02/19/2009
Juice: 22

I created a version of the LinkPoint API for UC 2.x. You can find it here - http://www.ubercart.org/forum/development/9567/linkpoint_api_drupal_6xub...

All I did was modify the .info file and a few other minor edits - nothing significant. This is pretty much the exact same code base as the UC 1.x version.

I've done very minimal testing so be careful using on sites - especially live sites! I still haven't ran a live transaction through this.

Joined: 05/07/2009
Juice: 2

Thank you very much for creating this module. I had a little trouble finding help on getting it to work, mostly because I am a noob. Here are some things to note for other noobs out there. Please note I dont warrant these tips are completely correct. It is just what worked for me and I humbly ask experts to correct anything I state incorrectly.

1. If your the developer and your client has YourPay - this module is for you. The LinkPoint links listed in the module directions above will work for you. In order to download the PEM file, you will need to know the exact first and last name your client used to sign up with the service. In my case, my clients name is Josh but he used Joshua to sign up.

2. You need SSL to pass information to LinkPoint. I understood that your need SSL for security, however I thought I could get away with fully testing with out SSL. The way the module is set up will actually partially test the credit card number when you go from the Billing Information page to the Review Order page. This was slightly misleading to me because it would pass the partial test however when I tried to complete the order I received an error. When I checked the Watchdog Error log, it said 'Payment failed: Credit card payment declined: Sorry - Could not connect to payment gateway'. This was due to my shared hosting provider (bluehost) not having port 1129 open for me. After buying the dedicated IP address I had to send in a request ticket to open up port 1129.

3. I also requested that my host give me SSH access so that I could better test that curL was actually getting to LinkPoint. Here is a cool command that I pieced together from web searches that you can enter into the command line:

curl -v -d "<order><orderoptions><ordertype>SALE</ordertype><result>GOOD</result></orderoptions><creditcard><cardnumber>4005550000000019</cardnumber><cardexpmonth>12</cardexpmonth><cardexpyear>12</cardexpyear><cvmindicator>provided</cvmindicator></creditcard><billing><name>Chad King</name><company></company><address1>6329 s paulina</address1><address2></address2><city>Chicago</city><state></state><zip>60636</zip><country>USA</country><phone>312-431-0251</phone><fax></fax></billing><shipping><state></state></shipping><transactiondetails><oid>e520402b948a7fc6bd403cd065ab132d</oid></transactiondetails><merchantinfo><configfile>XXXXXXXX</configfile><keyfile>/home/XXXXX/etc/linkpoint/XXXXXX.pem</keyfile><host>secure.linkpt.net</host><port>1129</port></merchantinfo><payment><chargetotal>34.35</chargetotal></payment></order>" -E <path to your .pem file> -k https://secure.linkpt.net:1129/LSGSXML

Replace [path to your .pem file] with the full location of your PEM file. Notice that between the [cardnumber] tag I am using a fake credit card number LinkPoint offers for testing. You can find more of these test credit card numbers in the PDF at http://www.firstdata.com/support/manuals_and_guides/pdf/global_gateway/n....

4. After using the above command I would get an error that I couldn't connect to the payment gateway until I got the SSL set up on my server. After SSL was set up I got another error. It said the following:

* About to connect() to secure.linkpt.net port 1129 (#0)
* Trying 208.72.248.102... connected
* Connected to secure.linkpt.net (208.72.248.102) port 1129 (#0)
* SSL: couldn't set callback!
* unable to use client certificate (no key found or wrong pass phrase?)
* Closing connection #0

After lots of whining and banging my head against the wall I re-read the thread on this page and notice I missed comment #18. WiseTex mention that you shouldn't put the PEM is the web accessible public_html directory. You should place the folder somewhere above the public_html directory. After doing that and revising the PEM location in the command line code everything worked!

Thanks again for this module!

Joined: 09/30/2008
Juice: 8

Hope you have found a solution. I installed Ubercart about a year ago and it seemed to be working fine with the Linkpoint gateway, After checking it recently I am confronted with the very same problem you reported here. I haven't upgraded Ubercart or changed the Linkpoint settings since first installing, perhaps the Linkpoint Gateway settings need changing.

Joined: 12/19/2007
Juice: 110

Great module, but I'm having trouble with declined transactions. Thought I'd cross-post this here in case anyone has developed a solution. The problem is that if someone's card is declined that order ID is now in Linkpoint's system and can't be used again. So, if the user were to click to click the Back button and change their CC# it would still not be able to process the order because it would detect a duplicate Order ID. So, my question is how would I reset the order ID after a declined transaction? Can I just increment it to the next available ID in uc_orders or is it also a session variable?

Joined: 12/19/2007
Juice: 110

Just a heads up that I solved the declined transaction problem mentioned above and posted the 6.x version as a module on d.o. at http://drupal.org/project/uc_linkpoint_api

le
le's picture
Joined: 07/05/2009
Juice: 2

Hi - I'm having the same issue as someone else in this thread. I've got this module installed and got the PEM file, and it gives me a "success, your order is complete!" message after I check out, but the information isn't going into my First Data / Linkpoint transaction log. I can't debug curl from the command line (as suggested in other posts) due to SSH restrictions on the machine I'm working on, and there's no errors in my php error log. Does anyone have any ideas how I can debug this? Is there some debugging code I can add to the module itself? Any help would be GREATLY appreciated.

Joined: 07/11/2009
Juice: 2

any idea on support for recurring billing?

I see nothing in any of the drupal controls for linkpoint allowing recurring subscriptions and nothing in the uc_recurring module allowing linkpoint.

Joined: 08/30/2008
Juice: 7

I will be glade to hear what is the status of this ?
I this stable & working ?

does firstdata.com using this module as a payment gateway ?

Thanks
Avior

Joined: 09/20/2009
Juice: 2

I need recurring billing/subscription billing. Is it available with this?

Joined: 08/19/2008
Juice: 190

If you're wanting to add the First Data Global Gateway, this is the module you should use. There is also a version of UC2x at the Drupal site. http://drupal.org/project/uc_linkpoint_api

--------
'Twas the end of the world, and you didn't even know it.

Joined: 07/13/2009
Juice: 10

Reply to http://www.ubercart.org/contrib/903#comment-38381

I want to add a couple of comments for others and for my own future reference.

Here: <path to your .pem file> you don't need the < and >, just the path/to/your/pemfile.pem

Here: <configfile>XXXXXXXX</configfile> you don't need to replace the XXX's for this test.

Here: <keyfile>/home/XXXXX/etc/linkpoint/XXXXXX.pem</keyfile > you DO need to replace the XXX's with your path and filename.

I continued to get this error after moving a site to a new server: curl: (58) unable to use client certificate (no key found or wrong pass phrase?)

It turned out the pem file had changed somehow during the transfer, and getting the pem again from First Data and pasting directly into the file in the command line editor fixed the problem.

Joined: 11/12/2009
Juice: 4

First off, Id like to thank everyone for their work on this module.

I'm having an issue though getting it to work. My host is positive that port 1129 is not blocked and Ive verified the path to the PEM file a million times. Ive also had the host install an SSL certificate. When I try to process a card using either my production account or live account I get the default error:

"We were unable to process your credit card payment. Please verify your card details and try again. If the problem persists, contact us to complete your order."

Under recent log entries in drupal, I see a error of type "uc_linkpoint_api" with no message attached every time I try to process an order. Also, simultaneously during every order I get an error of type "uc_payment" with the message "Payment failed for order 8: Credit card payment declined: Sorry - Could not connect to payment gateway." Do you think my host is lying to me about port 1129? Is there anyway I can prove it if so? Thanks for the help!!

Edit:
Im using drupal 6.14, UC 2, and UC linkpoint API 6.x-1.2.

Joined: 11/12/2009
Juice: 4

OK guys, after giving up and getting some sleep I found my problem! If you running on a windows server you need to make the path to the PEM file look something like this:
c:\\xammp\\keys\\xxxxxxxxxx.pem (notice the double slashes)

Also, I had to uncomment two lines in the module code:
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); //Comment out these two lines before actual use
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); //And this one.
According to the Magento plugin I found here, this is necessary for some people.

To debug the problem, I created a curltest.php file on my server with the following code (Notice the hard coded url):

<?php
$StoreID
= "xxxxxxxxxx";
$PEMfilePath = "c:\\xammp\\keys\\xxxxxxxxxx.pem";
$xml = "<order>
    <billing>
        <userid>1</userid>
        <name>John Doe</name>
        <company></company>
        <address1>938 New Garden</address1>
        <address2></address2>
        <addrnum>938 New Garden</addrnum>
        <city>New York</city>
        <state>NY</state>
        <zip>10001</zip>
        <country>US</country>
        <phone></phone>
        <email>generic@email.com</email>
    </billing>
    <shipping>
        <name>John Doe</name>
        <address1>938 New Garden</address1>
        <address2></address2>
        <city>New York</city>
        <state>NY</state>
        <zip>10001</zip>
        <country>US</country>
    </shipping>
    <orderoptions>
        <result>GOOD</result>
        <ordertype>PREAUTH</ordertype>
    </orderoptions>
    <merchantinfo>
        <configfile>"
.$StoreID."</configfile>
        <keyfile>"
.$PEMfilePath."</keyfile>
    </merchantinfo>
    <creditcard>
        <cardnumber>4111111111111111</cardnumber>
        <cardexpmonth>1</cardexpmonth>
        <cardexpyear>12</cardexpyear>
        <cvmvalue>111</cvmvalue>
        <cvmindicator></cvmindicator>
    </creditcard>
    <payment>
        <chargetotal>122.2</chargetotal>
    </payment>
    <transactiondetails>
        <transactionorigin>ECI</transactionorigin>
        <oid>3-13</oid>
        <invoice_number>3</invoice_number>
        <ip>127.0.0.1</ip>
    </transactiondetails>
    <notes>
        <comments>Pet Rock x4</comments>
    </notes>
</order>"
;
$xml = str_replace("&", "and", $xml);
$xml = str_replace("'", " ", $xml);

/*******************************************************************************
  * Start CURL Session
  ******************************************************************************/
 
$ch = curl_init();
 
$url = "https://staging.linkpt.net:1129";
 
curl_setopt($ch, CURLOPT_URL, $url);
 
curl_setopt($ch, CURLOPT_VERBOSE, 1);
 
curl_setopt($ch, CURLOPT_POST, 1);
 
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
curl_setopt($ch, CURLOPT_SSLCERT, $PEMfilePath);
 
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); //Comment out these two lines before actual use
 
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); //And this one.
 
$buffer = curl_exec($ch);

  if (

$error = curl_error($ch)) {
    echo
$error;
  }
 
curl_close($ch);

    echo

$buffer;
?>

This is similar to what focal55 did but in a shared hosting friendly way. I hope this helps someone!

Joined: 01/20/2010
Juice: 2

I had zero shipping and the XML send to the gateway has 'f' for the shipping value (I know this form the log file) when it should be zero ('f' presuably is first char of "free", and I had a "free" shipping item that triggered this error). Had to modify the line in class.linkpoint_api.php from
$xml .= "" . $pdata["shipping"] . ""

to:
$xml .= "" . ($pdata["shipping"]=='f'?'0':$pdata["shipping"]) . ""

Note this should also work for zencart and oscommerce...