Friday, June 8, 2012

More and more types of services that once were exclusively 'server-side' on your web-server, are now independently hosted web services, accessible via a web API.

One such task is handling credit card charges; Stripe.com handles credit card processing through a web API. Rdbhost now supports handling charges for your hosted web application via Stripe.com. This is the second web-service we support, after email.

This service works similarly to the email mode, in that a query pulls the input data for the charge, including CC Num, CCV, expiration, etc, formulates a Stripe request from it, submits it, retrieves the result from Stripe, calls a database function to store the result, and then returns a summary status record to the client, via the selected data format. Any or all of the results of the initial query can be concealed from the client, for customer privacy and security reasons.

CC Charging uses a new mode, called 'charge'. Each record returned by the submitted query must contain a certain set of fields, to include 'ccnum', 'amt', 'apikey', 'service' and 'currency'. One charge is run for each such record.

Since the actual charging is done by a third party email web-service, you need to set up an account on stripe.com; they will provide you the API key.

The result page is formatted just as the result page for email mode, with either 'success' or an error message for each record processed.

jQuery Rdbhost Plugin

The jQuery plugin does not have any specific methods for charging, but the $.postData method will suffice, and the example linked below shows how to use it that way. This example only relies on database storage for the api key, as that needs protecting from the end user.