Skip to content

Making a WebPayment

Oleg Fetisov edited this page Sep 27, 2016 · 4 revisions

JudoResponsive allows you to easily accept card payments within your WebApp. judoResponsive supports both desktop and mobile devices and make your PCI-DSS compliance easier. It also includes additional card holder verification using Post-code verification and 3D secure.

Configuration Checklist

  • You need to configure the "Success" and "Cancel" urls for your application and as it might be expected the app will return the success url if the payment is successful and the cancel url if the payment is aborted.
  • Your API token needs to have the permissions to "create" web payments, you can edit these permissions on the application configuration screen within our merchant dashboard

Provisioning the web payment

Before you can send your user to the judo payment page, you'll need to tell us the details of the web payment using our JudoPay API. Support for this is built into our Ruby SDK:

# Populate the api token and api secret details with the Judopay gem
# from the application you created on our 
Judopay.configure do |config|
	config.judo_id = 12345
	config.api_token = 'your-token'
    config.api_secret = 'your-secret'
end

# Create an instance of the WebPayment Payment model, or you can use the Preauth model 
# if you only want to process a pre-authorisation which you can collect later.
payment = Judopay::WebPayments::Payment.new(
  :judoId => 'your_judo_id',
  :your_consumer_reference => 'xxxxxxxx',
  :your_payment_reference => 'xxxxxxxx',
  :amount => 10.00,
  :currency => 'GBP',
  :clientIpAddress => '127.0.0.1',
  :clientUserAgent => 'Their browser user agent/11.0'
)

# Send the model to the JudoPay API, this provisions your webpayment and returns a unique reference along with the 
# URL of the page you'll need to dispatch your users to.

webpayment_details = payment.create

# Here's an example of the Mash returned
# {
#  "post_url"=>"https://pay.judopay-sandbox.com/v1",
#  "reference"=>"4AcAAAkAAAAXAAAABwAAAL2kP2Pk-XatKSeqDvWdlGDvyuKCHCEdTsnEwVZ76TNDVawo4g"
# }

web_payment_reference = webpayment_details.reference
form_post_url = webpayment_details.post_url

Dispatching your user to judo

You should then dispatch your user to our server using a POST request, this can be done easily by wrapping your "Pay Now" button in a form as follows:

	<form action="<%=form_post_url%>" method="post">
	<input  id="Reference" name="Reference" type="hidden" value="<%=web_payment_reference%>">
	<input type="submit" value="Pay now">
	</form>

Capturing the returned information

Whether payment was successful system returns to pre-configured success url using a POST request. Included in this POST request are the following form fields :

reference - this is our reference for the web payment.

receipt_id - this is our reference number for the JudoPay API transaction.

card_token - this is the unique reference for your user's card. If you want to process further payments on their card (either as a "saved card" feature, or a reoccurring subscription payment), you must capture this card token.

Please note that you cannot retrieve the card_token later, if you wish to use this card in a future payment (i.e. Pay with your saved card) you will need to capture and store this value.

Verifying the payment

Finally you should always verify the payment outcome using the JudoPay API, this will protect you from the request tampering.

# Invoke the find method passing in the reference you obtained above to the WebPayment Transaction class
# (as web payments can either be payments or preauths we have a superclass called transaction).

transaction_details  = Judopay::WebPayments::Transaction.find(web_payment_reference)

# check the value of the "status" to confirm the payment was successful
webpayment_status = transaction_details.status

# webpayment_status should be "Success"
# you can also access a copy of our receipt object using the "receipt" entry.
receipt = transaction_details.receipt

Clone this wiki locally