Skip to main content

PayPal Community

  • Dashboard
  • Send and Request
  • Wallet
  • Business
  • Help
Log in

Le forum de Communauté ne sera plus disponible à partir du 30 Juin 2025. Le Forum de la communauté n’est pas disponible pour les nouveaux messages ou les réponses; les articles précédents restent disponibles pour vérification. Afin de connaître les options d’assistance complètes, rendez-vous sur PayPal.com/HelpCenter

Si vous souhaitez signaler du contenu illégal et contraire au Règlement sur les services numériques de l’Union Européenne (DSA), veuillez cliquer ici.

since ‎Dec-01-2017
Country: United Kingdom
Type: Personal
FixItDik
FixItDik Contributor
Contributor
11
Posts
5
Kudos
1
Solution
Your 5th PayPal Anniversary
Helper
Esteemed
Friendly
Liked
Ice Breaker
Your 3rd PayPal Anniversary
Your PayPal Anniversary
The Return
Organized
Active
View all
Latest Contributions by FixItDik
  • Topics FixItDik has Participated In
  • Latest Contributions by FixItDik

Re: Buy Now button not working for some payers

by FixItDik Contributor in PayPal Payments Standard
‎Feb-01-2021 05:38 AM
‎Feb-01-2021 05:38 AM
Hi @not_here ,   thanks for responding. At the moment the problem has improved and I have only had it reported to me once over the weekend. If you need details of the specific order then please do let me know but as you can imagine this is very frustrating so anything I can do to help find a solution please do let me know   Regards   Dik ... View more

Re: Buy Now button not working for some payers

by FixItDik Contributor in PayPal Payments Standard
‎Jan-27-2021 04:33 AM
‎Jan-27-2021 04:33 AM
Bumping this back up as no one has replied but other people are raising the same issue - there is clearly a problem on the system and it has been going on for weeks - PLEASE CAND SOMEONE FROM PAYPAL HELP? @not_here, tagging you as you appear to have an inside line as moderator, apologies if this is impolite. ... View more

Re: Using a custom_id to match a PayPal transactio...

by FixItDik Contributor in PayPal Payments Standard
‎Jan-25-2021 05:54 AM
1 Kudo
‎Jan-25-2021 05:54 AM
1 Kudo
PPS my thankyou page also does not update the database, it simply uses the {my order id} passed to it to locate my order record and checks the status.  On the sandbox the web hooks were happening hours after the transaction (due to issues at PayPal) but in Live they seam to be happening before the user gets redirected to the thankyou page so it is always seeing the status of the order as "Complete". If the thankyou page sees "Complete" it shows them the details of their completed order for them to print (my database methods used in the webhook code also sends them an email anyway so they have that for their records) *BUT* if it sees the order as "Pending" then is simply tells them they will get an email once PayPal confirm the transaction is complete. Sorry, possibly giving you too much information now but hope some of it is helping 🙂 ... View more

Re: Using a custom_id to match a PayPal transactio...

by FixItDik Contributor in PayPal Payments Standard
‎Jan-25-2021 05:48 AM
1 Kudo
‎Jan-25-2021 05:48 AM
1 Kudo
PS I know my code could be better, it assumes that the existence of the JSON parameters means it is a capture for example but in experience I was only seeing those two web hooks anyway so I get away with it. You might want to add code that checks the call type. ... View more

Re: Using a custom_id to match a PayPal transactio...

