Paypal - Dynamically change HTML variable for "Buy Now" button? - php

I'm new to Paypal integration. I need to dynamically change the HTML variable to the Buy Now button since I need to calculate discount_rate and shipping.
At first I use the hosted button, but then realized that I can't add new variables.
So I found this alternative way which is creating our own button. But then the customer can simply "Inspect Element" and change the value of the input.
Is there better and more secure way to implement dynamic pricing for Paypal?
Can I submit the payment through backend script like PHP?
Thanks

You can use the PayPal express checkout API to create a purchase in the background then send the user to PayPal with a token linked to this purchase.
if you do go down this route, I recommend using this class as it is very simple, yet powerful;
https://github.com/thenbrent/paypal-digital-goods/
On the other hand you can continue what you are doing with the non-hosted buttons and simply check the gross amount paid by the user against what they should have paid in your notify script.

Related

Is there any way to change Tax Text on PayPal form using PHP?

I am using Paypal Payment and I need to change TAX text.
Currently it Display Tax only I want to change it Tax(10%).
No, this text cannot be changed.
If you want your site to have your own display before reaching PayPal with an option to pay with a Debit or Credit Card as an inline form on your site, use this approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server
(Also allows PayPal payments to be made without redirecting away from your site, within a small in-context window)
You'll need two server-side routes for the approval JS to call, one to create an order and one to capture it.

Paypal options for "Pay now" button integration (PHP)

I have rolled out my own shopping cart website in PHP, and I want to add a "Pay Now" button which:
Sends the user to Paypal with a total amount payable
Allows the user to pay with or without a paypal account of their own
Prevent user from hacking around with the final amount (e.g. plain text attributes in HTML)
and I want a solution where I do not pay any monthly Paypal fees. But I'm finding the Paypal documentation seriously confusing, as well as other SO questions:
Paypal: Paypal Button Manager overview
SO: Paypal Pay Now Button
SO: php basic pay now button for paypal
SO: PayPal: express checkout pay without account
The Paypal documentation suggests that if I want a "Pay Now" button, the only option I have is to use "Hosted Sole Solution only". What exactly does this mean?
It also says "You cannot use hosted buttons with Hosted Sole Solution; you should use token buttons instead." Please forgive the stupid question, but this means if I want a Paypal "Pay Now" button, I have to use the "Hosted Sole Solution", which always uses "Tokens"? How exactly does the "Token" scheme work? Other questions suggest data is sent in plain text so can be hacked around with, yet the concept of tokens seems to suggest otherwise?
And last but not least, are there any examples of PHP code for the "Pay Now" button? I'm mystified why it all has to be so confusing!! (I'm comfortable with PHP, but to really understand how the Paypal "Pay Now" system works, examples would be ideal)
In case it matters, I will also want to use Paypal IPN, but I have done this before, so will regard it as a separate task, unless it has to be considered for the "Pay Now" button.
The big factor here is going to be the fact that you do not want to pay a monthly fee. This will limit you to using PayPal Payments Standard / Express Checkout, both of which have no monthly cost.
PayPal Standard are your "Pay now" buttons. They are nothing more than an HTML post form and can be created within your PayPal account's button factory, or you can create your own forms.
PayPal Express Checkout is an API based solution which in the absence of a shopping cart platform will perform nearly identically to PayPal Standard. Express Checkout does not allow the customer to checkout as a guest by default, additional variables (solutiontype=sole) need to be passed with the initial API call.
It sounds to me like PayPal Standard is going to be the product you are after. Here is a link to the base "developer" guide for PayPal Standard:
https://developer.paypal.com/webapps/developer/docs/integration/web/
If you prefer to create the buttons through the PayPal system, login to your PayPal account, click 'Profile' in the top right, then select "My Selling Tools". Select "Update" next to "PayPal Buttons" and then click on Create New Button on the right side. The button builder is really a simple tool and will provide you with a complete HTML form to paste into your site's source.
It turns out that what I wanted is the Express Checkout:
Getting Started with Express Checkout

Does paypal generate any event after clicking pay now button?

I've a shopping cart implemented in PHP and the checkout process is handled by PayPal. When the customer presses pay now button in PayPal, does it generate any events so that i may process that information and based on the stock levels in my database decide whether to accept the payment or not?
No, but you can do that after payment with PayPal IPN, it sends all the data about purchase back ..
You could use javascript to query your server about stock levels on-click, and submit the form if everything looks OK.

Paypal subscription button

Background
I'm building a website where I need to use some sort of recurring billing payment method. My client does not have Paypal's Website Payments Pro so he decided to use a simple Subscribe button.
Problem
This is all nice and easy to use but how would I get a notification from Paypal when such a payment has been made? I had some experience with Paypal before and there was a field return_url that would be accessed by Paypal to notify the website but checking the variables on their site this field does not exist anymore or perhaps not available with this type of button.
when you create subscribe button that time you will find that option(in step 3) , so according your need you can set url and get ipn variable
Step 3: Customize advanced features (optional)
Take customers to this URL when they cancel their checkout
http://yourwebsite/complete_registration.php?action=cancel&sts=0
Take customers to this URL when they finish checkout
http://yourwebsite/complete_registration.php
Advanced variables
notify_url=http://yourwebsite/complete_registration.php
i hope it help you

Paypal Website Payments Standard with dynamic Amount

I have a scenario where a user can input the amount he wants to be billed. I use buynow buttons that are created using code. Now in this case what what i had in mind was to:
Set minimum billing amount to 10$
If he enters below that, give error.
Set the amount of buynow button 10$ when form loads.
Once User inputs a number greater than 10 do an ajax request to controller
Check if their is a button saved in DB against that amount that was created earier on PayPal.
If button does not exist, create a new one on PayPal, save button in the DB.
Return the HTML of the newly created button
Replace the existing button with the returned HTML
Problem with this approach is that it might be too heavy. I also do not want to spread form over 2 pages. Are there any alternate and better options? Can i do some tweaks to make this option more robust?
A better option in this case would be to use the API and do the payments via either Express or Payments Pro. Essentially, you're trying to over-complicate this by making the buttons to the job of the API; getting the worst of both worlds in the process.
You could still utilize a "pay now" button graphic, but just submit your own request to the paypal express gateway (exactly what the button does for you) with a couple curl commands.
There are many tutorials available, but PayPal provides PHP code and a complete walkthrough on their site, so best, in my opinion, to go right to the source.
Log into PayPal -> Merchant Services -> Express Checkout
Under "Setting it up", you'll find all the implementation details.

Categories