Skip to main content

PayPal Community

  • Dashboard
  • Send and Request
  • Wallet
  • Business
  • Help
Log in
  • Welcome
    • Guidelines
    • News and Events
    • Suggestions for PayPal
    • General Discussions
  • PayPal Help Community
    • Managing Account
    • Transactions
    • Wallet
    • Security and Fraud
    • Products & Services
    • Reporting
  • MTS Community
    • PayPal Upgrade Community
    • PayPal Payments Standard
    • REST APIs
    • NVP/SOAP APIs
    • SDKs
    • Sandbox Environment
    • PayPal Reporting
    • Payflow
    • Ideas for MTS
    • Client-side Integration
    • Server-side Integration
  • The Archives
    • PayPal Help Community Archives
      • Managing Account Archives
      • Transactions Archives
      • Wallet Archives
      • Security and Fraud Archives
      • Products & Services Archives
      • Reporting Archives
    • Help Community
      • PayPal Basics Archives
      • Payments Archives
      • My Money Archives
      • My Account Archives
      • Disputes and Limitations Archives
      • Products and Services Archives
      • PayPal Credit Archives
    • Merchant Community
      • Merchant Products
      • Business Tools Archives
      • Reporting Archives
      • Managing Risk and Fraud Archives
    • Help Archives
      • About Business (Archive)
      • About Payments (Archive)
      • About Settings (Archive)
      • About eBay (Archive)
      • About Protections (Archive)
      • About Products (Archive)
    • Social and Your Voice Archives
      • Off Topic (Archive)
      • My Feedback for PayPal (Archive)
    • About PayPal Archives
      • Watercooler (Archive)
      • Tax Information (Archive)
      • Fees (Archive)
      • eBay and PayPal (Archive)
      • Coupons and promotions (Archive)
    • My Account Archives
      • My account settings (Archive)
      • Account limits and verification (Archive)
      • Account balance (Archive)
      • Bank accounts and credit cards (Archive)
    • Payments Archives
      • Sending money (Archive)
      • Receiving money (Archive)
      • Refunds (Archive)
      • Donations and Fundraising (Archive)
    • Disputes and Security Archives
      • Disputes and claims (Archive)
      • Fraud, phishing and spoof (Archive)
    • My Business Archives
      • Merchant services (Archive)
      • Reporting and tracking (Archive)
      • Shipping (Archive)
    • PayPal Products Archives
      • PayPal Debit Mastercard (Archive)
      • PayPal Extras MasterCard (Archive)
      • PayPal Mobile & Other Services (Archive)
      • Student Accounts (Archive)
      • Bill Me Later (Archive)
    • Getting to know PayPal
      • My PayPal account
      • Security and protection
    • Receiving and sending money
      • Buying with PayPal
      • Selling with PayPal
    • PayPal Here UK
      • PayPal Here News and Events
      • PayPal Here Community
      • Chip and Pin Card Reader
      • PayPal Here App

The Community Forum will no longer be available starting June 30, 2025. Please note that the forum is now closed for new posts and responses, but previous posts will remain accessible for review until June, 30 2025. For comprehensive support options, please visit PayPal.com/HelpCenter
Merchant Technical Support: For technical support and related questions, please visit our Technical Support Help Center or Developer Central

If you want to report illegal content under the EU Digital Services Act, please do so here

since ‎Jun-26-2019
Country: United Kingdom
Type: Personal
Donquick
Donquick Contributor
Contributor
6
Posts
0
Kudos
0
Solutions
Friendly
Your PayPal Anniversary
The Return
Ice Breaker
Active
View all
Latest Contributions by Donquick
  • Topics Donquick has Participated In
  • Latest Contributions by Donquick

Re: BASIC Smart Payment buttons integration help

by Donquick Contributor in PayPal Payments Standard
‎Jul-02-2021 03:24 AM
‎Jul-02-2021 03:24 AM
Hi,    Thanks for posting.  I am a bit busy this week.  I will take a closer look over the weekend.  I did not ever resolve the problem as the project i was using the button on stalled.  Coincidentally it is now back on and I think we need to try the Paypal again.   Thanks, Don   ... View more

