3
5 Comments

Adding PayPal button to user page

Hi there
If we have a SaaS where I allow users to set up a booking page for their business, is there a simple way to allow them to take payments online? I wouldn't need a cut of the proceeds. It would be ideal if the amount could be made dynamic - e.g. I could generate a button that paid a certain amount.
Most useful would be a way for my site to be notified when a payment was successfully completed. In the old days there was a PayPal IPN but IIRC that pinged whenever that user bought anything and was a royal PITA for them to set up.
What do other people on here use? Would be v grateful for any pointers.

  1. 2

    I'd go with Stripe too, but if you want to use PayPal, their smart payment buttons are good and easy to implement: https://developer.paypal.com/docs/checkout/
    I believe paypal won't notify your server via webhook. But you have to specify a custom success callback, so you use this to ping your backend.

    1. 2

      Thanks for this. I had just seen the custom paypal button on this page:

      https://www.dummies.com/business/online-business/ebay/how-to-create-a-paypal-button-on-your-website/

      and yes I think that would work. I noticed it seems possible to be able to add a IPN url as well with the 'Advanced Features' page e.g.

      address_override=1
      notify_url=https://www.mywebsite.com/PayPal_IPN
      

      The button can then be made into a URL with all of these as GET parameters. I'll test it out when I get a chance and see what info is sent to that IPN link. Looks promising though :)

      Thanks to all for your replies!

      1. 1

        Tried it and it works. In case it helps anyone here:

        • you set up a button on your site according to that above link
        • your IPN URL needs to be https or it seems to be ignored
        • the user is not automatically redirected to your 'success URL' after the payment is complete - they have to choose to do so by clicking 'return to merchant', so the IPN notify_url is more reliable. It arrives a few minutes after the payment.
        • either PayPal or ngrok are stripping the trailing slash of my notify_url so safer to make sure you can POST to your callback both with or without one.
        • you can add an item ID to the button which is passed through so you can identify the payment against your database when the POST data arrives.

        Perhaps a little overkill but thought example (obfuscated in places) POST data might be useful:
        {'mc_gross': ['0.01'],
        'protection_eligibility': ['Ineligible'],
        'payer_id': ['XXXXXXXXXXXX'],
        'payment_date': ['16:27:20 Feb 06, 2020 PST'],
        'payment_status': ['Completed'],
        'charset': ['windows-1252'],
        'first_name': ['Joe'], 'mc_fee': ['0.01'],
        'notify_version': ['3.9'],
        'custom': [''], 'payer_status': ['verified'],
        'business': ['[email protected]'],
        'quantity': ['1'],
        'verify_sign': ['xxxxxxxxxxxxxxxxxxxxxxxxxxx'],
        'payer_email': ['[email protected]'],
        'txn_id': ['7Xxxxxxxxxxxxx3R'],
        'payment_type': ['instant'],
        'last_name': ['Bloggs'],
        'receiver_email': ['[email protected]'],
        'payment_fee': [''],
        'shipping_discount': ['0.00'],
        'receiver_id': ['XXXXXXXXXXXXXX'],
        'insurance_amount': ['0.00'],
        'txn_type': ['web_accept'],
        'item_name': ['Item name goes here'],
        'discount': ['0.00'],
        'mc_currency': ['GBP'],
        'item_number': ['ITEM ID ON YOUR SITE'],
        'residence_country': ['GB'],
        'shipping_method': ['Default'],
        'transaction_subject': [''],
        'payment_gross': [''],
        'ipn_track_id': ['xxxxxxxxxxxxxxx']}

        Hopefully the bank won't stop my credit card because of all the suspicious £0.01 transactions I've been making tonight :D

        This will get me moving forward. Very pleased.

      2. 1

        This comment was deleted 4 years ago.

  2. 2

    I'd go with Stripe for this. You can dynamically create one-time/recurring payments and you can also get notified via Events if e.g. a charge went through. Stripe is very developer friendly and has a few libraries for all major languages.

    https://stripe.com/docs/api
    https://stripe.com/docs/api/charges
    https://stripe.com/docs/api/events

    1. 2

      Thanks, I've heard good things about Stripe :)

Trending on Indie Hackers
Getting first 908 Paid Signups by Spending $353 ONLY. 24 comments I talked to 8 SaaS founders, these are the most common SaaS tools they use 20 comments What are your cold outreach conversion rates? Top 3 Metrics And Benchmarks To Track 19 comments How I Sourced 60% of Customers From Linkedin, Organically 12 comments Hero Section Copywriting Framework that Converts 3x 12 comments Join our AI video tool demo, get a cool video back! 12 comments