Skip to content
This repository was archived by the owner on Mar 10, 2025. It is now read-only.
/ platon Public archive

Ruby on Rails engine for processing Platon.ua payment service data. (Note: "Unfortunately, the package is no longer being maintained.")

Notifications You must be signed in to change notification settings

mykhailokrainik/platon

Repository files navigation

Unfortunately, the package is no longer being maintained.


Platon Ruby Gem

Gateway for Platon processing center (https://platon.ua/)

Installation

gem 'platon'

And then execute:

$ bundle

Or install it yourself as:

$ gem install platon

Usage as engine

/config/routes.rb
Rails.application.routes.draw do
  mount Platon::Engine => "/platon"
end
/config/initializer/platon.rb

Methods which called when something happen.

Platon::Callbacks.setup.success =->(_result) { puts 'success' }

Platon::Callbacks.setup.failed =->(_result) { puts 'failed' }

Platon::Callbacks.setup.error =->(_result) { puts 'error' }

Usage as service

create form

# product description (important keys)
data = {amount: '99.99', currency: 'USD', description: 'Show desciption less that 255 byte'} 

# product order id (important key)
order = 1892

# addition field in form :name, :value
ext = [{name: 'discont', value: 10}]

@service = Platon::FormService.call(data, order: order, extra_fields: ext)

# views/pay/index.html.erb
<form action="<%= @service.form_prop[:url] %>" method="<%= @service.form_prop[:method] %>">
  <% @service.fields.map do |field| %>
    <input type="<%= field[:type] %>" name="<%= field[:name] %>" value="<%= field[:value] %>">
  <% end %>
  <input type="submit" value="Pay">
</form>

parse response

# /app/controllers/callback_controller.rb

def create
    service = Platon::CallbackService.call(params)
    
    if service.success?
        head :ok
    else
        head :bad_request
    end
end    

General options

gem 'dotenv-rails'

# config/application.rb
Bundler.require(*Rails.groups)

Dotenv::Railtie.load
/.env
PLATON_KEY=XXXXXXXXXX
PLATON_PASSWORD=XXXXXXXXXX
PLATON_URL=https://secure.platononline.com/payment/auth
PLATON_CALLBACK_URL=http://localhost/platon
PLATON_PAYMENT_METHOD=CC

License

The gem is available as open source under the terms of the MIT License.

About

Ruby on Rails engine for processing Platon.ua payment service data. (Note: "Unfortunately, the package is no longer being maintained.")

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors 2

  •  
  •