Re: BASIC Smart Payment buttons integration help

by Donquick Contributor in PayPal Payments Standard
‎Jul-02-2019 11:07 PM
‎Jul-02-2019 11:07 PM
Thanks as always Shawn,  I have been called away for work for a week or two and will resume with this when i get back.  Cheers, Don. ... View more

Re: BASIC Smart Payment buttons integration help

by Donquick Contributor in PayPal Payments Standard
‎Jun-30-2019 04:48 AM
‎Jun-30-2019 04:48 AM
Hi Shawn,   Thanks for your time and effort, I can see that this has taken you a long time.  I must say that it is very much appreciated.  For my part i have had another 10 hour day on this and made almost no progress.   Thanks for the details of the checkout.php code.  After a bit of tweeking, that is now working - it looks in paypal-transaction-complete.php and then returns control.  I'm not sure how we are supposed to know how to do this ".then(function(res))" part without relying on kind souls such as yourself.  I simply can't imaging why they don't give this as the example code as it is such a very likely scenario.  Anyway, moving on!   SDK! Today I managed to get Putty working and tried to follow this: https://developer.paypal.com/docs/checkout/reference/server-integration/setup-sdk/# I typed the word composer in every location i could - 'no such command'.  Abandoned after a few hours and thought i would try to just manually copy the files from the zip instead.   On the link that you sent:  https://github.com/paypal/Checkout-PHP-SDK there is a zip, as you say.  I downloaded that and copied the content into a folder that i called PapPal-PHP-SDK in my main folder where the php and css files are.  After that i looked at the sample code for the paypal-transaction-complete.php file.    First line:  require __DIR__ . '/vendor/autoload.php';   Well there is no such folder and no such file in the file structure that i downloaded from the zip, so i guess that is never going to work.   I found a different zip here:  https://github.com/paypal/PayPal-PHP-SDK/releases which does have an autoload.php file, so i deleted the original folder structure and copied this zip content into PayPal-PHP-SDK instead.   However, I notice that we have not defined ___DIR___ and there is no folder called vendor, so still a fundamental failing that means that it is not going to work.   Thanks for the supplementary comment.  I'm afraid that "Again just unpack the "lib" folder together with the checkout SDK" is not clear enough for me.  There is a folder called braintreehttp_php-0.3.0 in the zip and this contains files and a folder called lib.  If i try to put this content in the 'PayPal-PHP-SDK' folder then i will be overwriting certain files.  I guess I need to make another folder in the root next to the first one?   Questions please 🙂 1)  After putting files on my server from the zip files, does that mean that i have installed the SDK or do i need to then try to carry out the tasks listed here: https://developer.paypal.com/docs/checkout/reference/server-integration/setup-sdk/#   a)  If the copy is the install then great, I have some hope. b) if I then need to do all that extra stuff, then i'm going to throw the towel in.  Just reading 'Set Up The Environment', I can see that the instructions are too vague for me to follow.  'create a file' without saying what to call it or how it is going to get called. etc.   2)  Does the sample code for paypal-transaction-complete.php need editing significantly?  As i mentioned above, I see immediate problems with paths to files that do not exist on either SDK folder structure.  I have changed "require __DIR__ . '/vendor/autoload.php';" to "require '/PayPal-PHP-SDK/autoload.php';"  Is this a good idea - half of me thinks that the change is required, the other half thinks that Paypal surely wouldn't give sample code that fails on line 1 for all situations.  3) I have tried to run the code all sorts of different ways adding lines / taking them out / changing paths, you name it - i can't get it to work.  Any command that i put in after the "require" line doesn't work.   4) The sample file sets up a class call GetOrder with a function called getOrder(), but nowhere in my checkout.php do i create a Get Order object nor call a function called getOrder, so how is this ever going to work.   Well, there it is - I am very close to giving up.  If you have the time and the inclination I think the only way ahead would be step-by-step instructions for installing am SDK and editing the papypal-transaction-complete.php file - like you would talk to a complete moron.  "Copy this file to a folder called XYZ in your root folder.  Type this in here etc.  Edit that line of the php to say this instead.  After this line is where you add your database insert statement, etc. etc.   Without that, I am not going to be able to do this.  If you wany paying, that's cool too.   P.S. here below is my code at the moment.  As you see i am using an sql insert just to see how far i am getting.  At the moment the first instance is working and i get an extra line in the table and the second one isn't - the code fails at the 'require' line. I have a folder with all my phps and css file and in that i have a folder called PayPal-PHP-SDK whihc has the content shown in the image below.   Cheers, Don     <?php namespace Sample; include_once 'database.php'; include_once 'phpfunctions.php'; $resultadd = mysqli_query($link,"INSERT INTO user_products VALUES ('','1','3','','','','','','')") or die("Error ".__LINE__); //require __DIR__ . '/vendor/autoload.php'; require '/PayPal-PHP-SDK/autoload.php'; include_once 'database.php'; include_once 'phpfunctions.php'; $resultadd = mysqli_query($link,"INSERT INTO user_products VALUES ('','1','3','','','','','','')") or die("Error ".__LINE__); use Sample\PayPalClient; use PayPalCheckoutSdk\Orders\OrdersGetRequest; class GetOrder { // 2. Set up your server to receive a call from the client /** *You can use this function to retrieve an order by passing order ID as an argument. */ public static function getOrder($orderId) { // 3. Call PayPal to get the transaction details $client = PayPalClient::client(); $response = $client->execute(new OrdersGetRequest($orderId)); /** *Enable the following line to print complete response as JSON. */ print json_encode($response->result); print "Status Code: {$response->statusCode}\n"; print "Status: {$response->result->status}\n"; print "Order ID: {$response->result->id}\n"; print "Intent: {$response->result->intent}\n"; print "Links:\n"; foreach($response->result->links as $link) { print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n"; } // 4. Save the transaction in your database. Implement logic to save transaction to your database for future reference. print "Gross Amount: {$response->result->purchase_units[0]->amount->currency_code} {$response->result->purchase_units[0]->amount->value}\n"; // mmw code // end mmw code } } if (!count(debug_backtrace())) { GetOrder::getOrder('REPLACE-WITH-ORDER-ID', true); } ?> ... View more

