Jump to content

PHP Paypal integration


Recommended Posts

For christ sake can some one PLEASE point me in the direction of SIMPLE paypal integration system that DOES NOT require bloody Composer, or any other irritating baggage.

 

And that does not have components scattered across GitHub in multiple zip files.

 

And that can be used via one SIMPLE include statement.

 

 

 

I found this https://github.com/paypal/rest-api-sdk-php.

 

Great!

 

Except that it uses PHP "uses" statements and my web server's version of PHP apparently does not support it.

 

So I proceeded to replace all the "uses' statements with explicit "requires" statements so that I don't have to use Composer. Which I find impossible to figure out how to use properly. And I simply don't want to have to use it because it adds unnecessary layers of complexity when a simple include or requires statement would suffice.

 

I then discovered this problem in all the files in the folder "Api".

 

All the files contain this at the top:

 

use PayPalCommonPPModel;use PayPalRestApiContext;

I found "RestApiContext" in the file "RestApiContext.php" - no problem.

But where the buggery is "CommonPPModel" - its not included in the zip file.

WHY the ###### would you not include this in the zip file given that it is in a requires statement?

 

And where the ###### is it?

Link to post
Share on other sites

Except that it uses PHP "uses" statements and my web server's version of PHP apparently does not support it.

Maybe the solution is to find a host that uses a version of PHP less than 8 years old. If you're on PHP 5.2 then you should be aware that support for it ended in 2011. Support for 5.3, which is where namespaces were introduced in 2009, ends this month. The current version is 5.5, it's been out for over a year. Find a host that cares about things like that instead of sticking you with an 8 year old version.

So I proceeded to replace all the "uses' statements with explicit "requires" statements so that I don't have to use Composer.

Use statements have nothing to do with Composer, use statements are about namespaces in PHP.

All the files contain this at the top:use PayPalCommonPPModel;use PayPalRestApiContext;I found "RestApiContext" in the file "RestApiContext.php" - no problem.But where the buggery is "CommonPPModel" - its not included in the zip file.

Again, those are not file paths, they are namespaces. That says that the code should import the PPModel class from the PayPalCommon namespace, and the ApiContext class from the PayPalRest namespace. If you think you can go around replacing use statements with require statements and expect everything to work, then you don't understand namespaces. You do not need to change anything about the code. In fact, if you do change anything in that code, then you're going to break it.The readme file includes instructions for running the samples and using the SDK:https://github.com/paypal/rest-api-sdk-php/blob/master/README.mdNotice the line that starts with "In case you cannot install composer on your machine"...If you open the composer.json file, the only thing it requires (other than PHP 5.3) is this:https://github.com/paypal/sdk-core-phpThat includes the PPModel class and the rest of the core classes.
Link to post
Share on other sites

This (in written form) is what paypal needs to put on their developer website:

 

https://www.youtube.com/watch?v=t_7GA1BZXPs

 

This makes sense to me, and now I have an understanding of how the whole express checkout process works.

 

But it wasn't easy to find and only after several very frustrating blind attempts with other sdk and class packages from github.

 

After this Paypals details on key/value pairs now means something to me.

 

Hope it helps others who are experiencing the same frustration that I have had to endure over the past week.

Link to post
Share on other sites

Maybe the solution is to find a host that uses a version of PHP less than 8 years old. If you're on PHP 5.2 then you should be aware that support for it ended in 2011. Support for 5.3, which is where namespaces were introduced in 2009, ends this month. The current version is 5.5, it's been out for over a year. Find a host that cares about things like that instead of sticking you with an 8 year old version.Use statements have nothing to do with Composer, use statements are about namespaces in PHP.Again, those are not file paths, they are namespaces. That says that the code should import the PPModel class from the PayPalCommon namespace, and the ApiContext class from the PayPalRest namespace. If you think you can go around replacing use statements with require statements and expect everything to work, then you don't understand namespaces. You do not need to change anything about the code. In fact, if you do change anything in that code, then you're going to break it.The readme file includes instructions for running the samples and using the SDK:https://github.com/paypal/rest-api-sdk-php/blob/master/README.mdNotice the line that starts with "In case you cannot install composer on your machine"...If you open the composer.json file, the only thing it requires (other than PHP 5.3) is this:https://github.com/paypal/sdk-core-phpThat includes the PPModel class and the rest of the core classes.

For something that is now, in hindsight, very simple to implement, all this namespace business seems, to me, to be completely unnecessary layers of complexity.

Link to post
Share on other sites

gregaryb,

 

In this thread: http://w3schools.invisionzone.com/index.php?showtopic=50827 you made some time ago, I responded by supplying a link to another thread that basically goes into what the video above is basically about. Just thought I'd let you know incase you missed it. Good luck. :good:

Edited by Don E
Link to post
Share on other sites

gregaryb,

 

In this thread: http://w3schools.invisionzone.com/index.php?showtopic=50827 you made some time ago, I responded by supplying a link to another thread that basically goes into what the video above is basically about. Just thought I'd let you know incase you missed it. Good luck. :good:

No I didn't spot that reply but thanks anyway.

 

After a short stint writing some user documentation (as a programmer), at my last IT job some years ago, I realised why programmers generally make such poor manual writers. I had to totally change my mindset in order to make the documentation of any use to the testers.

 

The Paypal developer website epitomises 'programmer' designed documentation unfortunately...

Link to post
Share on other sites
  • 2 weeks later...

For something that is now, in hindsight, very simple to implement, all this namespace business seems, to me, to be completely unnecessary layers of complexity.

Namespaces become completely necessary when integrating several unrelated classes into one large application. Modern PHP APIs are geared at experienced programmers rather than someone looking to add some sort of basic functionality to a website that couldn't be considered an actual application. By "modern", I mean anything targeting PHP 5.3 and greater.
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...