Connect With Us

Rails Payment Integration with zipPay (Buy Now and Pay Later)

By Nelson Suwal on Mar, 23, 2018 in buy now pay later, zipmoney merchant, zipmoney, zipPay Australia, afterpay stores australia, buy now pay later online, zipPay integration, zipmoney merchant integration, zipmoney australia, jyaasa, Rails zipPay integration, payment integration, zipPay checkout, Rails zipPay integration, zipmoney-ruby-sdk

zipPay is a safe, simple and 100% interest-free account, which offers Buy now and Pay later.  zipPay is owned by zipMoney Limited with all operations based in Sydney, Australia. Once customer has zipPay account, they can use their digital wallet to buy product without  credit card and interest. Customers can buy upto $1000 (australian) and offers payment with four installments. The minimum repayment of at least $40 per month was required. A $5 monthly service fee will be added to the consumer’s account for any month there is an outstanding balance.

 


 

Integration requirement and process
The requirements to integrate zippay to the application: we need two accounts: one for merchant and another for customer. Here, merchant account records all transaction status,  product details and provides the credential require to integrate zippay to our application. Merchant have right to capture amount, refund account and cancel order. For testing zipmoney provides sandbox merchant account.


Test Merchant Registration
For merchant sandbox account, we need to fill signup form on merchant website and need a confirmation from zipmoney team for approval of  our request to create merchant account.

Once account is created,  we will have the following information from our account:

  • Merchant Id - This is your general merchant identifier
  • Merchant Secret Key - This is your secret API key that will be used for all API communications (You MUST store this key securely and keep it private)
  • Merchant Public Key - This is your public API key that can be used for accessing our widget library and does not require secure storage


For testing transaction between merchant and customer, We require zippay test account. ZipPay test account can be created from zipPay website.  Before creating account, we need to have following details:

  • Social or Email - One must use a unique social account and/or email address for each account to create
  • Mobile Phone - One can either enter own phone number, or for sandbox account one can use the phone number 0400000000 and the sms code 123456 to create as many accounts as need.
  • Repayment method - For test account we can add the card number 4005 5500 0000 0001 with expiry 12/25 and CVV 123. This will allow  to top up account as required to test multiple purchases

 

Integrating zipPay with Rails Application

To integrate with Rails Application, we can use zipMoney API for checkout, capture and refund.

We used gem: zipmoney-ruby-sdk

Configuration

We need to add following on app/config:

require 'zipMoney' 

# Configure the api credentials 
ZipMoney::Configuration.merchant_id  = ENV['MERCHANT_ID']
ZipMoney::Configuration.merchant_key = ENV['MERCHANT_KEY']
ZipMoney::Configuration.environment  = ENV['ENVIRONMENT']

 

API Operations

We can separate api operation by creating a separate services (app/services/zippay_handler.rb)

Class ZippayHandler
  # methods
end

 

Checkout
Checkout API will initialize order in zipmoney system and send request for checkout process and gives “redirect url” with successful response. The redirect url leads to zippay sign up or login form.

Checkout is initial process and we can initialize checkout object and send parameters required for the checkout process

def set_checkout
  checkout = ZipMoney::Checkout.new
  # we need send customer details order, order details, billing address, shipping address. 
  checkout .params.required_attribute = ‘value’
  .
  .
  .
  response = checkout.do() 
  if response.isSuccess
    # do something
  else
    # do something 
    # response.getError 
  end  
end

 

Capture
Capture API will finalize the order and settle the fund.  Authorize and capture method is being used for settling funds. This request is asynchronous request, that will return the response directly to the API request.

def set_caputer
  capture.params.required_attributes = ‘values’
  .
  .
  response = capture.do()  

  if response.isSuccess
    # do something
  else
    # do something 
    # response.getError 
  end  
end

 

Cancel
Cancel API will cancel the order and will release the captured amount.

def set_cancel
  # we need to send transaction id, order information 
  cancel = ZipMoney::Cancel.new
  cancel.params.required_attributes = ‘value’
  .
  .
  response = cancel.do()  

  if response.isSuccess
    # do something
  else
    # do something 
    # response.getError 
  end 
end

 

Query order
We can get order details, transaction amount from merchant account as response of the query

def set_order
  query = ZipMoney::Query.new
  query.params.orders[0] = Struct::QueryOrder.new
  .
  .   
  response = query.do()  

  if response.isSuccess
    # do something
  else
    # do something 
    # response.getError 
  end	
end

 

Refund
Charged and capture amount can not be cancelled but can be refunded. This can be also done through merchant account.

def set_refund
  refund = ZipMoney::Refund.new
  refund.params.required_attributs = ‘values’
  .
  .
  response = refund.do()  

  if response.isSuccess
    # do something
  else
    # do something 
    # response.getError 
  end
end

 

For more detail documentation and api information, you can follow following references:

References
https://api.zipmoney.com.au/
https://zippay.com.au/
https://github.com/zipMoney/zipmoney-ruby-sdk

Share This:

Comments


Add a new comment

Latest Posts


Encrypted secrets in Ruby on Rails By Rasna Shakya on Apr, 20, 2018

Rails Payment Integration with zipPay (Buy Now and Pay Later) By Nelson Suwal on Mar, 23, 2018

Getting started with React Native: Core Architecture of React Native By Aman Maharjan on Dec, 15, 2017

First Step to Software Development: Design Thinking Process By Rasna Shakya on Nov, 03, 2017

Bourbon By Rasna Shakya on Oct, 20, 2017