We have just released updated versions of our PHP class libraries for PayPal (one standard and one specific to CodeIgniter). Â The new version includes the following updates:
Fixes
- Corrected bug in update to SetExpressCheckout() to avoid PHP warnings when a TOKEN isn’t available.
- Updated library method Preapproval(). The $ClientDetails array was using an incorrect name ($ClientDetails vs. $ClientDetailsFields). Also added missing namespace.
- Updated library method PreapprovalDetails(). The XML elements were missing the namespace.
- Fixed bugs in GetBasicPersonalData and GetAdvancedPersonalData that were causing invalid XML to get sent to PayPal.
- Updated the Pay() method to use the correct Return URL for DigitalGoods payments.
- Fixed problem in library method GetPaymentOptions() that was causing parsing errors with the PayPal response.
- Fixed incorrect field name in CreateRecurringPaymentsProfile request arrays. AUTOBILLAMT updated to AUTOBILLOUTAMT
- Fixed Pay request so that it will send lowercase values for the primary parameter (true/false). PayPal returns an error if you send TRUE/FALSE
- Fixed a problem in SetPaymentOptions() where the receiverOptions node in the XML request was not getting generated correctly.
New Features
- Split Adaptive and PayFlow extended classes into separate files.
- Updated PayPal API Version to 95.0
- Added PayFlow class to the library.
- Added BMButtonSearch
- Added PayWithOptions() function to the library which combines both Pay() and SetPaymentOptions().
Do you have class that will create recurring or subscription payments?
Yes. I have a standard class library for PayPal and also one specific to CodeIgniter.
Hi Andrew,
we’re trying to integrate your paypal class library on our platform (we need preapprovals and chained payments) but when we call the preapproval api we get a “invalid request” (580001) error.
Using the same authentication data with the example code from x.com website, all works fine, but when we use your library (that we’d prefer to use while it is a certified one), we get this error.
Here is the request and the response we get from paypal aftr the call:
Array
(
  [0] => X-PAYPAL-SECURITY-USERID: vinix_1356108020_biz_api1.vinix.it
  [1] => X-PAYPAL-SECURITY-PASSWORD: 1356108047
  [2] => X-PAYPAL-SECURITY-SIGNATURE: A.8osZD5ZQXWSGCyns6XoHkn1MLkAF1TEckRaaWIb6vi7aCvdLw2PnMX
  [3] => X-PAYPAL-SECURITY-SUBJECT:
  [4] => X-PAYPAL-SECURITY-VERSION: 95.0
  [5] => X-PAYPAL-REQUEST-DATA-FORMAT: XML
  [6] => X-PAYPAL-RESPONSE-DATA-FORMAT: XML
  [7] => X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T
  [8] => X-PAYPAL-DEVICE-ID:
  [9] => X-PAYPAL-DEVICE-IPADDRESS: 192.168.1.100
  [10] => X-PAYPAL-SANDBOX-EMAIL-ADDRESS: info@vinix.it
)
Array
(
  [Errors] => Array
    (
      [0] => Array
        (
          [Receiver] =>
          [Category] => Application
          [Domain] => PLATFORM
          [ErrorID] => 580001
          [ExceptionID] =>
          [Message] => Invalid request: {0}
          [Parameter] =>
          [Severity] => Error
          [Subdomain] => Application
        )
    )
  [Ack] => Failure
  [Build] => 4110101
  [CorrelationID] => fefd10637cd14
  [Timestamp] => 2012-12-22T07:53:10.077-08:00
  [PreapprovalKey] =>
  [RedirectURL] =>
  [XMLRequest] => ReturnAllen_UShttps://www.vinix.com/shop/approval_cancel.phpAPP-80W284485P519543T192.168.1.100EURNO_DAY_SPECIFIED2012-12-30Zhttps://www.vinix.com/shop/ipn_shop.php929.281929.28preapprovalpreapprovalNOT_REQUIREDEACHRECEIVER1https://www.vinix.com/shop/approval_confirm.phpNOT_REQUIRED2012-12-22Z
  [XMLResponse] => 2012-12-22T07:53:10.077-08:00Failurefefd10637cd144110101580001PLATFORMApplicationErrorApplicationInvalid request: {0}
)
Any help?
Thanks!
When you see this result on screen, please view source on that page. Then when you scroll down to the XMLRequest and XMLResponse you’ll see the full, raw XML data. The on-screen display wipes out the actual XML, so it’s tough to troubleshoot something like this. If you can please get me that actual XML request and response I can help you troubleshoot this.
ooops, unfortunately all the tags have been cancelled.
[XMLRequest] =>
[?xml version=”1.0″ encoding=”utf-8″?]
[PreapprovalRequest xmlns=”http://svcs.paypal.com/types/ap”]
[requestEnvelope xmlns=””]
[detailLevel]ReturnAll[/detailLevel]
[errorLanguage]en_US[/errorLanguage]
[/requestEnvelope]
[cancelUrl xmlns=””]https://www.vinix.com/shop/approval_cancel.php[/cancelUrl]
[clientDetails xmlns=””]
[applicationId xmlns=””]APP-80W284485P519543T[/applicationId]
[ipAddress xmlns=””]192.168.1.100[/ipAddress]
[/clientDetails]
[currencyCode xmlns=””]EUR[/currencyCode]
[dayOfWeek xmlns=””]NO_DAY_SPECIFIED[/dayOfWeek]
[endingDate xmlns=””]2012-12-30Z[/endingDate]
[ipnNotificationUrl xmlns=””]https://www.vinix.com/shop/ipn_shop.php[/ipnNotificationUrl]
[maxAmountPerPayment xmlns=””]929.28[/maxAmountPerPayment]
[maxNumberOfPayments xmlns=””]1[/maxNumberOfPayments]
[maxTotalAmountOfAllPayments xmlns=””]929.28[/maxTotalAmountOfAllPayments]
[memo xmlns=””]preapproval[/memo]
[paymentPeriod xmlns=””]preapproval[/paymentPeriod]
[pinType xmlns=””]NOT_REQUIRED[/pinType]
[feesPayer xmlns=””]EACHRECEIVER[/feesPayer]
[displayMaxTotalAmount xmlns=””]1[/displayMaxTotalAmount]
[returnUrl xmlns=””]https://www.vinix.com/shop/approval_confirm.php[/returnUrl]
[senderEmail xmlns=””]NOT_REQUIRED[/SenderEmail]
[startingDate xmlns=””]2012-12-22Z[/startingDate]
[/PreapprovalRequest]
[XMLResponse] =>
[?xml version=’1.0′ encoding=’UTF-8′?]
[ns3:FaultMessage xmlns:ns3=”http://svcs.paypal.com/types/common” xmlns:ns2=”http://svcs.paypal.com/types/ap”]
[responseEnvelope]
[timestamp]2012-12-22T08:10:46.030-08:00[/timestamp]
[ack]Failure[/ack]
[correlationId]6a5b696f7360f[/correlationId]
[build]4110101[/build]
[/responseEnvelope]
[error]
[errorId]580001[/errorId]
[domain]PLATFORM[/domain]
[subdomain]Application[/subdomain]
[severity]Error[/severity]
[category]Application[/category]
[message]Invalid request: {0}[/message]
[/error]
[/ns3:FaultMessage]
Might be better, actually, if you’d just send me the files you’re working with so I can reproduce what you’re doing and work on it directly.
ok, thank you.
The file is an example content in your class, Preapproval.php,
if you want I can send it the same.
How do I send it?
Hi,
your PHP class seems to be what I was searching for.
A few days ago I downloaded your class for PayPal API Version 95.0, but now it seems to be gone. On the download page I can only find “PayPal API Version 84.0”.
With version 95.0 I tried SetExpressCheckout.php (from the samples directory) after adjusting config.php with my sandbox credentials. All seems to be well (URL to the PayPal site generated, list of items in the cart shown, logging in with the sandbox buyer account, clicking on the buy button), but when the browser redirects to DoExpressCheckoutPayment.php on my local server, I get the following errors in the array:
Array
(
[TIMESTAMP] => 2013-01-28T21:50:55Z
[CORRELATIONID] => d9f1caf225663
[ACK] => Failure
[VERSION] => 95.0
[BUILD] => 4181146
[L_ERRORCODE0] => 10410
[L_SHORTMESSAGE0] => Invalid token
[L_LONGMESSAGE0] => Invalid token.
[L_SEVERITYCODE0] => Error
[ERRORS] => Array
(
[0] => Array
(
[L_ERRORCODE] => 10410
[L_SHORTMESSAGE] => Invalid token
[L_LONGMESSAGE] => Invalid token.
[L_SEVERITYCODE] => Error
)
)
...
I’ve uploaded the full output to http://pastebin.com/Ausu1179 , because I don’t want to flood your comments with the full message 😉
Do you have a hint, what I could do?
Thank you for your work,
Rudolph
I’m sorry for the delay getting back to you. I don’t see the TOKEN included in your DECP request. Are you sure you filled that value in to the request array?
The Transaction ID returned in the PAYMENTINFO_0_TRANSACTIONID does not match the Transaction ID on my PayPal Sandbox page. Where does the class return the actual Transaction ID reported to the merchant and customer accounts?
Andrew.. life saver
I did find a bug with RequestPermissions.php at the root level. Just forgetting to add the $RequestPermissionsField array to the $PayPalRequestData
Line 55: $PayPalRequestData = array(‘RequestPermissionsFields’);
—-REPLACED WITH—-
Line 55: $PayPalRequestData = array(‘RequestPermissionsFields’=>$RequestPermissionsFields);
Thanks again.
Thanks for pointing that out!
Andrew
Again this library has been a savior to my work. Can you verify that the bug you resolved in the latest revision is indeed resolved? I am receiving an Internal Error (520002) from PayPal and am having difficulty identifying any errors with the request being sent.
What bug are you referring to? I would need to get a look at your request to see what the problem might be. You can email that directly to me via the contact page on my site. You could also just send me the files that you’re working with if you’d rather do that. I’ll take a look and see what I can find.
Thanks
Andrew,
I’ve been attempting to incorporate your PHP libraries into an existing WordPress site for a client of mine. Their customers request some changes via a form. They then have a screen on the admin side to accept or deny the changes. Some changes they flag for charging the customer. I want to then take all the info about the change, create and send an invoice to the customer’s email address.
After iterating through some standard errors (missing some required fields, not having the correct API credentials, etc.), I have hit a wall where I get nothing back but the 520002 error from PayPal.
I’m attempting to use a Sandbox account created under my client’s developer.paypal.com account. I have the API credentials from that Sandbox account entered in the config file. I’ve attempted using all of the various API Signature endpoints listed on https://cms.paypal.com/ca/cgi-bin/?cmd=_render-content&content_ID=developer/howto_api_endpoints.
I’m truly at a wall. I’d love some suggestions, if you have any.
Thanks.
Send me a copy of the file you’re using to setup the API request and I’ll see if I can find the issue.
sir… i want to develope Adaptive chain paypal payment system in my side ..i am read more articals & doc. on net but i cant find right solution for that…
You would just setup a Pay API request with PayPal that splits everything up how you need it. My library includes a sample for that as well as PayWithOptions which is what I would recommend so you can provide more details with it.
Thanks for your PayPal library. I’ve got just one hitch remaining. I would like the purchase details of the transaction to be listed on the notification email sent to the seller. Currently it only shows the total price of the transaction. Is there a setting that I’ve overlooked to enable that?
Are you working with Express Checkout? Are you including the $OrderItems in the request data?
Yes, Express Checkout. I am pushing the line items into $PaymentOrderItems in SetExpressCheckout.php, and they do show up on the purchaser’s screen. I don’t see $OrderItems on that script. Where would I set it?
Sorry, yeah, $PaymentOrderItems is what I meant. That should be getting passed into $Payment, which is then passed into $Payments, which is then passed into $PayPalRequest. All of that is laid out for you, though, so you just need to loop through your item(s) and add the items accordingly. If you want to send me your SetExpressCheckout.php file I’ll take a look and see what you’re missing.
There doesn’t seem to be a way to send a file here. Please send me your email address back-channel.
Thank you very much for your PayPal library and for all of the information you provide – tremendous help!
I understand (and have working) PayWithOptions parallel payments on my site. However, if at least one of the receivers does not have a verified business account, then customers/senders are forced to set up a PayPal account before being allowed to pay with a credit card.
Is it possible to use parallel payments from within PayPal Advanced Payflow and use a credit card? I cannot find any examples of this.
What I ultimately want is to allow senders (with no PayPal account) to pay multiple receivers with a credit card even if one of the receivers does not have a verified business account.
Thank you again.
Hi Greg,
If you’re working with Parallel payments (as opposed to chained) then you can do that with Express Checkout instead of the Pay API and you wouldn’t have the same limitations to my knowledge. That said, I haven’t specifically tested the scenario you’re outlining here, so I can’t be 100% sure.
Thanks. Yes, Express works beautifully until an affiliate joins my site without a business account (and I don’t really want to limit those who join). So it sounds like you’re saying PayPal Advanced PayFlow does *not* support parallel payments?
Yeah, payments advanced doesn’t yet support parallel/chained payments.
Andrew:
You haven’t given me a way to take you up on your kind offer to review my SetExpressCheckout.php file to resolve my problem.
Put it on pastebin and respond with the link here, or you could contact me directly through my contact page.
Again, cannot thank you enough for your library. Out of curiosity, I was wondering if you had ever seen something like this and know why it might be happening. I was running a pre-production test using a live PayPal account, Express Checkout Parallel Payment (PayWithOptions), two RECEIVERS. I received the following from PayPal in the confirmation e-mail.
======================================
Payment details
Receiver email: v1team@outlook.com
Amount: $0.70 USD
Transaction date: August 21, 1922
Status: Incomplete
Transaction ID:
Invoice ID: 100000001
Receiver email: gtteam@gmail.com
Amount: $0.70 USD
Transaction date: July 3, 2013
Status: Completed
Transaction ID: 36P53117GD8751311
Invoice ID: 100000001
======================================
The first RECEIVER has a transaction date of August 21, 1922. Of course, then, his payment was never processed by PayPal. The second RECEIVER’s payment went through just fine. I ran the same test again (no code changes) with a new INVOICE ID and both payments went through just fine. Is there anything obvious that I might need to review in my code?
Thanks again.
Hmmm, that’s definitely strange. Not something I’ve seen before. If you want to send me your PayWithOptions file I’ll take a look and see if I notice anything that could cause that.
Thanks for offering. I was testing with multiple instances of Magento using the same PayPal account. I inadvertantly used a duplicate (Magento-auto-generated) invoice number and PayPal (rightfully so) did not know what to do with it. I now have a work-around in place – again, can’t thank you enough.
Thanks for your PayPal library , nicely done.
Glad you like it, thanks!
Hi Andrew,
This library looks great and I’ve been trying to use it. Unfortunately I’m have trouble with the initial API credentials and am having additional trouble finding the documentation I need. Specifically the error id is 520003 and the message is “Authentication failed. API credentials are incorrect.”
I would like to use your library to make a Delayed Chained Payment. My confusion comes with weather or not to set up a REST API app at https://developer.paypal.com/webapps/developer/applications/myapps or a classic API app at https://apps.paypal.com/. If I use the first (REST API), does “Client ID” correspond to $api_username and does “Secret” correspond to $api_password?
I should note that I’ve tried setting up apps with the REST API and the Classic APIs and created credentials using steps at https://developer.paypal.com/webapps/developer/docs/classic/api/apiCredentials/ None of these seem to be working.
Thanks for any pointers you might have!
My library uses the classic API. I plan on getting the REST API’s integrated into it, but I just haven’t gotten that done yet. It’s really not a top priority of mine right now because the REST API doesn’t give you anything new that the Classic API doesn’t have, and my library makes the classic API so easy to use I haven’t had any reason to get them tied in yet.
Anyway, what you need is the api username, password, and signature. You will also need an App ID since you’re using Adaptive Payments. This is included in the library for testing, but you’ll need to submit your app to PayPal for approval to get a live App ID.
You can login to this tool to quickly obtain your username, password, and signature.
That’s a handy tool. It gives me the same login information as what I had before. Now I just have to figure out what is causing the authentication failure. Could it be because I have a REST app and a classic API app setup?
Thanks again!
It sounds like maybe you’re hitting the wrong endpoint. You need to make sure that when you’re using sandbox credentials you’re hitting the sandbox endpoint and visa versa. If you’re using my library that should all be handled for you. Have you been able to get the samples included with the library working?
Sorry for the late response. I haven’t changed the endpoints to my knowledge and it looks like hey’re going to https://svcs.sandbox.paypal.com/ for sandbox and https://svcs.paypal.com/ for live. This is based if the EndPointURL fields in paypal.adaptive.class.php
Yes, those are correct. So you just need to make sure that your $sandbox value getting passed into the class object is what you’re expecting it to be. If you want to send me the file you’re working with I’ll see I can find your problem.
Great class! I am struggling with the PayPal adaptive payments and I found your class very useful and easy to use. After couple days of work I am able to use it. I’ve got one comment/question, however. When I enter notify_URL in the form http://www.domain.com/index.php?affID=1&controller=PP, I’ve got error message 58001 from paypal. After some testing I’ve noticed the URL is not sent to paypal in the right format. “&” seems to not be encoded. So I modified the paypal.adaptive.class.php script (line 552, Version 1.5) to
$XMLRequest .= $IPNNotificationURL != '' ? '' . htmlentities($IPNNotificationURL) . '' : '';
Now it works, I’ve got success message from paypal. Am I on the right way? Is it a “bug” in your script or am I missing something?
Once again, thanks for this great class.
Patrik
If that’s working for you, that’s fine, but I really wouldn’t recommend passing data as URL parameters in your notify_url like that. Instead, you can use the CUSTOM parameter to include a record ID for data in your database table (or you could use the INVNUM parameter to include a specific order/invoice ID) and then you can pull data back out within your IPN script just using that ID, which will be included with the IPN data.
Hi,
First .Thank you ..User library matching what i am search long time…
Actually i am beginner in paypal system
I have one doubt !
(1) When I setup delayed payment system with PAY_PRIMARY parameter .Everything working fine.
I set First person 5.00
Second person 2.00 etc…
How can I set secondary receiver get credit on his account only after 10 days or particular date .
Is there any option like these ? help me please !
With a delayed chained payment you release the secondary payments using the ExecutePayment API. You can set this up to be run at whatever time-frame you want, so just create a script that automatically run 10 days after the fact and you’ll be good.
Thank you !
Hi Andrew,
I implemented adaptive payment using pay type, But Paypal response looks like as below.
Please help me, How can i change API credentials.
Array
(
[Errors] => Array
(
[0] => Array
(
[Receiver] =>
[Category] => Application
[Domain] => http://schoolswapshop.demowork.com/
[ErrorID] => 520003
[ExceptionID] =>
[Message] => Authentication failed. API credentials are incorrect.
[Parameter] =>
[Severity] => Error
[Subdomain] => Application
)
)
[Ack] => Failure
[Build] => 9641252
[CorrelationID] => 90f702623e340
[Timestamp] => 2014-02-17T21:10:37.435-08:00
[PayKey] =>
[PaymentExecStatus] =>
[RedirectURL] =>
[XMLRequest] => ReturnAllen_USPAYhttp://schoolswapshop.demowork.com/paypal/class/1.2/Pay_Cancel.phpAPP-80W284485P519543Tadamg@gmail.com119.160.193.154Always Give BackAUDSENDERECHECKBALANCECREDITCARD10.00accounts-facilitator@schoolswapshop.com.au5.00chris@demowork.com123-ABCDEFaccounts@schoolswapshop.com.auhttp://schoolswapshop.demowork.com/paypal/class/1.2/Pay_Return.phpadamg@gmail.com
[XMLResponse] => 2014-02-17T21:10:37.435-08:00Failure90f702623e3409641252520003PLATFORMApplicationErrorApplicationAuthentication failed. API credentials are incorrect.
)
Thanks,
chris.
As it says, that means that one way or another your API credentials are incorrect. Make sure you have the correct values in your config file, first of all, and then also make sure you’re not sending sandbox credentials to the live server or visa-versa.
Hi-
I am still somewhat of a noob with all this PayPal stuff.. and all the (tricky) naming conventions they use (with slight variations)..etc
Your class has made this so much easier so thank you for sharing it.
I figured might as well ask form someone who can explain it in a format I could (hopefully) understand.
My questions stems from ‘testing’..
Testing using the sandbox for BOTH DoDirectPayments & PayFlow
I understand about the config vars and setting the sandbox to true/false..etc..
what I am not grasping is HOW to actually test correct (with expected results)
DoDirectPayments: (sandbox mode = true)
Are you supposed to test with FAKE cc#’s? (ie: 4111111111111111)
-or-
Are you supposed to use the info generated when creating sandbox accounts on the PayPal site itself? (Developerr section or something)
I’m not clear if using the fake CC# of: 4111111111111111 is supposed or work or fail?
any other CC#’s should fail…correct?
any sandbox generated account info, should -pass-……correct?
————————
PayFlow: How do you correctly test (while in sandbox mode) to get a success and how to test to get a failure (correctly?)
Sorry if this is a mundane question, I am just looking for a quick & dirty, DEFINITIVE answer (or better yet example of each scenario for both DoDirect and PayFlow instances.
Thanks!
You use fake numbers, but you don’t want to use that 41111 number. It’s been used so much in the sandbox that it causes issues now. Instead, I like to use this credit card number generator to create test numbers any time I need them. They work just fine in the sandbox.
Array
(
[0] => Array
(
[Receiver] =>
[Category] => Application
[Domain] => PLATFORM
[ErrorID] => 580001
[ExceptionID] =>
[Message] => Invalid request: None of the fields are specified to identify a receiver
[Parameter] =>
[Severity] => Error
[Subdomain] => Application
)
)
how do i avoid this error?
As the error says, you apparently don’t have any fields included which specify the receiver of the payment. Are you trying to send a payment from your account to another, or are you trying to setup a payment where your own would be the receiver, or what exactly? Can you provide a sample of your request?
Hi Andrew, I have set up a multi vendor/marketplace website (using dokan + Woocommerce) and i am wondering is it possible for vendors to receive payment automatically and instantly from a sale? (kind of like ebay)
And would vendors need a Papal business account for this?
I would appreciate any info
Regards, Jesse
Hi Jesse,
Our PayPal Multi-Account for WooCommerce plugin will do that for you! Currently, you can create rules in our plugin based on the Author ID (vendor ID). Any product ordered that is owned by a vendor will get paid directly to their account. You can also set a commission to keep for yourself.
It’s recommended that vendors have a business account, but not necessarily a requirement. There are some limitations that could come from it, so again, I do recommend that all receivers of payments on the Express Checkout API (which is how this works) are business accounts.