Re: BASIC Smart Payment buttons integration help

by Donquick Contributor in PayPal Payments Standard
‎Jun-28-2019 11:57 PM
‎Jun-28-2019 11:57 PM
Hi Shawn,   Thank you so much for the reply.  I have spent some more hours wildly trying things at random and have progressed no further.  If you have time, can i ask for some more help please [example code is good, if you have it].   Can i break it down into two steps.  A) The verification on the server side, the response and redirect.  B) Whether i need the SDK and how to install it if i do.   A) The verification on the client and server side, the response and redirect   Specifically can we focus on this please - "From there, just check that the information received is what you expected, and if it is, release the product".  this is where i could really use some guidance and example.   For info, my buttons and the call are in a file called checkout.php.    In the sample code I see within onApprove an alert and a fetch.  The alert works and the fetch, I have no idea.  So presumably 100/100 people want to redirect their customer to another URL after a successful payment process and 0/100 actually want to display this alert window - i.e. i guess this alert is for test purposes only.  Also the alert is before the fetch anyway, so i guess that ultimately the alert gets removed?   I have created a file called paypal-transaction-complete.php and uploaded it and changed my checkout.php file to say "return fetch('/paypal-transaction-complete.php', {".    As you explained, the fetch should post the orderID to the php and return a response.    I have put the code from part 2 of step 6 of the instructions into my paypal-transaction-complete.php file.  [The code that starts with "<?php namespace Sample; require __DIR__ . '/vendor/autoload.php';.... "].  This code is clearly reliant on other includes and things, so it's not going to do anything until I have installed the SDK, right?  However, interestingly, I do not see any errors when i run this.  I guess that the errors and warnings are happening serverside or my path is wrong.   Questions:   1)  Is it the code in the example that goes into the paypal-transaction-complete.php file or is it something entirely different that i need to write.  If the latter, do you have some sample code please? 2)  Am i correct in thinking that i process my database work and do my redirect inside my original checkout.php file after i have got the return from the fetch OR does the paypal-transaction-complete.php do this work.  I think the former as the paypal-transaction-complete is just a server side thing, right? 3)  If it is my checkout.php where i do the work after the positive response from the fetch, what is the response from the fetch, a json encoded string?  So, this is the "From there, just check that the information received is what you expected, and if it is, release the product" question!   Where in checkout.php do i put code to check the response; what does apositive response look like; How do i redirect?  header('Location: confirm.php');  or a hidden form with some post data and java submit or something i guess? This is my checkout.php page at the moment - please, where do i put what i want to process the response and redirect?   <div id="shopping-cart"> <?php if(isset($_SESSION["cart_item"])){ $total_quantity = 0; $total_price = 0; ?> <table class="tbl-cart" cellpadding="10" cellspacing="1"> <tbody> <tr> Confirm Order Total Cost </tr> <?php $total_price = 0; foreach ($_SESSION["cart_item"] as $item){ $total_price += ($item["price"]*$item["quantity"]); } ?> <tr> <td>We are ready to process your order. Please acknowledge the terms and conditions and continue to payment.</td> <td align="left" colspan="1"><strong><?php echo "£ ".number_format($total_price, 2); ?></strong></td> </tr> </tbody> </table> <div id="validate_payment"><input type="checkbox" name="tandc" id="tandc" value="" onclick="validate_payment()"> I accept the terms and conditons and wish to proceed to purchase.<br></id></div> <div class="align-right"> <div id= "paypal_screen" title="Please tick terms and conditions box to proceed."><img src="images/screen.jpg"></div> <div id="paypal_button" class="align-right"> <!-- Set up a container element for the button --> <div id="paypal-button-container"></div> <!-- Include the PayPal JavaScript SDK --> <script> // Render the PayPal button into #paypal-button-container paypal.Buttons({ // Set up the transaction createOrder: function(data, actions) { return actions.order.create({ purchase_units: [{ amount: { value: '' } }] }); }, // Finalize the transaction onApprove: function(data, actions) { return actions.order.capture().then(function(details) { alert('Transaction completed by ' + details.payer.name.given_name); // Call your server to save the transaction return fetch('/paypal-transaction-complete.php', { method: 'post', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ orderID: data.orderID }) }); }); } }).render('#paypal-button-container'); </script> </div> </div> <? } else { ?> <div class="no-records">Your Cart is Empty. Sorry, you shouldn't be here, please choose from the menus.</div> <?php } ?> </div>   B) Whether i need the SDK and how to install it if i do.   I think i can possibly muddle through A) on a good day, but where i really need help is this area.  Let's assume that i am going to install the SDK, as you say that the other alternative involves a complicated process.  How anything could be more complicated that this, I cannot image; but that's my problem 🙂   So i need to install the SDK.  I have tried:   1) following the instructions on this page: https://developer.paypal.com/docs/checkout/reference/server-integration/setup-sdk/#   I get as far as the first step:     Put simply, I don't know where i type this command.   2) following the 'Using composer' instructions on this page: https://github.com/paypal/PayPal-PHP-SDK/wiki/Installation .  I can get as far as this screen after downloading composer-setup.exe:     I don't have php on my PC I have it on my 1&1 webserver so i don't know how to progress.   2) following the 'Using direct downloads' instructions on the page.  I get as far as 'Go to your project directory', step 2.       How can i be in a position where i have a command line console on my 1&1 webserver?  Or can i just create a directory in FileZilla and copy the files there? I wonder, does it have to be called 'project'.  I don't really want all that stuff in my root directory with my php and css files.   3) I tried downloading putty.  Completely baffling:     Uncertainty about the folder structure in the SDK:  There are various Zip files on various websites.  I have downloaded the zip from here: http://paypal.github.io/PayPal-PHP-SDK/docs/ also from here: https://github.com/paypal/Checkout-PHP-SDK  I can't help but notice that in the sample code (in paypal-transaction-complete), there are references to '/vendor/autoloader.php' and Sample\PayPalClient and PaypalCheckoutSdk\Orders...  There are no such locations in the zip file directory structure that I have , so i think that this is going to fail anyway.   Conclusion Well, if you are still with me then thank you again.  If you do manage to help me, then i will post a step by step guide for all web novices that can do a bit of php/java/html but have no idea about APIs.  So you will be helping a big group of people in the long run.  Thanks again.         ... View more

Re: Smart Payment Button - Variable amount

by Donquick Contributor in Merchant Products and Services Archives
‎Jun-26-2019 08:32 PM
‎Jun-26-2019 08:32 PM
Hi,   You have set variable sel to be the element 'PaymentAmount' rather than the value contained there.  Use:  var sel = document.getElementById('PaymentAmount').value;  instead.  Then just replace '0.01' with sel.  Might have to try with and without the pair of single quotes. ... View more

BASIC Smart Payment buttons integration help

by Donquick Contributor in PayPal Payments Standard
‎Jun-26-2019 08:03 PM
‎Jun-26-2019 08:03 PM
Hello,   Objective I want to put Smart Payment buttons on my website (php).  There are no physical products, I just need to add some download links to the individuals account once they have paid.  Ideally, all the work gets done by the buttons and then when I get into the onApprove function, I want to redirect to a confirmation page on my website (if it can $_POST at the same time, all the better).  I will then do some changes to the database using my $_SESSION data (to make the customers products visible in their account - i.e. available for them to download).   Where I am now: I am following this set of instructions:  https://developer.paypal.com/docs/checkout/integrate/# headed 'Basic Integration Paypal Checkout'.   I have got as far as step 5.  It works!  My test buyer account is debited, my test seller account is credited and I get the javascript alert window saying 'Transaction completed by ...'.   OK, now i am stuck.  Step 6 has a client side and a server side process.    CLIENT: Of course, I can do the changes to the checkout code, but i do not understand the "fetch('/paypal-transaction-complete', ".  Do i need to make a file called 'paypal-transaction-complete' (what is the extension, this looks like a directory reference not a file reference to me) or is this something that is already part of paypal?  If i do need to make this file, I wonder what is in it.     SERVER:  I must upload the SDK to my server or not?  There is a box that says - "If you are calling the API directly, you do not need to install the SDK."  I think this sounds appealing, but how do i know if I am calling the API directly, what do i do instead of the server part of step 6 if i am calling the API directly - there are no alternative instructions for not installing the SDK.     The instructions for uploading the SDK here: https://developer.paypal.com/docs/checkout/reference/server-integration/setup-sdk/# also imply it is optional.  [Another problem: The first step on the SDK installation implies some sort of direct console/shell to the server.  I don't know how i would do that, I just have a hosting service with 1 & 1.  I don't know if they allow installations direct console activity etc.].   Summary and question I think i understand that the client should report transaction success to the server and record the results in the database and that that requires the SDK to be installed, but i think that this is for my benefit rather than a compulsory paypal process and it is something i would be willing to forego.  My risks are low - very low price items, very low volume of transactions that I can check manually in Paypal to see if the payment has been received etc.    I would be quite happy to get a success response from the paypal overlay window and then proceed to a redirect on my site and do all the database work there, but i would like to pass some data.  I am happy to bypass the server side processes and/or communicate with the API directly without installing the SDK if this is possible.  However, i don't see the instructions for this (instructions including what to name files, where to put them and how to modify the php code in my checkout file to do this).   Many thanks for help. ... 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
Welcome to the PayPal Community!