Angell EYE PayPal PHP SDK Class Library
Get the PayPal PHP SDK Class Library
Download the PayPal PHP SDK by Angell EYE and save loads of time integrating PayPal APIs into PHP applications.
Looking for Live Help?
Schedule a live meeting with Drew Angell, PayPal Certified Developer, and get all of your questions or concerns answered.
Featured PayPal Products and Services
PayPal for WooCommerceFREE!
WooCommerce Multiple PayPal Accounts Plugin$119.99
PayPal Shipment Tracking for WooCommerce$49.99
PayPal for WooCommerce – Credit Card Split Payment
Offers for WooCommerce$59.99
WordPress PayPal Invoice Plugin$20.00
PayPal Webhooks for WordPress$79.99
Is it possible to integrate to a Zend framework project?
Sure. It’s an object-oriented class library, so you can use it within any other framework you want. For example, I have a version specific to CodeIgniter. I’ve been meaning to make one specific to Zend but just haven’t had the time. I’m sure you can do it without much effort, though, or even just use it as-is within a Zend project.
have u shared the codeigniter one?
I don’t have a video for it specifically, but I have shared the CodeIgniter version of the PayPal library.
hello i was using your angelleye-paypal-class-library in php mvc frame work customized by us.
but angelleye-paypal-class-library it is not working with that can you help me please.
[Errors] => Array
 => Array
