eCommerce membership subscription after payment - php

I am creating a site in which a user must pay in order to access certain parts of the site. I understand how to make certain pages available to certain users, but I would like to know how I can automatically give them access once their payment has been processed.
ex.) A user sets up a account, during the process it will ask for credit card or other payment info(I would like it to be through Paypal). Once the payment has been processed it will add the user to my database and then they can access the site.
I am new to eCommerce and would like to know what tools I can use so that when a purchase on my site has been processed, I allow the user to access the website.
note: My site is being built with PHP.

I would recommend using Instant Payment Notification (IPN) for that.
It's basically a script that sits on your server listening for data. Any time your PayPal account has a transaction that takes place it will automatically push data to your listener script in real-time. Within that script you can update your database, send out email notifications, etc.
Here's a PHP template for IPN that I developed years ago. It's a little rudimentary, but still very useful and will get you up-and-running with IPN within minutes. Then all you would need to do is make some basic additions to update your users table accordingly, but the template comes with a nice database class that makes that very simple as well (assuming you install the IPN template solution to the same DB as your users table.)

Related

Stripe: How To Avoid Calling The API Too Often?

I am building a (small) subscription box business and I now need to focus on the web app. I already built stripe-based websites so I have a decent knowledge.
However, the issue I faced when building these previous sites is that the API was called TOO OFTEN. It slowed everything down.
How to build this subscription-based website, only with stripe, and making calls to Stripe API only when required (create/edit a customer, plan, subscription, etc.) while still making sure information is reconciled and up-to-date on the website for both admin and clients?
Check out the Stripe Webhook API here: https://stripe.com/docs/webhooks
You can store the user's information in the database and only update those fields if the user makes a UI action and you can make an assumption on what to update (like a subscription plan ID) or using a webhook handler, which you can use as a sanity check as well.
To be even more specific, I can give some examples as you will still need to make API calls when a user does an action such as: creates an account, removes their subscription, subscribes to a different subscription. You will store when their subscription expires in the database. When the user makes a request you do not make an API call to check when their subscription expires, but check the database field. When the subscription renews itself you will then have a webhook handler to update the expiration date in the database.
Essentially how it works is Stripe will make a request to YOUR service only when it needs to, instead of your service calling to Stripe on every request.
For WordPress specifically you can user the User Meta Data to cache/store the user's information and only make calls to your database for faster transactions. http://codex.wordpress.org/Function_Reference/get_user_meta

Passing a custom variable from a PayPal button after a user subscribes

I am working on a subscription service for a test website of mine. I have the infrastructure in place so that when a user registers, they need to subscribe before going to their profile. How can I tell if a user has finished subscribing? I have a flag in my database that will turn to true after they subscribe, but I can't seem to figure out that last handshake.
I tried to set it up when making the button to go to "http://www.example.com/profile.php?completed=true" so that I can simply look for that completed variable, but paypal seems to ignore that. Any thoughts on how to do that?
Upon looking at a similar post on here, I could redirect to a success.php, where it can update the database flag. This is a work around, but is this the only solution? Or is there one similar to what I originally wanted to do? Thanks for your input everyone.
You should make use of Instant Payment Notification
Instant Payment Notification (IPN) is a message service that automatically notifies merchants of events related to PayPal transactions. Merchants can use it to automate back-office and administrative functions, like automatically fulfilling orders and providing customers with order status.

Auto FIll Virtual Wallet for Users Wordpress

I am trying to integrate Virtual Wallet system for payments into a WordPress Based E-Commerce Website
I am using this plugin for this -
Link To Plugin
Working Process Of This Plugin
In this plugin From Admin Dashboard Admin can select the user from all users on the website and assigns a particular money in the wallet of the user then user can buy from the website within that money
My Problem and Requirement
But for this I need to fill the amount in user's wallet manually . I want that user transfer me money on paypal and it will be automatically added to his wallet
I was unable to find proper information regarding . Is this possible to be done in wordpress and Is there any plugin available to do so
I would recommend using PayPal IPN for that. Every time a transaction hits your PayPal account their server will POST data about the transaction to a URL on your server. That URL can receive the data and update your system accordingly. It happens in real-time, too.
You can get up and running with IPN very quickly using the PayPal IPN for WordPress plugin. Then you could use the hooks provided by the IPN plugin to do whatever you want to do with the PayPal payment data when it receives it.
For example, the paypal_ipn_for_wordpress_payment_status_completed hook would be triggered any time a successful payment occurs, so you could use that within your own plugin or your theme's functions.php file to automatically update the wallet balance of the user based on the data provided in the IPN.

Paypal paying back users

We've integrated Paypal on website of client for accepting payments.
All is fine.
But client wants to be able to pay users of his website back if they have earned some bounces/scores etc.
By now we have implemented such system:
If user of website should get paid - admin of website gets notification about it in admin panel
Admin looks manually at data of client and decides whether he pays or not (pressing approve or deny button)
It looks so:
Client is not satisfied with such system, saying it will get tedious and boring business when he gets many users (unlikely, but this is not the point).
I wonder. Is it possible somehow to automatise this process? He would like only to press "Approve" button and user should be paid immediately.
At first I've thought about using the same code that I use for accepting payments:
But when I accept payments, I use address of created shop. Usual users of paypal don't have shops. Well, this is all pretty confusing.
Any links or advice are appreciated. Because I'm not sure whether such thing is possible or good at all or perhaps I should say client that it can't be done.
Thanks in advance.
You can send a payment programatically using MassPay or Adaptive Payments (Implicit Payments). Either of these methods is a little more advanced, and you have to make an API call to the PayPal server.
MassPay has some restrictions US or CANADA business accounts only.
AdaptivePayments requires the account to go through an application process on http://developer.paypal.com and http://apps.paypal.com

How to create a system to access a page after payment has been made in https://www.realcredit.com/?

I want to create a credit card payment processing section in https://www.realcredit.com/ for my site. The users are allowed to access a page after payment has been made. What are all the steps needed to create a system like this. If anyone worked on credit card processing in Realcredit for a PHP site, guide me to implement the credit card processing section.
First you should specify if that payment is for a one time service or some sort of longer subscription/license.
If it's just a one time payment you might want to create a system where one can access the page using a single-use token. (You visit the page with an appended security token on the url and your session gets validated and the token invalidated.)
Then implement the payment system according to the API of realcredit.com and once the payment has cleared send a mail to the customer (or if clearance is instant display a page) containing a link with such a one-time token.
If you want to implement something like a license system then you might want to first implement a user-login for your page or a user database. Then once the payment has cleared set a flag on said user-record in your database allowing access to the page you want to protect.

Categories