cURL

What exactly is cURL?

And why would you use it to submit payment information to a Payment Gateway as opposed to some other method or tool?

Debbie

Correct. At their end it will just like any other http connection that a browser would make. The only difference will be the header which will show that its php making the connection not internet explorer, mozilla etc. As long as they have an api then this shouldn’t be a problem unlike some websites which restrict what browsers they will support (EG my bank refuses to let me logon using seamonkey but I can use cometbird which is a IE clone). APIs are different because they’re not really dependant on the users browser being secure or the display being correct. They’re just providing a way for you to interact with their system and exchange data which is much simpler.

A word to the wise though, not using cURL is doable but its not ideal since you’ll have to do a lot of testing to ensure the code you use can do what you want. I’ve only ever found one function that does a half decent job and it has a lot less features than cURL and still returns errors sometimes.

Client Url library.

It’s basically PHPs implementation of http. It’s basically ready to go. You tell it where you’re going, what data you’re submitting, what options you want and it does it for you.

Job done.

You could use other scripts… I had one which was over 300 lines in length for one function… and even then it sometimes errors. You basically have to trust that the person who wrote it knew what they were doing and knew all about http headers etc. With cURL you don’t need to worry as long as you done your bit correctly it will do its bit with no problems.

cURL also makes it very easy to send information by POST. Anyone can use get_file_contents() to get a url by GET but sending POST data is far harder since its not passed in the url as a parameter. Again cURL makes it a lot easier to do this.

The first time I came across cURL I wasn’t terribly up for it as it looked rather complex to use. In reality its like any other php code. You need a few lines to tell it what you’re doing and thats it - once it works job done. The php manual link I gave you at the top will be very useful to you as it will also have lots of user contributed notes and code samples.

What other method or tool Debbie? cURL is pretty flexible, more so than most of its alternatives.

:slight_smile:

I asked first! :stuck_out_tongue:

cURL is pretty flexible, more so than most of its alternatives.

:slight_smile:

I already looked it up on PHP.net and that didn’t really help.

I guess I wasn’t really sure what it is, or why I care about it?! :-/

For submitting a payment for, I guess you need (??) cURL to submit the data using POST and HTTPS, is that it?

Just trying to understand it, and how it might relate to the Payment Gateway I may be using.

Like, is cURL an issue on my side of the equation (e.g. on my web host), or is it something my Payment Gateway has to have or approve?

Debbie

cURL is a feature of PHP. PHP is on your server so its something that YOU need to use.

cURL basically acts as a browser on the internet. It does the same thing as Internet Explorer, Firefox, Netscape, Seamonkey, Chrome, etc in that it makes http requests, sends data and headers and then receives a http response like any browser would. The only difference is that cURL doesn’t display the result because it isn’t a display engine. It literally just downloads hyertext and file streams as instructed by you.

Yes you will need to use it and yes it will almost certainly be available to you (assuming your host has it enabled). cURL is a good thing and its one of PHPs best tools because it makes internet communication very easy as you don’t have to write your own socket code, header processing code etc.

If looking it up on php.net didn’t really help then you’re probably not understanding it properly. Read it and then re-read it until it starts to make sense. I know the name doesn’t do it any favours but you have to remember that it is basically does the same as internet explorer without a display.

So how would you submit a payment form normally if cURL didn’t exist?

Is it better than using the browser to do that?

If looking it up on php.net didn’t really help then you’re probably not understanding it properly. Read it and then re-read it until it starts to make sense. I know the name doesn’t do it any favours but you have to remember that it is basically does the same as internet explorer without a display.

Well, that’s what you get when developers do documentation… :wink:

For instance, this hardly explains what cURL is, its purpose for existing, or why I should read more…

Introduction

PHP supports libcurl, a library created by Daniel Stenberg, that allows you to connect and communicate to many different types of servers with many different types of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading (this can also be done with PHP’s ftp extension), HTTP form based upload, proxies, cookies, and user+password authentication.

Blah!!!

That is why I posted here, because you guys do a much better job of speaking English than a lot of stuff on PHP.net!! :slight_smile:

Thanks,

Debbie

Hang on let me double check I’ve got this right. You are submitting payment details from a script on your website to a payment processor yes? - OR are you trying to process a form that is on your website being submitted to your script?

The impression you initially gave suggested that you were trying to communicate from your script to another website. If thats what you’re doing then yes cURL is for you. It will let your script act like a browser and make a request to an external server. The reason I’m now asking is because you’re now asking about submitting a form. You then asked is it better than using a browser… using a browser requires a person to click the send button so now I’m not sure quite what you’re trying to do. As I say initially it sounded like you were trying to run an automated server side request to another system but now you’re asking about using a browser I’m not sure what you’re really trying to do.

If cURL didn’t exist then there would no doubt be some other library of code someone else has come up with somewhere which would do the same job. I’m sure if you hit google you’ll find plenty of other versions but none of which will have the the flexibility of cURL. You only need to use google to find examples of how to use it.

The php manual is pretty clear but it assumes you have a technical understanding of how the internet works, what various protocols are and how to use them etc. If you’re not technically minded or you’re new to the php programming field then it will sound a lot like jargon. It’s one of those things… the more you use it the clearer it becomes.

I am stressing out over which payment gateway to use and trying to figure things out.

I would be taking a simple “payment form” and submitting Name, Billing Address, and Credit Card details to some Payment Gateway to have them process the payment.

On example I saw - I think Authorize.net - used cURL, and so I was like, “Hmmm… wonder what that is and why they are using and the other Payment gateway isn’t?!”

The impression you initially gave suggested that you were trying to communicate from your script to another website.

Correct, I will be submitting a Payment Form from my website to the Payment Gateway’s server.