[Category] => Application
[Domain] => PLATFORM
[ErrorID] => 580046
[Message] => An invoice already exists for the merchant with this invoice number: 11111111s
[Parameter] => 11111111s
[Severity] => Error
[Subdomain] => Application
[Ack] => Failure
[Build] => 7236486
[CorrelationID] => 26ac6dcbee1a1
[Timestamp] => 2013-08-07T00:30:07.390-07:00
[XMLRequest] => ReturnAllen_USndudevi@email@example.com
1036 Crawford StDetroitMI48209US
1036 Crawford StUS
[XMLResponse] => 2013-08-07T00:30:07.390-07:00Failure26ac6dcbee1a17236486580046PLATFORMApplicationErrorApplicationAn invoice already exists for the merchant with this invoice number: 11111111s11111111s
Looks like it’s working just fine, but you got an error because the invoice number you sent in the request has already been used in your PayPal account and can’t be used again. I am a little confused, though, because the values look blank in the request. Did you attempt to populate those and your values aren’t carrying over or did you mean to leave them empty, but you get this error when they’re empty..??
Hey Thanks for this Its really helping me out. Your the Best!
No problem. Glad it’s working for ya!
this is a great lib!
but i have one problem with ‘setExpressCheckout’ and parallel payments.
testing only in sandbox.
it always show the error : “Instant Update API callback is not supported for parallel payments.”
but i dont set callback
There must be something in your request data that’s causing it to include those in the call to PayPal. If you want to send me a sample of the page you’re working with I’ll take a look and let you know what the problem is.
I have sent you the link to the code per contact form.
I’m similarly having the same problem. Was this ever resolved?
Yes, you need to make sure things like the survey question, shipping options, etc. aren’t enabled in the SEC request. If you want to send me your SEC file I’ll take a look and help you figure out what’s causing it.
My SEC fields are as follows (http://pastebin.com/QpKuV3N4):
$SECFields = array(
‘token’ => ”,
‘maxamt’ => ”,
‘returnurl’ => $domain . ‘paypal/class/DoExpressCheckoutPayment.php’,
‘cancelurl’ => $domain . ‘paymentfail.html’,
‘callback’ => ”,
‘callbacktimeout’ => ”,
‘callbackversion’ => ”,
‘reqconfirmshipping’ => ”,
‘noshipping’ => ”,
‘allownote’ => ‘1’,
‘addroverride’ => ”,
‘localecode’ => ”,
‘pagestyle’ => ”,
‘hdrimg’ => ”,
‘hdrbordercolor’ => ”,
‘hdrbackcolor’ => ”,
‘payflowcolor’ => ”,
‘skipdetails’ => ‘1’,
’email’ => ”,
‘solutiontype’ => ‘Mark’,
‘landingpage’ => ‘Billing’,
‘channeltype’ => ”,
‘giropaysuccessurl’ => ”,
‘giropaycancelurl’ => ”,
‘banktxnpendingurl’ => ”,
‘brandname’ => ‘Zookie’,
‘customerservicenumber’ => ”,
‘giftmessageenable’ => ”,
‘giftreceiptenable’ => ”,
‘giftwrapenable’ => ”,
‘giftwrapname’ => ”,
‘giftwrapamount’ => ”,
‘buyeremailoptionenable’ => ‘1’,
‘surveyquestion’ => ”,
‘surveyenable’ => ”,
‘buyerid’ => ”,
‘buyerusername’ => ”,
‘buyerregistrationdate’ => ”,
‘allowpushfunding’ => ”
Try removing the value for buyeremailoptionenable. If that alone doesn’t work try also removing the value for brandname.
I tried removing buyeremailoptionenable and then brandname also with no success.
Is there anything else it could be or anything else I could try? I’m quite desperate to resolve this
Hmmm…everything else is pretty straight forward. Send me a copy of your SetExpressCheckout.php and I’ll see if I can reproduce the problem. You may need to double check $PayPalRequest array to make sure the survey questions, shipping options, etc. aren’t being passed in there.
Just as I was in the process of sending it to you, I spotted the problem!
The problem was although I did not enable a survey, I was setting SurveyChoices and passing them to the PaypalRequest. Didn’t notice it initially because it is outside the setting of the SEC fields. But I have removed it and everything appears to be working correctly now.
Thank you for your help and in particular your quick responses, very much appreciated.
Glad you got it worked out! Let me know if you run into any other issues.
I really want to use your class in drupal CMS. For this i have to make a custom module for the same.
Can you give me an idea about how i use this script for PayPal adaptive payments…means which exact files i have to call for the same to process chained based payment. I have downloaded your script from php classes.org but there are so many files. I want to use process PayPal adaptive payments so please mentioned the required files which i need to integrate.
Please help me
Thanks in advance
For Adaptive Payments you’ll just the Pay API, so the Pay.php file is really all you’ll need to work with other than filling in your credentials in the config.php file.
Let me know if you have troubles and I’m happy to help further.
Thanks for the class!
Is this project somewhere on github?
I just have some optimalization that you might want.
No problem, glad you like it. It’s not Github yet. I’ve been meaning to get it up there but I just haven’t learned enough to Git yet to make it work well for me. If you want to send me your adjustments I’ll take a look and maybe add them to my original stuff. Eventually I will indeed get it on Github.
I have been trying to figure out the GetBasicPersonalData.php file, but all it ever returns is
[Errors] => Array
 => Array
[Category] => Application
[Domain] => PLATFORM
[ErrorID] => 500000
[Message] => Internal Error
[Severity] => Error
[Subdomain] => Application
This is in sandbox, could you tell me how to use this one
I think I may have missed a step in the headers being sent for these Permissions API calls. Unfortunately, the documentation links for Permissions at x.com are returning 404 not found right now, so I can’t look to see what it might be.
I’ll update here again once I get more info on what could be going on here. You might also want to submit a ticket to MTS at http://www.paypal.com/mts. You can provide the XML request and response (which the library makes available to you) and they can help us figure out what’s going wrong with it.
Please delete my last message, now I know how to work with your class aleady 🙂 My I ask you how we solve those problem below:
– Credit card doesn’t have enough money to pay for orders
– Credit card has an invalid account number
– Credit card has been expired date
– Credit card has an invalid security digits
In any of those situations the API would simply return an error that the payment failed. Address verification and CVV data can be adjusted in your Fraud Management Filters within your PayPal account.
Hope that helps.
Hi, my compliments for your great Job with this class. It helped me a lot to setup my mind about how to integrate paypal in ecommerce solutions.
I have a point of discussion. Using your class for a setExpress Checkout action Method. I’ve found that on the very first call on setExpressCheckOut a Notice will be displayed on line 1481. Saying thet “TOKEN” index is not defined in the HASH used to set up the redirect URL:
Here’s my changes to manage the notice.
if(isset($NVPResponse[‘TOKEN’]) && $NVPResponse[‘TOKEN’] != ”)
$NVPResponseArray[‘REDIRECTURL’] = ‘https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&’ . $SkipDetailsOption . ((isset($NVPResponseArray[‘TOKEN’]) && $NVPResponseArray[‘TOKEN’] != ”)?’&token=’ . $NVPResponseArray[‘TOKEN’]:”);
$NVPResponseArray[‘REDIRECTURL’] = ‘https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&’ . $SkipDetailsOption . ((isset($NVPResponseArray[‘TOKEN’]) && $NVPResponseArray[‘TOKEN’] != ”)?’&token=’ . $NVPResponseArray[‘TOKEN’]:”);
Please let me know if this helps, or if I’ve misunderstood the intended usage of your class.
(In my opinion the Token isn’t set in the first call of setExpressCheckout, it will be populated after the first response by Paypal, so I can’t pass a token value at first API call)
I noticed that myself and it’s actually fixed in this next version I’ll be releasing before too much longer. It only happens if your SEC call fails for some reason and no TOKEN is available, and it’s only a warning so it wouldn’t cause the app to halt at all. Again, though, I have fixed it so this warning doesn’t occur. I just need to tie up some more loose ends and then I’ll get this new version released.
Thanks for the feedback, though! Always appreciated. I’m sure I have other little mistakes in there, too, so if you find them please let me know.
This php library will support paypal payments advanced ?
Not right now, no. It’s for API’s only. Payments Advanced is just a basic form post directly to PayPal so you don’t have to put together request strings and parse response strings, etc. I may include it in the library at some point, but it’s not something I’ve focused on yet. Sorry.
First, I wanted to say thank you for the great videos and feedback that you have provided. Not everyone provides feedback, but you’ve been excellent about responding to everyone and we all appreciate it!
Second, I just wanted to follow up and ask if you have added anything for PayPal Payments Advanced or if you know of any good videos on how to set up PayPal Payments Advanced?
Thanks again for all of your videos and feedback!
I do not yet have that built into the class library, but PayPal has a 2-part video on YouTube that covers the steps for setting up PayPal Advanced. Here’s part one. You could use PayFlowTransaction.php as a template for making the calls the videos cover, and you would just need to adjust the parameters accordingly.
First off thanks a lot for your library of code its awesome!
So my overall goal for using your library of code is to embed a paypal iframe in my site for users to make payments through paypal. I’m currently following this tutorial https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_APIntro.
If you ctrl+f “Setting Up Web Pages to Invoke the Embedded Payment Flow Using a Lightbox”, you will see the step by step instructions I’m following.
So I’ve successfully used your library’s pay.php file to get an api pay key. But when I try to use this key in the form
“action” link. I receive the error in paypal” Your payment session has expired. Please return to the participating website and try again.”
Any idea what’s going on? I’m lost.
Thanks in advance for your help and once again thanks for the awesome library of code. It really makes up for paypal’s poor documentation.
The first thing I would do is get it all setup and working outside of the lightbox. Make sure you can call the Pay API which will give you back your PayKey and a ReturnURL generated for you by the library. See if you can load this RedirectURL without any problems or if you get the same problem there.
Could you please help me how to use your class files in yii framework.
Actually I want creating recurring payment profiles for each user while registration.
Thanks in advance.
I’m not familiar with the Yii framework, but upon quick review it looks like a standard MVC framework which means my library should plug into rather easily. It’s all object oriented so it should just be matter of extending the Yii classes to turn these into custom Yii libraries.
Great stuff no doubt and many thanks for building it and making it available.
I want to do chained payments and I have made it work perfectly in sandbox. Im just wondering, when I create the payment on a live server, do I need to send it on a secure line to prevent eavesdropping?
Because I see I need to put in the paypal password in the config file, is that something that is sent over to paypal when I create the payment before redirecting the user to the login. Or do I only need secure line if Im doing some of the more advanced stuff like preapproval or something?
The API endpoint is an https:// server so everything you post is encrypted. You only need SSL certs if you’re processing credit cards directly on your server. With the majority of PayPal’s services it’s optional because they’re handling the processing for you.
Thanks for the classes but i still seem to be confused with what i am trying to do. There is quite a lot of information there.
I am trying to process an Adaptive Payment on my site. I want buyers to be able to pay multiple sellers for multiple items all at one go from their shopping basket. I would like this to be a direct payment. I took a look at your classes but i am unable to see the the classes to use to process adaptive parallel payments.
Much appreciated, Thanks
You’ll be utilizing the Pay API with multiple receivers. If you want parallel (where the buyer will see the split) you don’t need to set a primary receiver. If you’d rather do chained payments (where the split will be hidden from the buyer) you’ll need to set one of the receivers as primary in your Pay request.
Thanks, Which of the classes do i start with?
I have setup a social network that just needs to accept a single payment that gets split between two paypal business accounts. How much would you charge me to program this for me. If you are interested in doing this can you call 817-773-7062 and if I can not answer please leave a message and a time when I can call you back.
I’ll give you a call today or tomorrow. Need to finish up some projects before discussing something new.
Hi Andrew. Thanks for your response to my paypal question earlier today. It looks like the only file I’ll end up using is Pay.php — but I’ll keep them all close at hand!
Ok, so Pay.php includes the config.php and the paypal.class.php (which includes the adaptive classes), so I just include the file Pay.php where I need access to your classes. This looks good.
I’m editing the config.php file now. I’m wondering about the $developer_account_email. It says this is needed only for Adaptive Payments. Is that my real developer/sandbox email? Or is that my sandbox fake business account email? I guess it just seems odd that paypal requires any sandbox info to work.
Am I mis-reading that?
Hmm. Wait.. I thought at first each file was its own class with associated functions. Am I supposed to include Pay.php in my code, or do I just include the paypal.class.php (and config)? It looks like the Pay.php file (and all the others are really samples of usage. Is that right?
If you’re simply going to use the library directly you’d just include config.php and the paypal.class.php. This would give you access to all of the methods included with the library.
All of the files included, like Pay.php, are simply empty template files prepared for that particular API request. It just gives you a real quick starting point for every call. You can either work directly from those files or from your own, but you’ll need all of those request arrays one way or another.
Let me know if you still have more questions about that.
$developer_account_email is the email address you use to login to http://developer.paypal.com. It gets passed into the header of Adaptive Payments requests, and I’m pretty sure it’s just used as a way for PayPal to track where things are coming from. Looks like you’ve got a follow-up comment here regarding which files to include so I’ll respond with more detail there.
Sandbox: recurring profile not start payment charge
I have several days trying to make it run the payment instruction
after you create the profile but this never happens.
I use your library for this propose:
There is an example of the way I am creating the profile:
2. Click here to continue.
3. In login form I use:
4. After login and confirm this redirect to:
5. The profile is created with start date today, but the payment is never charge.
Where I am wrong, why not start charging paypal,
if I do the same process with the buttons on subscriptions
payment is executed after creating the profile
I’m very sorry for the delay getting back with you. I would need to get a look at your actual requests/responses in order to help you troubleshoot this.
Please update me how to use it for PAYFLOW PRO.
You just need to add your credentials to the config.php file and then open up the PayFlowTransaction.php file and fill in the parameters accordingly.
HI, I just want to ask some help,how can i use this php class library for paypal, does this will work in sandbox,because i am just using sandbox and i want to try using IPN in my localhost,please help me i am newbie on this,please provide me how to start using this to achieve my goal to test IPN in localhost.
Thank you 🙂
Yes, the library is designed to work easily with both the PayPal sandbox and production servers. You simply pass in a true/false value for sandbox when you create the class object. My library does not have IPN built in to it, though. Also, when using IPN you can’t use “localhost”. You’ll need to use your public IP or setup a domain name that points to it.
does these library support Paypal Standard?
Right now the library supports some of the Button Manager API calls, but it doesn’t handle Payments Standard any other way. I do have plans of adding it, but it will be a few weeks before I’m able to get that done and release an update.
hi ..i am new in phhp…i want devlope chain payment system of paypal …when sender send $100 then 1st primary reciver recive only $90 & 2nd rec Recive $10 … how i can do that plz help me
You would use the Adaptive Payments platform for that, specifically the Pay API. You can set it up as a Parallel or Chained payment, the difference being that with parallel payments the payer would see the split that will happen, but with a chained payment that would be hidden and they would only see a single receiver.
Basically, though, you would just create the Pay call with multiple receivers in the request. Each receiver would be set to the amount they should receive in the payment and the library will handle the rest.
There is a Pay.php file included in the samples folder. You might want to look at the PayWithOptions sample, too, as that allows you to provide more details with the request. It actually combines both Pay (CREATE) and SetPaymentOptions in a single method.
Great work — you’ve served many, many people. Very impressive!
I’m having a few issues though. I’m using the Adaptive payments as you mentioned in the post I’m replying to. Currently, when a user clicks to ‘Pay’ on my website, a popup appears and they must then enter their PayPal email address.
In addition, the auction listings that a user creates on our marketplace can be in either $ (USD) or £ (GBP), but it seems that if the user creates a listing that isn’t in their main PayPal currency, they can’t receive payment.
Is the PayPal email popup necessary and can we allow users to receive payments in currencies other than their main PayPal currency?
Thanks for the kind words. I think I answered you on StackOverflow..??
I have a question about the delayed chained payment. And I read quite a lot of your posts on StackOverflow. That’s been very helpful. The thing is how I can create a delayed chained payment with a customized set of payment details? Because I wanna store the information of the item that the buyer wanted and when I got the IPN from PayPal and update it in the database. I think that the setPaymentOptions works on activeType=>Pay but not pay_primary. Thanks a lot!
You would actually call Pay with an actiontype of CREATE and then call SetPaymentOptions behind that to add in the details prior to redirecting the user to PayPal. If you’re using my class library there’s a separate file called PayWithOptions that combines these to make it easier.
Thanks for the reply.
When I’m using your class library from GitHub, I got a require_once error.
And I commended out the unnessary require_once and run the PayWithOptions.php.
I still got an error which is Undefined variable: ResponseDataArray in …/includes/paypal.adaptive.class.php on line 668
Am I missing anything?
I got the idea of create and setPaymentOptions then make a delayed chained payment call but think that using your library is more convinient to do it.
What “unnecessary require_once” are you referring to? You should be requiring the include.php, paypal.class.php, and paypal.adaptive.class.php at the top of your PayWithOptions.php file. You can click here to see the same sample script on my test server and it runs just fine.
I want to convert currency in chained payment using paypal……
but i need to include AdaptivePayment.php but this file i am not found anywhere.
Please help me.
There isn’t an AdaptivePayment.php. It would be Pay.php, Preapproval.php, etc. depending on which API in the Adaptive Payments platform you’re attempting to use.
//”I am use this code for convert currency but this file want to include AdaptivePayments.php”
detailLevel = 0;
$requestEnvelope->errorLanguage = ‘en_US’;
// Our base amount, in other words the currency we want to convert to
// other currency type. It’s very straighforward, just have a public
// prop. to hold de amount and the current code.
$baseAmountList = new CurrencyList();
$baseAmountList->currency = array( ‘amount’ => 15, ‘code’ => ‘USD’ );
// Our target currency type. Given that I’m from Mexico I would like to
// see it in mexican pesos. Again, just need to provide the code of the
// currency. On the docs you’ll have access to the complete list of codes
$convertToCurrencyList = new CurrencyCodeList();
$convertToCurrencyList->currencyCode = ‘MXN’;
// Now create a instance of the ConvertCurrencyRequest object, which is
// the one necessary to handle this request.
// This object takes as parameters the ones we previously created, which
// are our base currency, our target currency, and the req. envelop
$ccReq = new ConvertCurrencyRequest();
$ccReq->baseAmountList = $baseAmountList;
$ccReq->convertToCurrencyList = $convertToCurrencyList;
$ccReq->requestEnvelope = $requestEnvelope;
// And finally we call the ConvertCurrency method on our AdaptivePayment object,
// and assign whatever result we get to our variable
$result = $ap->ConvertCurrency($ccReq);
// Given that our result should be a ConvertCurrencyResponse object, we can
// look into its properties for further display/processing purposes
$resultingCurrencyList = $result->estimatedAmountTable->currencyConversionList;
$baseAmount = $resultingCurrencyList->baseAmount->amount;
$baseAmountCode = $resultingCurrencyList->baseAmount->code;
$convertedAmount = $resultingCurrencyList->currencyList->currency->amount;
$convertedAmountCode = $resultingCurrencyList->currencyList->currency->code;
echo ‘ $’ . $baseAmount . ‘ ‘ . $baseAmountCode . ‘ is $’ . $convertedAmount . ‘ ‘ . $convertedAmountCode;
// And here just for the sake of knowing how we get the result from Paypal’s API
I was wandering if you can help me with my dilemma. I have been beating my head against the wall for over few days already trying to figure out why my embedded payments don’t work. I have been searching and searching everywhere online hoping to get something I am looking for but none of them relate to the same problems I am having.
I am using your library to for chained payments and I can successfully get a payKey. However, I always get different errors when the iframe on my website shows up. Sometimes I get an error which says: “this transaction has already been approved paypal…”. Sometimes it says: “our payment session has expired. Please return to the participating website and try again”. And sometimes it says that it cannot be processed. I follow all the examples I find on the internet but I have never gotten a successful login screen. Please help me.
The error about “transaction has already been approved” means that you included a Preapproval key with your Pay request. When you do that there is no request to PayPal necessary to complete the payment as the payment happens immediately based on the preapproval key. As such, if you send the user to PayPal to login using the PayKey you got back from a payment that already happened because of Preapproval you’ll get that error.
Payment session has expired sounds like you’re using a bad PayKey in the redirect over to PayPal…one that was generated but you then waited too long to use it. It’s not something I’ve run into so without seeing your code and running a demo myself it’s tough to say for sure what’s going on there. Same with the 3rd error you mentioned. Hard to say without seeing your stuff.
I’d just make sure you understand how Preapprovals work first and from there you’ll probably get things straightened out.
I am currently using paywithoptions but I need to do something very special.
How can I pay the primary, then pay a secondary, then delay for a third affiliate. So basically if a vendor sells a product, he as the primary gets full payment. From there the secondary, gets a small commission. Then the vendor can either send instant payments which your paywithoptions allow or delay on that third. How can I do this, as I do not see any option that will allow for it, but I know it is possible as another company is doing it.
The delayed chained payments system only allows you to delay all of the secondary receivers and release them all at once. Any system where you’re collecting funds and then paying out to secondary receivers at different times would most likely be using Preapproved Payments or Billing Agreements / Reference Transactions, which are separate API’s altogether.
I was just testing your Paypal PHP library. Almost all the functions are there, but I couldn’t find the GetPaymentDetails functionality in the library. Is it missing? I downloaded from GitHub.
I’m not aware of any GetPaymentDetails API on the PayPal platform. I don’t see it in the classic API reference (which is what my library is based on) and I don’t see it in the new REST API either (which is not yet included in my library).
You might be thinking of GetTransactionDetails..?? That is indeed part of the API and is included with my library. There is also a GetPaymentOptions that is part of the Adaptive Payments platform, but again, no GetPaymentDetails that I’m aware of at the moment. If you can point me to a doc that mentions it maybe I’ll be able to help more.
I have released a new version of my library recently, but Github hasn’t yet been updated. If you want the latest one you can grab it here. It performs a little better because I removed the child classes from the parent class so they don’t always load when you’re not using them. When you need them you just need to include both the parent and the child class in your script.
I was talking about the following:
Isn’t this a part of the classic API?
Ok, yeah, it’s called PaymentDetails, not GetPaymentDetails. It is included in the Adaptive Payments API and is part of my library. There is a template file called PaymentDetails.php that’s all setup and ready to go for you. Let me know if you can’t find it.
Thanks a lot Andrew! Got everything I needed! 🙂
I have an application which simply uses SetExpressCheckout, GetExpressCheckoutDetails and DoExpressCheckout to do parallel payments. I set this all up using your library, and everything worked as expected with sandbox. However, I went live with my application recently and am now having the problem where normal payments work, however parallel payments to 2 different receivers does not work.
Do you have any idea what the problem might be?
I am trying to use your pay chained example and I keep getting “Your payment can’t be completed. Please return to the participating website and try again.” When I make a payment. Any insights?
Do you have it setup with your own sandbox account?
Got it. Thanks for a great library Andrew.
Hi Andrew I need a help on how to create a paypal button that customer will pay a one time payment for the set up fee for $25 and a subscription of $29.95 per month.Thanks!
Are you using my PHP library? The best way to do it would be to utilize Express Checkout with Recurring Payments. This allows you to setup a subscription (recurring payments) profile that includes a one time fee of any amount, and then you can set an amount and a start date for the actual subscription payments separately within the same API call.
Which template I will use from your library?Thanks!
SetExpressCheckout, GetExpressCheckoutDetails (optional), and CreateRecurringPaymentsProfile.
Hi Andrew!I have one last question.I don’t want to use a sandbox.I want to use a live paypal.Which code i will change so that it will never array with the paypal sandbox api crendentials?Thanks!
For that you just need to make sure your config file is setup correctly. There is a $sandbox flag in there that sets itself based on the subdomain of the current URL. I like this method so I don’t have to remember to set $sandbox back and forth from true/false. Of course, you can just make sure it’s set to true and that you’ve got your live credentials filled into the placeholders correctly and you’ll be ready to rock.
Hi. I’m following the following tutorial to create affiliate payments for my site.
I managed to get it work out and it seems to be functioning properly sending payments to each individual receiver. But how do i go further in creating a delayed chained payment?
I need something like when the sender makes payment, he make his payment to the primary receiver then it stays there. Upon receipt of his item, the buyer then clicks on another button on site and runs another script to release payments to the affiliates(secondary receiver).
I’m not sure if this is possible using your library or paypal, but perhaps you might be able to provide some assistance on your side, so in the event this doesn’t work, i can look at other directions to get the job done.
You just need to setup what’s called a delayed chained payment, and yes, you can easily do it with my library. Basically, you just set the action type in the Pay API request to PAY_PRIMARY. This will submit the payment to the primary user only. Then you would bind whatever trigger you want, in your case a button, to make a call to ExecutePayment, which is what releases the secondary payments.
For more details see this doc that PayPal provides.
By the way, my library includes a PayWithOptions.php that you may want to take a look at. This combines both Pay and SetPaymentOptions so that you can include all of the extra details if you want to. Anything you don’t need you can just leave blank, of course, but I always like to have all the options available to me easily.
Yes. The set payment options was actually what i was about to ask as well.
Because i would also like to enter item names and details instead of my shop name in the description. Been figuring out how but i don’t think i see any fields in the PayWithOptions.php to enter the name and details.
Actually, item details are something that requires the additional SetPaymentOptions call. In PayWithOptions.php you just need to make sure to populate $InvoiceItems accordingly. It includes a single $InvoiceItem array with the actual parameters that gets pushed into $InvoiceItems. If you need more items you can either create more $InvoiceItem arrays manually or loop through a shopping cart of some sort to load $InvoiceItems with all your items.
Oh. I think i understand what you mean. Yea. I found your PayWithOptions.php template files now and yes. there are options for item names as well. I have a question though.
I keep getting error Invalid request parameter: institutionId with value 1 When using PayWIthOptions.php file. I don’t know what to put in there. Can’t leave it blank either.
The $InstituionCustomer array as a whole is not required, and to be honest I’ve never used it within any of my apps to this point. The parameters within in are only required if you include the $InstitutionCustomer array in the $PayPalRequestData that gets passed to the class. The payment documentation shows the following for the InstitutionCustomer section…
(Optional) Details about the party that initiated this payment. This payment is made by the API caller on behalf of the initiating party. The initiating party can be an institution or a customer of the institution. The initiating party must be set up by PayPal Merchant Services.
That leads me to believe it’s something more custom that you’d have to get setup by PayPal in order for you to use it. To get more info on that you’ll need to submit a ticket to http://www.paypal.com/mts. Show them the request you’re sending and the response you’re getting back, and they can provide more details about how those parameters are intended to be used. Sorry I can’t be of more help on that one. Again, though, you can leave that array out entirely and you won’t have any problems.
I also entered a random value for paykey because i thought paykey was suppose to be a return value for authorisation to release the payment to my secondary receivers. correct me if i’m wrong.
I’m not exactly sure I understand your question here. Where are you filling out the PayKey? It’s not included as a request parameter in PayWithOptions.php. You actually get the PayKey back in the Pay response, and then that gets passed into SetPaymentOptions. All of that happens within the PayWithOptions() function in the library, though, and the PayKey would be returned in the result.
your paypal adaptive payment library working fine. we create a store in codeigniter using your library. we embed this store page in wordpress page using iframe. i click checkout button wordpress page completely move to paypal site. we need all payment process done inside the iframe only. how i create this type of process using your library? tell you suggestion.
Review this documentation thoroughly. There’s an entire section about how to setup the different checkout flows with iframes, pop-ups, or redirects.
I’ve recently decided to teach myself PHP and chose SagePay & PayPal to understand APIs and payment gateways. SagePay went really well so I’ve ended that project and started learning PayPal. I chose your classes after finding them on GitHub because they looked simplified and pretty awesome!
I understand pretty much everything about creating recurring payment profiles, what I can’t get my head around is getting the token… where do I get the token value from when I’m not collecting user credit card information? Is there a process/class I need to complete before hand rather than just a POST to this class? (I.E. all of my vars below are set with escaped and validated $_POST values).
[TIMESTAMP] => 2014-04-18T12:57:35Z
[CORRELATIONID] => 4efb915ba9688
[ACK] => Failure
[VERSION] => 109.0
[BUILD] => 10433064
[L_ERRORCODE0] => 11585
[L_SHORTMESSAGE0] => Missing Token or payment source
[L_LONGMESSAGE0] => Missing Token or buyer credit card
[L_SEVERITYCODE0] => Error
[ERRORS] => Array
 => Array
[L_ERRORCODE] => 11585
[L_SHORTMESSAGE] => Missing Token or payment source
[L_LONGMESSAGE] => Missing Token or buyer credit card
[L_SEVERITYCODE] => Error
Thanks in advance for any help 🙂
You would need to go through the Express Checkout flow. This includes SetExpressCheckout, which is what returns a token to you. You’ll need to make sure and include the billing agreement parameters in the SEC request so that the token you get back is compatible with CreateRecurringPaymentsProfile.
When you get that token you’ll redirect the buyer to PayPal where they sign in, agree, and are then returned the ReturnURL you specify in the SEC request. At this return URL you call GetExpressCheckoutDetails if you need to obtain the Payer ID and other details, and then finally finish it off with CreateRecurringPaymentsProfile.
Thanks Andrew 🙂 I’ll explore this further. You’re a generous man!
hey i cant config script
[ERRORS] => Array
 => Array
[L_ERRORCODE] => 10002
[L_SHORTMESSAGE] => Security error
[L_LONGMESSAGE] => Security header is not valid
[L_SEVERITYCODE] => Error
$PayPalConfig = array(
‘APIUsername’ => $api_username,
‘APIPassword’ => $api_password,
‘APISignature’ => $api_signature
$api_username = $sandbox ? ‘hello180_api1.dispostable.com’ : ‘LIVE_API_USERNAME’;
$api_password = $sandbox ? ‘TR4GLMKE3A445QZD’ : ‘LIVE_API_PASSWORD’;
$api_signature = $sandbox ? ‘ABnNOelBH.feu7mTKqXfQy6kZLRAAL-EadP7Z.uOVdng1xeQBDOFlg4f’ : ‘LIVE_API_SIGNATURE’;
any one help me
im testing on localhost wamp server
You’ve got something funky going on there in $PayPalConfig. The Sandbox value should be a boolean true/false value. You’ve got the endpoint there, so what’s happening is that when the credentials are getting set $sandbox is evaluating to false, which is falling to the values like LIVE_API_USERNAME instead of an actual value. That’s why you’re getting the invalid security header error, which means the credentials are wrong.
I’d like to setup Recurring Payments on my site. Thisis the ideal page flow in my head:
– User clicks the ‘Pay button on my site’
– User is redirected to PayPal and enters her billing information (I’m assuming this will be done through setExpressCheckout template?
– User clicks ‘Agree and Pay’ button on PayPal (or whatever other button is presented on PayPal to make the payment). Recurring payment gets set up after they clicked the Pay button.
– User is redirected back to my site with a confirmation that the recurring payment was set up successfully.
Is this possible to do using your library? What templates would I use to achieve this? From what I’m seeing, if I understand correctly, there needs to be multiple back and forth redirections from my site to PayPal for the recurring payments to be set up correctly.
I’d like to make it so that the user clicks the ‘Pay’ button and is redirected to PayPal to enter his billing information.
What you’re after would involve the following steps.
1) Call SetExpressCheckout and make sure to include the billing agreement parameters to specify that it’s for a recurring payments profile. This returns a token.
2) Redirect the user to PayPal. My library returns $PayPalResult[‘RedirectURL’] so you can just use that. Note: If you want the button at PayPal to say “Agree and Pay” instead of “Agree and Continue” then make sure to include the SkipDetails=true in the SEC request.
3) User logs in (with recurring payments they will need an account or will have to create one), approves the payment, and are then sent back to the ReturnURL you specified in the SEC request. If you included the SkipDetails=true in SEC, then you’ll get a PayerID included on the URL when PayPal sends the user back to your site.
4) If you need additional info about the buyer beyond their PayerID you can call GetExpressCheckoutDetails to obtain it. GECD would be required to get the PayerID if you didn’t use the SkipDetails option in my library.
5) Call CreateRecurringPaymentsProfile to finalize the process. No profile is created until this call is completed successfully.
Those steps will generate the profile. You’ll want to use Instant Payment Notification to automate procedures based on when profiles are created, payments occur, etc.
Hi Andrew, thank you for your reply and clarifying on the steps. Currently I’m using Express Checkout but the user isn’t required to have a PayPal account (IE they can just enter their credit card and contact details and the payment goes through. I really like this option as not all of my users have a PayPal account and it means they don’t have to create one to make a payment.
With Recurring Payments, is it possible to continue with this option? In other words is it possible for users not to have to create a PayPal account and still register a recurring payment?
Not with Express Checkout, no. In order to create a profile through EC people will need a PayPal account. You’ll need to upgrade to Payments Pro w/ Recurring Billing if you want to create profiles with credit cards directly. Then no redirect to PayPal happens at all. You just take the card details directly on your site. Pro costs more, though, and you’ll need an SSL certificate on your site as well.
Thank you for such an amazing library! I have been running some successful tests using chained payments, but am stuck trying to add a brandname and hdrimg to the requestfields. This works using your expresscheckout samples, but not with the chained examples.
Is this even possible using chained adaptive payments?
Unfortunately, the BrandName parameter is not available to Adaptive Payments (which includes chained payments) like it is with Express Checkout.
No problem. Thanks for the very prompt reply
I am using this library for the purpose of creating both one-time and recurring payments with Payflow!
The one-time payments are currently working great by updating the PayFlowTransaction.php file.
When I try a recurring payment it is sadly going through as a one-time payment. Is there any reason for this? I have updated the following variable within the PayFlowTransaction.php:
‘recurring’=>’Y’, // Identifies the transaction as recurring. One of the following values: Y = transaction is recurring, N = transaction is not recurring.
But it is only going through as a one-time payment and not a recurring.
Any help is much appreciated!
You need to make sure you have the TRXTYPE parameter set to “R”. Take a look at the Add Action example on page 15 of the PayFlow Recurring Billing documentation.
Since I posted the comment I have actually looked at the document you linked. I have changed the TRXTYPE to R… In the document you can see that they use name, firstname, city, etc and not how you display it as “billtocity” would I have to change your implemetation? I assume not… even so I have tried it with your implemetation and changed the TRXTYPE but I receive an error back from paypal which is the following:
User authentication failed: Recurring Billing
I think this maybe an issue of recurring payments somehow not being enabled on my paypal account? Just a guess right now. If you have any information that would be great!
Thanks for the quick reply!
Yes, you’ll need to make sure you have Recurring Billing enabled on your account for it to work.
The PayFlowTransaction.php template that comes with the library is a very basic setup. You’ll always want to refer to their docs to see exactly what request params are available for the request you’re making, and then you can just add those if they’re not already included in the template.
Ok sounds great, I’ll have to figure out how to go about getting recurring billing enabled. Yeah through the documentation I see that I would an ACTION, PROFILENAME, START, TERM, and PAYPERIOD.
I’d like to inform that your library working fine local host. when I tried in live it will not return the response. can help me out from this trouble. CURLRequest($Request = “”, $APIName = “”, $APIOperation = “”)
above function only not working. I got output like
[ERRORS] => Array
[REQUESTDATA] => Array
[USER] => bala.ixly-facilitator-12_api1.gmail.com
[PWD] => XW6SPLD8UABTDYC7
[VERSION] => 123.0
[BUTTONSOURCE] => AngellEYE_PHPClass
[SIGNATURE] => AFcWxV21C7fd0v3bYYYRCpSSRl31A385WJZTIiL6DzvqE06F0.A8SPeE
[METHOD] => DoDirectPayment
[PAYMENTACTION] => Sale
[IPADDRESS] => 188.8.131.52
[RETURNFMFDETAILS] => 1
[CREDITCARDTYPE] => VISA
[ACCT] => 4032035716410683
[EXPDATE] => 052021
[CVV2] => 123
[EMAIL] => firstname.lastname@example.org
[BUSINESS] => Testers, LLC
[SALUTATION] => Mr.
[FIRSTNAME] => Tester
[LASTNAME] => Testerson
[STREET] => 123 Test Ave.
[CITY] => Kansas City
[STATE] => MO
[COUNTRYCODE] => US
[ZIP] => 64111
[PHONENUM] => 555-555-5555
[AMT] => 100.00
[CURRENCYCODE] => USD
[ITEMAMT] => 95.00
[SHIPPINGAMT] => 5.00
[DESC] => Web Order
[L_NAME0] => Test Widget 123
[L_DESC0] => The best test widget on the planet!
[L_AMT0] => 95.00
[L_NUMBER0] => 123
[L_QTY0] => 1
[SHIPTONAME] => Tester Testerson
[SHIPTOSTREET] => 123 Test Ave.
[SHIPTOCITY] => Kansas City
[SHIPTOSTATE] => MO
[SHIPTOZIP] => 64111
[SHIPTOCOUNTRY] => US
[SHIPTOPHONENUM] => 555-555-5555
[RAWREQUEST] => USER=bala.ixly-facilitator-12_api1.gmail.com&PWD=XW6SPLD8UABTDYC7&VERSION=123.0&BUTTONSOURCE=AngellEYE_PHPClass&SIGNATURE=AFcWxV21C7fd0v3bYYYRCpSSRl31A385WJZTIiL6DzvqE06F0.A8SPeE&METHOD=DoDirectPayment&PAYMENTACTION=Sale&IPADDRESS=184.108.40.206&RETURNFMFDETAILS=1&CREDITCARDTYPE=VISA&ACCT=4032035716410683&EXPDATE=052021&CVV2=123&EMAIL=test%40domain.com&BUSINESS=Testers%2C+LLC&SALUTATION=Mr.&FIRSTNAME=Tester&LASTNAME=Testerson&STREET=123+Test+Ave.&CITY=Kansas+City&STATE=MO&COUNTRYCODE=US&ZIP=64111&PHONENUM=555-555-5555&AMT=100.00&CURRENCYCODE=USD&ITEMAMT=95.00&SHIPPINGAMT=5.00&DESC=Web+Order&L_NAME0=Test+Widget+123&L_DESC0=The+best+test+widget+on+the+planet%21&L_AMT0=95.00&L_NUMBER0=123&L_QTY0=1&SHIPTONAME=Tester+Testerson&SHIPTOSTREET=123+Test+Ave.&SHIPTOCITY=Kansas+City&SHIPTOSTATE=MO&SHIPTOZIP=64111&SHIPTOCOUNTRY=US&SHIPTOPHONENUM=555-555-5555
I did’t get Below values in live But working perfectly in localhost,
[TIMESTAMP] => 2016-04-13T07:26:55Z
[CORRELATIONID] => cd554060d0fda
[ACK] => Success
[VERSION] => 123.0
[BUILD] => 000000
[AMT] => 100.00
[CURRENCYCODE] => USD
[AVSCODE] => X
[CVV2MATCH] => M
[TRANSACTIONID] => 8RV03768AH212152X
It looks like you’re not getting any response at all, which means the curl request must be failing. I would look at this article about POODLE as that is probably what you’re running into.
i am building an app and i would like to do smth like:
-user clicks credits button and i(application) automatically should call a script that sends money to this user account via email. i would like to know what steps i should follow in your library(which files)?
Look at the Pay API, which would be under /samples/Pay.php and /templates/Pay.php. That will allow you to send a payment out from your account to another account.
can i use credit or debit card on paypal adaptive payment?
please reply if it possible…
You can, but only through guest checkout. You can’t do directly like you could with Payments Pro or the new REST APIs.
Hello, I’m Using Paypal Adaptive payment by using your demo. I have an android app, I am using php as backend for this app. so, payment purpose i am using backend php code as per your demo. Sandbox working well, but I have problem in Live payment. It’s not working.
I’m going to need more info than “it’s not working” in order to help. Are you getting an error code/message of some sort?