setting up a ssl connection ( Bibit / worldpay )

293 views
Skip to first unread message

a.k

unread,
Jul 10, 2009, 7:59:19 AM7/10/09
to Active Merchant

Hi,
I'm trying to extend active merchant to support the RBS worldpay
global gateway (formerly known as Bibit).

My first question is : Has anyone implemented this yet ?

if not. I'm having some trouble and hoping someone can shed some light
to it. For your information BiBit only supoprts an XML API.

It says in the bibit documentations
"To submit the XML order you have to set up an HTTP(S) connection to
the Payment Service. How you create a connection with another RBS
WorldPay server depends on the specifications of your platform...When
setting up the connection, use your merchant code (always in capitals)
as the login and your XML password as the password...Once you have set
up the connection to the Payment Service, your system has to post the
XML order.
Make sure the HTTP content type is ”text/xml”!... "

Now the problem is all the gateways which support SOAP API in Active
Merchant, they take the username and password as xml elements. But
there is not the case with BiBit. There is so provision for supplying
passwords in the XML DTD.

They have provided me with a sample php code which has this entry

----------------------------------------------------------------------
function Bibitstart($debug) {
$this->debug = $debug;
if($this->debug)
$this->url = "https://" . $this->merchantCode . ":" . $this-
>merchantPassword . "@secure-test.bibit.com/jsp/merchant/xml/
paymentService.jsp";
else
$this->url = "https://" . $this->merchantCode . ":" . $this-
>merchantPassword . "@secure.bibit.com/jsp/merchant/xml/
paymentService.jsp";
}

function CreateConnection() {
$ch = curl_init ($this->url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->xml); //$xml is the
xml string
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/
xml"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_NOPROGRESS, 0);

// echo "ch: $ch<HR>" ;

$result = curl_exec ($ch); // result will contain XML reply from
Bibit
curl_close ($ch);
if ( $result == false )
print "Curl could not retrieve page '$this->url', curl_exec
returns false";
return $result;
}
----------------------------------------------------

I have built the gateway on the basis on PayPal gateway and for
authentication just used

TEST_URL = "https://<username>:<password>@secure-test.bibit.com/jsp/
merchant/xml/paymentService.jsp"


Is this enough or am i missing something? I'm getting authentication
error..

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>401 Authorization Required</TITLE>
</HEAD><BODY>
<H1>Authorization Required</H1>
This server could not verify that you
are authorized to access the document
requested. Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.<P>
</BODY></HTML>

ActiveMerchant::ResponseError: Failed with 401 Authorization Required

The username and password is correct , cause they work with the sample
php code.
Is there any other way to "establish a connection" before posing xml
in Active Merchant?

Quick reply would be appreciated.

Thanks
A.K

Cody Fauser

unread,
Jul 11, 2009, 1:27:21 PM7/11/09
to activem...@googlegroups.com
Take a look at the WirecardGateway in wirecard.rb. It uses HTTP Basic
authentication. Take a look at #commit where the "Authorization" HTTP
header is being set to the HTTP Basic encoded credentials.
--
Cody Fauser
http://shopify.com - e-commerce done right
http://www.codyfauser.com - blog
http://peepcode.com/products/activemerchant-pdf - ActiveMerchant PeepCode
http://www.oreilly.com/catalog/rjsrails - RJS Templates for Rails

a.k

unread,
Jul 14, 2009, 6:24:53 AM7/14/09
to Active Merchant
Thanks, It worked perfectly. I'm able to get myself authenticated. I
knew it had to do something with the headers but was still figuring
our in the Net::HTTP docs :).

Anyways, there is one point of concern.
Bibit has the card holder name as a compulsory field. I looked through
the credit_card structure and it seems that there is no provision of
overriding the

name = first name + last name

Bibit has a great testing feature where you can set the card holder
name to simulate various situations
like if you set name = "REFUSED" it will refuse the transaction and
so on.

Is it currently possible to keep card holder name as separate entity?

In my situation we have to support both paypal and bibit.
As far as i think i can subclass CreditCard class and use the child as
Credit card for bibit.

Any ideas ?

thanks
-A.K

Cody Fauser

unread,
Jul 14, 2009, 5:08:05 PM7/14/09
to activemerchant
If you're just testing these failure conditions in the remote tests
then I would use mocha to stub the name the credit card returns:

@credit_card.stubs(:name).returns("REFUSED")

Subclassing the credit card isn't really necessary because it doesn't
matter in the live environment.

2009/7/14 a.k <ask4...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages