Git Product home page Git Product logo

webmoney_acceptor's Introduction

Webmoney Acceptor

Small controller & view extension to ease WebMoney payment processing.

Usage

  1. Configure your wallet in the config/webmoney.yml file:

    development: wallet: "R123456789012" secret: "mysupersecret123" production: wallet: "R098765432109" secret: "myproductionsecret"

  2. Add new action to your payment controller:

    class PaymentsController < ApplicationController

    Disable forgery protection for webmoney accepting action

    skip_before_filter :verify_authenticity_token, :only => :webmoney_payment

    ...

    def webmoney_payment @payment = current_user.payments.build( :currency => webmoney.currency, :amount => webmoney.params[:payment_amount] )

     if webmoney.prerequest? # Pre-request to check that your site is available
       if @payment.valid?
         render :text => "YES"
       else
         render :text => @payment.errors.full_messages.join("; ")
       end
     elsif webmoney.valid_payment? # Payment callback
       if @payment.save
         render :text => "Success"
       else
         Rails.logger.error("Webmoney payment error!")
    
         render :text => "failure"
       end
     else # Payment invalid
       raise WebmoneyAcceptor::InvalidTransaction
     end
    

    end end

Important: Payment model is not provided by the plugin. You should create it by yourself.

  1. Add acction to your routes:

    ActionController::Routing::Routes.draw do |map| ...

    map.resources :payments, :collection => {:webmoney_payment => :post}

    ... end

  2. Add WebMoney payment form to your view:

    <% webmoney_payment_form(@amount, :payment_desc => "This is your payment description") do %> Confirmation text goes here

    <%= submit_tag("Pay") %> <% end %>

  3. Profit! :)

Avanced Usage

You can use multiple wallets to accept payments. The only thing you should do for this is to provide wallet and secret to form and validation method.

In your view:

<% webmoney_payment_form("Z123456789012", @amount) do %>
  ...
<% end %>

In your controller:

def webmoney_payment
  ...

  if webmoney.prerequest?
    ...
  elsif webmoney.valid_payment?("mycustomsecret123")
    ...
  end
end

Some additional methods that can be useful:

  • webmoney.currency - currently used WebMoney currency (:wmr, :wmz, etc)
  • webmoney.params - a hash of WebMoney-related params (all params that start with "LMI_")

Testing

No tests yet :( You can fork this plugin at GitHub (http://github.com/dekart/webmoney_acceptor) and add your own tests. I'll be happy to accept patches!

Installing the plugin

./script/plugin install git://github.com/dekart/webmoney_acceptor.git

Credits

Written by Alex Dmitriev

webmoney_acceptor's People

Contributors

dekart avatar

Stargazers

Stanislav Ershov avatar Eugeniu Vozoca avatar Max avatar  avatar Volodymyr Melnyk avatar Andrey avatar Руслан Корнев avatar Andrey Dmitrichev avatar Alexander Manzyuk avatar andrey.p avatar Konstantin Tumalevich avatar Dmitry Vasilets avatar Akim avatar Dzmitry Ilyashevich avatar Roman Smirnov avatar Aleksandr Ivanov avatar Leonid Bugaev avatar Aleksandr Orel avatar  avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

andreyd22

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.