by FixItDik Contributor in PayPal Payments Standard
‎Jan-25-2021 05:45 AM
1 Kudo
‎Jan-25-2021 05:45 AM
1 Kudo
Hiya,   Let me start with the questions: 1) This was kind of a belt and braces solution as I spotted this option was available, to be honest I think it is the entry in the orders object that results in the order id being set and this one in the script call is ignored but I could be wrong and it does no harm so I left it in.   2) there's no Ajax call to update the database in this code - I am simply storing it in the local var (ppoid) so I can pass it as a parameter to the thankyou.php page, but it is the webhook that updates the database (again, I did not trust the javascript to be secure and unhackable - any call from this script to update the database would have been risky in my eyes)   And so the code for my webhook, just a single PHP file to handle all messages from the PayPal system:   <?php // This file is called by PayPal and returns data relating to // a payment transaction. It should never be seen by the customer. // should result in 2 lines to log file for every inbound message (what was received followed by what was done with it) // these includes are just functions to perform the database actions require('../includes/paypal_functions.inc'); require('../includes/paypal_orders.inc'); $date = date('Ymd'); $logfile= 'pp_results_'. $date . '.txt'; $t = file_get_contents('php://input'); // log every request to the log file file_put_contents($logfile, (new DateTime())->format('Y-m-d H:i:s.u') . ' - Received ' . $t . chr(13) . chr(10), FILE_APPEND | LOCK_EX); $oid = $ppoid = $pptid = ''; $details = json_decode($t); if ($details == NULL) { // oops - failed to decode it - save that to file file_put_contents($logfile, (new DateTime())->format('Y-m-d H:i:s.u') . ' - Oops, failed to convert to JSON' . chr(13) . chr(10), FILE_APPEND | LOCK_EX); echo 'Failed to convert JSON'; } elseif (isset($details->resource->purchase_units[0]->reference_id)) { // from user authorised // use my oid $oid = $details->resource->purchase_units[0]->reference_id; if (isset($details->resource->purchase_units[0]->payments->catures[0]->id)) { $pptid = $details->resource->purchase_units[0]->payments->catures[0]->id; } // Locate record echo 'Is just a notification of authorisation'; $result = authorise($oid, $pptid); // my db method to handle an authorisation notification file_put_contents($logfile, (new DateTime())->format('Y-m-d H:i:s.u') . ' - Result of attempting to authorise $oid: $result' . chr(13) . chr(10), FILE_APPEND | LOCK_EX); } elseif (isset($details->resource->id)) { //from capture complete - Success! // use PP TID $pptid = $details->resource->id; $tran_status = $details->resource->status; // could be a renewal or join, need to find the record to determine that echo 'Is a complete! ('.$tran_status.')'; $result = complete($oid, $ppoid, $pptid, $tran_status); //my db method to handle a complete file_put_contents($logfile, (new DateTime())->format('Y-m-d H:i:s.u') . " - Result of attempting to complete $pptid: $result" . chr(13) . chr(10), FILE_APPEND | LOCK_EX); } ?>   You will see that I only handle auth and capture notifications, everything else is logged but ignored.  You can see I have methods that update the database if I have an auth and if I have a capture, you don't need the detail of what I do there - you do what you need to do 🙂 ... View more

Re: Is the standard Javascript button secure enoug...

by FixItDik Contributor in PayPal Payments Standard
‎Jan-22-2021 05:21 AM
‎Jan-22-2021 05:21 AM
I would not rely on it - I had the same concern as you and so I implemented the web hooks so that PayPal could tell me if the transaction was completed or not. My web page code just passes the user on to a page that checks the result from the webhook (which I store in my database) so cannot be spoofed.   I posted my code (minus the web hook code) and a bit of an explanation in this thread if it is of help - let me know if you would like the web hook code, but it is in PHP 🙂   https://www.paypal-community.com/t5/PayPal-Payments-Standard/Using-a-custom-id-to-match-a-PayPal-transaction-to-an-order-OR/td-p/2565133/jump-to/first-unread-message ... View more

Re: Using a custom_id to match a PayPal transactio...

