image

Great way to accept credit cards

June 24, 2010 by
Filed under: Payments 

Credit Cards PaymentsSimple and secure
By combining eCrisper’s user database with Paypal, you can accept credit card payments through a web page without the need for additional hardware or complicated processing. This solution is simple, secure, and can be used to create new accounts or recharge existing ones. What follows is a series of steps required to implement this payment solution.

Step 1 – Create a merchant account with Paypal.

Step 2 – Login to your Paypal account, go to Merchant Services, and create a Buy Now button. Specify an Item name, for example Account purchase. You can have one price for a fix number of minutes, or add a drop-down menu with price/option to offer options such as 10, 30, 60 minutes. Add 2 Text fields, Username and Password. Answer Yes/No questions and specify pages for cancel and finished checkout.

In the generated html, change the name os1 for invoice and os2 for custom. This renaming is necessary for the values to be sent by Paypal. Also, add the following line inside the form generated by Paypal (the Buy Now button) but with your own server name.

1
<input name="notify_url" type="hidden" value="http://ecrisper.com/ipn_process.php" />

Step 3 – Create a web page that will be displayed on the main menu, for example in the left box webview. You will find an example at ecrisper.com/accountcreation.htm – you can view the source to compare with what you got from step 2. Insert your html code from step 1 into your new page.

Step 4 – Add the following database table to keep a record of payments. Here is a simple example but you could add name, address, etc… as needed. I assume you already have tables users and sessions described in the previous posting.

1
2
3
4
5
6
7
CREATE TABLE payments
(txn_id VARCHAR(30),
username VARCHAR(30),
amount FLOAT,
currency VARCHAR(3),
payment_timestamp TIMESTAMP NOT NULL DEFAULT NOW(),
PRIMARY KEY (txn_id));

Step 5 – When a payment is completed successfully, we need to be notified so that we can create the new account in the database. PayPal makes this possible through Instant Payment Notification(IPN) by sending the transaction data to a script you specify (we used the name ipn_process.php in step 2). This script then has to post all the data back to PayPal and wait for a response. If the transaction is valid, PayPal will return a response “VERIFIED” and the script can create the new account.

The link below will show you an actual IPN script written in PHP. To keep it simple, it assumes that the purchase is for a new account. It could easily be modified to check if the account exists and to update the balance if it does.

Working example of an IPN script

IPN Guide from Paypal

Step 6 – Set eCrisper to require an account, and display the web page from step 3 in one of the webviews. In the example below it is displayed in the left box but it could be cleverly arranged to be right beside the login box.

It took me a while to figure out how to use IPN so you may need a bit of patience to get it to work. I think this is a great way to accept credit cards.

Comments

Comments are closed.