Paypal Website Payments Standard with dynamic Amount - php

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.

Related

How to get payment amount from Stripe token? (in PHP)

I've got a site that offer users 3 different subscription plans (with 3 different prices). So there's a sign up page with 3 different subscribe buttons, each of which opens Stripe Checkout for the appropriate amount for each plan (I'm using the standard Stripe simple Checkout integration https://stripe.com/docs/checkout#integration-simple ) .
On my server I know which plan a user has subscribed to because I've got a hidden field in each Stripe Checkout button form with the plan name. The problem is how to stop someone editing the form (e.g. using developer tools in their browser) and changing the hidden plan field so they get e.g. the Gold plan at the Basic plan price.
The obvious solution seemed to be to check the amount associated with the stripeToken that Stripe returns (i.e. the same as the data-amount field in the Stripe Checkout form), before calling the Stripe API to actually subscribe the user. However, I'm not sure how to get the amount from Stripe using just the token and can't find an obvious API call for this.
Or is there some better way of handling multiple subscription plan options while ensuring a user can't somehow get away with paying a lesser amount?
Thanks.

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

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.

Pay event fee with paypal and allow guests

I have been hunting around developer.paypal.com for a couple of days now and have the gist of what I need. But I am still looking on the best way to accomplish my task.
What I need is a way for people to pay a fee for an event from my website. I would prefer to allow Guest Checkout as not all attendees will likely have a paypal account yet. But what I would really like is for the paypal website to handle all of checkout. In ebay, you see the total, a small summary and you pay for it right there. I have looked at express checkout, and it wants to return the user to my website to finalize everything.
So in short:
Allow guest checkout
Show payment total on Paypal webpage
Allow payment to be finalized and 'Captured' from PayPal's website, only coming back to my page to say Thanks.
And if possible, not require an address of the attendee
Can this be done?
I have long used StackOverflow for answers, but I am having a hard time finding this answer (mainly because I don't know exactly what I am looking for).
Thanks in advance
You are describing "standard", and the HTML button integration will be much easier than Express Checkout.
Express Checkout is the most robust API to use. The "return" to your site is a good thing, to give the customer the ability to click a final "Place Order" button. But you can also have this triggered automatically on return -- just run DoExpressCheckout without user interaction and display a thank you / confirmation message. If you are going to run DoEC w/o interaction, your initial redirect to PayPal.com should have &useraction=commit appended to the URL. Then, the final button at PayPal.com will say "Pay Now" instead of the default "Continue"
To allow guest checkout with EC, pass SOLUTIONTYPE=Sole in the initial SetEC call. Note that when customers load a PayPal.com checkout page, it checks their browser cookies to see if they have a PayPal email address stored. If they have one stored in the browser, the top "Log in to PayPal" section will be expanded. If they do not have an address stored -- generally meaning this is a brand new computer or they've never used a PayPal account to check out on this one before -- then the bottom guest checkout section will be expanded.
To not require an address, pass NOSHIPPING=1.

PayPal Digital Goods: How to get item number after purchase made?

I got a simple Digital Goods Checkout to work in Sandbox mode. I have a "Pay with PayPal" button that I can click which pops up an window for logging into PayPal. After that it redirects me to my purchasemade.php script, and from there I can successfully download a file.
My problem is that on my website I'm going to sell many products, so I need to know which product they want to download when they finish the purchase. Each product has a unique ID, so I thought I'd pass that ID as the item number in the HTML form as a hidden field named "item_number". However, I don't know how to read that value once I reach the purchasemade.php.
How do I read values passed in POST in the original form? Otherwise, what's the best way of identifying a product? I'm using PHP as my scripting language for this project.
If you're going to stick with Payments Standard I would recommend using IPN to deliver your digital goods. You could use PDT (which is very similar to IPN) to send order data back to the page the user gets redirected to, however, there is no guarantee they will make here even with Auto-Return enabled in your PayPal account.
Alternatively, you could use the Express Checkout API instead of Payments Standard. This method guarantees the user will make it back to your site prior to completing payment. This will allow you to utilize session variables so you can present the download to the user on the thank you/receipt page.
Still, though, I think IPN would be your best bet regardless of which way you go. You can use it to auto-deliver the digital goods, send out general email notifications, update your database, hit third party web services, etc. all in real-time.

Passing variable values over to paypal's cart for payment

I have created a basket where a user can add to and update etc. This basket has been built based on what product the user adds to cart obviously. The product itself is grabbed from the database and displayed in a table in the basket. How do I use Paypal from here? I now want a button called 'pay' that the user can click and then it takes them to Paypal to pay. But I want the details of the items to be displayed in Paypal.
I have signed up to paypals web standard payment. Obviously I don't need their add to cart buttons since I have got my own cart. I think I just need the buy button but as mentioned, I am not sure how to get products over to Paypal.
Can somebody explain what I need to do please
This broad of a topic is generally best suited with a quick Google search. Basically, find a paypal form (perhaps through Paypal's button builder) and edit the form's values to suit your needs. This can be accomplished with php or javascript quite easily (PHP is a bit safer as it limits tampering). Then users send the form :)
You can also create a link such ashttps://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=$business which will do the same as the full form (add all of the fields you want to send, of course).
Give it a shot - if you have more specific questions, post back with clarifications.

Categories