by FixItDik Contributor in PayPal Payments Standard
‎Jan-22-2021 05:17 AM
1 Kudo
‎Jan-22-2021 05:17 AM
1 Kudo
Hi, yes, I managed some of this but I don't think you get to see your own OrderID in the dashboard.   The first part is to pass your OrderID in the order data, the other is to log/store the PayPal OrderID in your database (as your OrderID does not get returned in some of the web hook calls). Here's the code on my payment page (the bits in curly brackets are filled in by the PHP code that generates the page), I will describe a bit more after it:       <html> <head> <!-- my stuff --> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Ensures optimal rendering on mobile devices. --> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <!-- Optimal Internet Explorer compatibility --> </head> <body> <script src="https://www.paypal.com/sdk/js?client-id={MY_CLIENTID}&currency=GBP" data-order-id="{My Order ID}"> </script> <!-- my stuff --> <!-- my 'please wait' message that is shown when PayPal confirms authorisation --> <div id="PleaseWait" style="display:none;position: fixed;top: 50%;left: 50%;width: 300px;line-height: 200px;height: 200px;margin-left: -150px;margin-top: -100px;background-color: #f1c40f;text-align: center;z-index: 10;font-size:40px;outline: 9999px solid rgba(0,0,0,0.5);">Please Wait</div> <div id="paypal-button-container"></div> <script> ppoid=pptid=''; paypal.Buttons({ createOrder: function(data, actions) { // This function sets up the details of the transaction, including the amount and line item details. return actions.order.create({ style: { label: "pay" }, application_context: { brand_name: 'Our Club Name', shipping_preference: 'NO_SHIPPING' }, purchase_units: [{ reference_id: '{My Order ID}', amount: { value: '{total to pay}', currency_code: 'GBP' } }], payer: { name: { given_name: '{FIRST}', surname: '{LAST}' }, email_address: '{EMAIL}', address: { country_code: '{Country CODE}', address_line_1: '{ADD1}', address_line_2: '{ADD2}', admin_area_2: '{TOWN}', admin_area_1: '{COUNTY}', postal_code: '{POSTCODE}' } } }).then(function(details) { ppoid = details; return details; }); }, // this function handles the successful outcome onApprove: function(data, actions) { x = document.getElementById('PleaseWait'); if (x) {x.style.display='inherit';} return actions.order.capture().then(function(details) { pptid = details.purchase_units[0].payments.captures[0].id; setTimeout(function(){window.location.href='thankyou.php?oid={My Order ID}&ppoid=' + ppoid + '&pptid=' + pptid;}, 500); return details; }); }, onError: (err) => { console.error('*** error from the onError callback', err); } }).render('#paypal-button-container'); // This function displays Smart Payment Buttons on your web page. </script> </body>       So you will see my "{My Order ID}" going in to the "purchase_units" section in the "reference_id" parameter:     ... purchase_units: [{ reference_id: '{My Order ID}', amount: { ...     You will also see that I added some code to the end of the "createOrder" method to store the PayPal orderID it generates in a local (JavaScript) variable "ppoid":     ... postal_code: '{POSTCODE}' } } }).then(function(details) { ppoid = details; return details; }); ...     And then on the "OnApprove" callback I redirect the user to my "thankyou.php" page passing it our OrderID, PayPal's OrderID as well as the "TransactionID" (returned when I call the "capture" method in the javascript):     ... onApprove: function(data, actions) { x = document.getElementById('PleaseWait'); if (x) {x.style.display='inherit';} return actions.order.capture().then(function(details) { pptid = details.purchase_units[0].payments.captures[0].id; setTimeout(function(){window.location.href='thankyou.php?oid={My Order ID}&ppoid=' + ppoid + '&pptid=' + pptid;}, 500); return details; }); ...   (I display a "Please wait" message when PayPal hands control back to me as I found the capture method was taking a few seconds to complete giving the user the chance to click other buttons on the page and cause chaos)   My ThankYou page just reads my database to see the current status of my order - the webhook code will often have received the call from PayPal by the time it is doing this and the webook will have updated the order to show it has been completed successfully, but just in case the ThankYou page will check and either display a "Transaction complete, thank you" type message or a "We are just waiting on PayPal" message.  The webhook code also sends them an email so they know when the transaction completes. Let me know if you would like to see the webhook code.   I hope that helps!   Regards   Dik (aka FixItDik) ... View more

Buy Now button not working for some payers

by FixItDik Contributor in PayPal Payments Standard
‎Jan-22-2021 04:27 AM
1 Kudo
‎Jan-22-2021 04:27 AM
1 Kudo
Hi, my "customers" are members of our motorcycle club and are paying for their membership. I use the Checkout buttons and after some initial teething problems with formatting of phone numbers as I passed them in the CreateOrder data they appear to be working for most people. *BUT* some are still reporting problems and they tell me they are using the "Credit/Debit Card" option, filling in their card details (and mobile number) but when they click the "Buy Now" button (which should be "Pay Now" as I have set the "label" to "pay" in the order data which works for PayPal option but not for card, but hey ho) nothing happens!   I have put a message on the web page for people to contact me if they have problems and I am getting about 3 per day out of the 12 or so that try (and if I look at my logs I can see I am presenting the payment options to some people and they are not completing the payment but are also not contacting me, they simply try again a while later and about 50% of these people complete - so probably get distracted or have to go find their card details).   I am only a volunteer and I am already looking at moving over to Stripe (which would be a shame as PayPal users would not be able to pay using their PayPal account) - I know we don't do high volumes so PayPal will not be sweating about losing us but wondered if anyone else has the same problem (or had it and found the solution)?   If you need to see my code for this page I posted in another post here: https://www.paypal-community.com/t5/PayPal-Payments-Standard/400-Bad-Request-when-button-pressed-happening-more-frequently/m-p/2547444#M11561 ... View more
Labels:
  • Labels:
  • PayPal HTML Buttons

Re: 400 Bad Request when button pressed - happenin...

by FixItDik Contributor in PayPal Payments Standard
‎Jan-11-2021 06:26 AM
‎Jan-11-2021 06:26 AM
I found the problem: I was initially trying to populate the order data with the person's phone number (from the data in my membership database) but soon realised that was only relevant if they were based in the UK so put the logic for that in with the logic that detected an ISO country code of "UK" and replaces it with the PayPal-required value of "GB". Unfortunately the members type all sorts of rubbish in the phone number field so trying to clean it up to look like a real number (which the PayPal JSON object will only accept) resulted in too many failures so I simply stripped out the logic to populate the "{PP_PHONE}" line in my HTML - *MY STUPID MISTAKE* was to also then remove the logic for the country code so I was sending "UK" instead of "GB".   Why oh why did PayPal allow me to create the order with "invalid" data and not throw some form of error at the point of order creation rather than this really bad user experience! Anyway, the real anger is pointed at myself for being so slap-dash in my haste to get this working. ... View more

400 Bad Request when button pressed - happening mo...

by FixItDik Contributor in PayPal Payments Standard
‎Jan-11-2021 03:58 AM
‎Jan-11-2021 03:58 AM
Hi, Background: I needed a quick way to take fixed amount one-off payments from my "customers" (motorcycle owners club members) so thought the PayPal Checkout buttons looked to be perfect. Developed on sandbox and put live in a hurry but was working pretty much fine at first. What's reported by users: But after a couple months I am seeing increasing numbers of people attempting to pay using the buttons (both PayPal and Card) who are trying over and over. Luckily I store their email addresses in the "Orders" table I create for each attempt so I reached out to them and they tell me they are just seeing the rotating circle if they click the card button or nothing if they click the PayPal button. What I found: So I went to the live web site and tried myself using their details and sure enough I see exactly the same. I opened Developer Tools in Chrome and I am seeing the following appear in the console when I click the button:   GET https://www.paypal.com/smart/card-fields?sessionID=2ac27243e1_mte6mtm6mdy&buttonSessionID=64587ec80e_mte6mjg6mdg&locale.x=en_US&commit=true&env=production&sdkMeta=eyJ1cmwiOiJodHRwczovL3d3dy5wYXlwYWwuY29tL3Nkay9qcz9jbGllbnQtaWQ9QWRZQkpkUllXMDRLU1I1R1lzX2VKZkpyTFV6Wkh1T01BQlJWMlVoTVBJcmtxVXItaTBzZmM0cjNaejdyVWNHbURnYnp5QlRPUEZmc2d6Y2omY3VycmVuY3k9R0JQIiwiYXR0cnMiOnsiZGF0YS11aWQiOiI4MDM2YzE5ZjlmX210ZTZtamc2bWRnIn19&disable-card=&token=8MU85455SA178700V 400   The hardest thing for me here is that it is working for some people and not for others, but as the title suggests is started out with 1 in 20 people now it is line 4 in 5 (i.e. only one attempt in every 5 is successful)   Because it sometimes works and because it has been getting worse this feels like a compatibility issue somewhere but the people I have contacted have told me they are trying different devices with different browsers.   Here's an extract of my page:             <html> <head> <!-- my stuff --> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Ensures optimal rendering on mobile devices. --> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <!-- Optimal Internet Explorer compatibility --> </head> <body> <script src="https://www.paypal.com/sdk/js?client-id={MY_CLIENTID}&currency=GBP" data-order-id="{My Order ID}"> </script> <!-- my stuff --> <!-- my 'please wait' message that is shown when PayPal confirms authorisation --> <div id="PleaseWait" style="display:none;position: fixed;top: 50%;left: 50%;width: 300px;line-height: 200px;height: 200px;margin-left: -150px;margin-top: -100px;background-color: #f1c40f;text-align: center;z-index: 10;font-size:40px;outline: 9999px solid rgba(0,0,0,0.5);">Please Wait</div> <div id="paypal-button-container"></div> <script> ppoid=pptid=''; paypal.Buttons({ createOrder: function(data, actions) { // This function sets up the details of the transaction, including the amount and line item details. return actions.order.create({ style: { label: "pay" }, application_context: { brand_name: 'Our Club Name', shipping_preference: 'NO_SHIPPING' }, purchase_units: [{ reference_id: '{My Order ID}', amount: { value: '{total to pay}', currency_code: 'GBP' } }], payer: { name: { given_name: '{FIRST}', surname: '{LAST}' }, email_address: '{EMAIL}', address: { country_code: '{Country CODE}', address_line_1: '{ADD1}', address_line_2: '{ADD2}', admin_area_2: '{TOWN}', admin_area_1: '{COUNTY}', postal_code: '{POSTCODE}' } } }).then(function(details) { ppoid = details; return details; }); }, // this function handles the successful outcome onApprove: function(data, actions) { x = document.getElementById('PleaseWait'); if (x) {x.style.display='inherit';} return actions.order.capture().then(function(details) { pptid = details.purchase_units[0].payments.captures[0].id; setTimeout(function(){window.location.href='thankyou.php?oid={My Order ID}&ppoid=' + ppoid + '&pptid=' + pptid;}, 500); return details; }); }, onError: (err) => { console.error('*** error from the onError callback', err); } }).render('#paypal-button-container'); // This function displays Smart Payment Buttons on your web page. </script> </body>             As you can see I have modified the script a little from the examples in the documentation (but used other areas of the docs and questions on this forum to get them right): I have added some elements to the order.create parameter Added the onApprove hook to I can redirect the payer to a Thank You page (showing a Please Wait for the few seconds that takes to avoid them clicking anything else) Added the onError hook which does not get triggered even though the JavaScript console is showing me the above 400 error when the button is clicked In the background: Before drawing this page my code generates an orderID and stores their info in a database table (the "{My Order ID}" gets populated on this page with that) When drawing this page all the things that look like "{xxx}" get replaced with the transaction information - before you ask no the use of curly braces is not conflicting with the JSON, I can see the code in the developer tool is exactly as it should be I have set up webhooks so that when PayPal authorises and Completes the transaction there is a small bit of code that simply updates the database record - identified by the {My Order ID} which travels with the order - and on completion emails the person (and CCs me) with  By the time the person lands on the Thank You page the PayPal web hook has usually triggered and the person is shown the payment confirmation - obviously no web hooks are triggered as the person is not even getting the chance to pay This leaves me with a database table that is filling up with uncompleted transactions as the people try and try again (I am not worried about space, just about the very poor user experience and the fact we are losing money!) Please help! Thanks   Dik. ... View more
Labels:
  • Labels:
  • PayPal HTML Buttons
Paypal Logo
  • Help
  • Contact Us
  • Security
  • Fees
  • © 1999-2025 PayPal, Inc. All rights reserved.
  • Privacy
  • Legal
  • Cookies
  • Policy Updates

The money in your balance is eligible for pass-through FDIC insurance.

The PayPal Cash Mastercard is issued by The Bancorp Bank pursuant to a license by Mastercard International Incorporated. The Bancorp Bank; Member FDIC.

Powered by Khoros