Angell EYE PayPal PHP SDK Class Library
Video Demo
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.
Need Additional 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 Help
$100.00 -
PayPal for WooCommerce
FREE! -
WooCommerce Multiple PayPal Accounts Plugin
$119.99 -
PayPal Shipment Tracking for WooCommerce
$49.99 -
Sale!
PayPal for WooCommerce – Credit Card Split Payment
$49.99 -
Offers for WooCommerce
$59.99 -
Sale!
Offers for WooCommerce – WC Vendors
$99.99 -
Sale!
Offers for WooCommerce – Dokan
$99.99
Hi Andrew,
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).
[code]
Array
(
[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
(
[0] => Array
(
[L_ERRORCODE] => 11585
[L_SHORTMESSAGE] => Missing Token or payment source
[L_LONGMESSAGE] => Missing Token or buyer credit card
[L_SEVERITYCODE] => Error
)
)
[/code]
Thanks in advance for any help 🙂
Michael
Hi Michael,
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
(
[0] => Array
(
[L_ERRORCODE] => 10002
[L_SHORTMESSAGE] => Security error
[L_LONGMESSAGE] => Security header is not valid
[L_SEVERITYCODE] => Error
)
)
$PayPalConfig = array(
‘Sandbox’ =>”api.sandbox.paypal.com”,
‘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.
Hi Andrew,
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.
Hi Vlad,
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?
Thanks
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.
Hi Andrew,
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?
Thanks,
Paul.
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
Hello Andrew!
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!
Thanks,
Al
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.
Hi Andrew,
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
Array
(
[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] => 117.213.97.38
[RETURNFMFDETAILS] => 1
[CREDITCARDTYPE] => VISA
[ACCT] => 4032035716410683
[EXPDATE] => 052021
[CVV2] => 123
[EMAIL] => test@domain.com
[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=117.213.97.38&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
[RAWRESPONSE] =>
)
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.
Hi Andrew,
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.
Hi
can i use credit or debit card on paypal adaptive payment?
please reply if it possible…
thanks
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?