If thats what you’re doing then yes cURL is for you. It will let your script act like a browser and make a request to an external server. The reason I’m now asking is because you’re now asking about submitting a form. You then asked is it better than using a browser… using a browser requires a person to click the send button so now I’m not sure quite what you’re trying to do.

Let’s say I have a simple HTML Form that gathers Name, Billing Address, and Credit Card Info. (The page would technically be a PHP page.)

The enters their payment info, hits a “Next” button, my PHP redisplays what they just entered and asks them to confirm everything, and then they hit a final “Place Order” button.

From there, my HTML Form on my PHP Page would submit that information to the Payment gateway’s server for processing.

I guess I don’t know how you submit forms. From the books I’ve read, they always seemed to just use some PHP, but maybe that is because they were submitting the page to themselves and not outside.

I am a total newbie on this, so pardon any dumb questions!! :blush:

As I say initially it sounded like you were trying to run an automated server side request to another system but now you’re asking about using a browser I’m not sure what you’re really trying to do.

Hopefully my explanation above answers that.

The php manual is pretty clear but it assumes you have a technical understanding of how the internet works, what various protocols are and how to use them etc. If you’re not technically minded or you’re new to the php programming field then it will sound a lot like jargon. It’s one of those things… the more you use it the clearer it becomes.

I just remember POST and GET, but that was when I studied this long ago, and I have obviously forgotten a lot of what I studied, PLUS you know how academic most PHP books are!! :lol:

Thanks,

Debbie

Yep you need cURL then to open a connection FROM your server to the payment processor.

Authorize.net might show you a curl sample and others might not. Thats just how each developer does things. cURL will do exactly what you want.

So if I wanted to submit my form data to the Payment Gateway using cURL, then they shouldn’t care, right?

In other words, how I send them data is immaterial to their server as long as I send the correct data in the correct format, right?

Thanks,

Debbie

Okay, Tango, thanks for the information.

Debbie

P.S. Know anything about working with Payment Gateways? :smiley:

No not really but I’ve never needed to.

If you get stuck, download Teamviewer and PM me. I’ll hop over to your desktop and take a look with you. Not today though… it’s 1am and I’m about to hit the sack…

EDIT: I just noticed your post count and mine are reverse… You have 614 and I have 416 :smiley:

Well, there are some places that no men are allowed to go… And my desktop is one of them!! :wink: :rofl:

Not today though… it’s 1am and I’m about to hit the sack…

Where is it 1:00am now?! (:

EDIT: I just noticed your post count and mine are reverse… You have 614 and I have 416 :smiley:

It is a sign from Heaven that we are soul mates and that you have been sent to help your long lost twin out!! :stuck_out_tongue: :stuck_out_tongue:

Debbie

Lol, no worries but the offer is still there if you need it. Note though that I don’t want to be exposed to your authorize.net login or security details etc so if you do take me up on the offer of a desktop session please setup a test account which they offer free. That way your authorize.net account is still secure.

United Kingdom… although with the way Scotland, Northern Ireland and Wales are being given their own independence it’s more like the Disunited Kingdom these days. Centuries ago the last time this happened it led to civil war.

Programming soul mates maybe but I already have my love soulmate - she even puts up with me staying up late :smiley:

Thanks for the offer, but that is one place I won’t go for security reasons. (Way too much - like my Swiss Bank Account # - on my laptop!! :slight_smile:

United Kingdom… although with the way Scotland, Northern Ireland and Wales are being given their own independence it’s more like the Disunited Kingdom these days. Centuries ago the last time this happened it led to civil war.

Ha ha

Aren’t you guys on Daylight Savings Time?

Seems like it should be later there?!

Programming soul mates maybe but I already have my love soulmate - she even puts up with me staying up late :smiley:

Good find!

Well, I’m a SitePoint regular, so say “Hi” when you’re around!

I definitely will need some PHP help!

Thanks,

Debbie

No worries. In honesty it’s probably best like that but you asked if I knew anything about payment gateways so I thought I’d offer just in case as you’re also taking on cURL.

Yes we’re on DST I think… I’ve always been a bit confused by DST. I always thought it meant Dual Summer Time but others refer to it as Daylight Saving Time… despite the fact we apparently use Daylight saving to ensure we have enough light in the mornings during winter when we’re GMT +0. Every year the clocks go forward and then back and every year we hear the same arguements about whether we need to do it or not and how it will affect the scottish… give them their own time zone and be done with it :smiley:

I only hang around in the PHP section of sitepoint. I like to help other people who have obstacles they need help with. I’ve spent days solving some problems when I was learning that I can now help others to solve in minutes to save them the frustration I suffered. I also have a motivational problem - I find it hard to work on my own code yet easy to work on other peoples. Strange I know but I think the problem is with my own sites they’re never finished as I’m always thinking of new features faster than I can code them. Eventually it kinda gets you down and you feel beaten by it. Helping other people with php keeps my mind active with php if that makes any sense…

Well, I believe in giving back to my community as well, so for those who feel unmotivated unless they help me, I say, “Why not?! Let them help Debbie!” :lol:

Seriously, I am under the gun to get some things done, so anyone who can help educate me on PHP (or other topics) is welcome!

If I ever get my website done, then maybe I can spend more time studying books and get to where I am rich and famous and have time to st around and help others too. (We can dream, can’t we?!)

Thanks,

Debbie

Can I use cURL to send an XML-string-thingy?

Do you use cURL to read information from another server as well?

Debbie

Sorry for the delay… had to fit some sleep in :wink:

Theoretically yes but I’ve never used XML in php as I’v never had the need. I’m sure now I’ve said that I’ll regret it soon…

cURL does exactly what a browser does. It makes calls to a http webserver like it is a browser so anything the server outputs will be read by cURL whether the server outputs XML, CSV, or just lines of data seperated by the newline character cURL will read it.