kiosan / wayforpay

Ruby wrapper for WayForPay API

Home Page:https://wayforpay.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gem Version

Installation

Add this line to your application's Gemfile:

gem 'wayforpay'

And then execute:

$ bundle install

To manually install wayforpay via Rubygems just run:

$ gem install wayforpay

Documentation

Wayforpay API Docs

Usage

require 'wayforpay'

Create new file config/initializers/wayforpay.rb and put your own credentials here (required):

Wayforpay.configure do |config|
    config.merchant_account = 'test_merch_n1' # Seller identifier. This value is assigned to You from the side of WayForPay
    config.merchant_domain_name = 'example.com'
    config.encrypt_secret_key = 'flk3409refn54t54t*FNJRET'
end

Click here for more information.

Payments

Blocking money on the payment card (Hold)

Wayforpay::Payments.hold(parameters)

Required parameters:

Parameter Description
orderReference Unique number of the order in merchant’s system
orderDate Date of order placing
amount Amount of refund
currency Currency of order: UAH (USD, EUR)
productName[] Array with the names of ordered products
productPrice[] Array with the prices per product unit
productCount[] Array with the quantity of ordered goods by each item
card Card number 16 characters
expMonth Card Expiry Date (mounth) - MM
expYear Card Expiry Date (year) - YY
cardCvv Card Security Code CVV / CVV2
cardHolder Cardholder Name, as indicated on the card
recToken Card token for recarring withdrawals, without client (without reference to card details)

Note: fields (card+expMonth+expYear+cardCvv+cardHolder) or recToken should be required.

An example of request:

{
  "orderReference": "myOrder1",
  "orderDate": 1421412898,
  "amount": 0.13,
  "currency": "UAH",
  "card": "4111111111111111",
  "expMonth": "11",
  "expYear": "2020",
  "cardCvv": "111",
  "cardHolder": "TARAS BULBA",
  "productName": ["Samsung WB1100F","Samsung Galaxy Tab 4 7.0 8GB 3G Black"],
  "productPrice": [21.1,30.99],
  "productCount": [1,2]
}

Refund/Cancellation of payment (Refund)

Wayforpay::Payments.refund(parameters)

Required parameters:

Parameter Description
orderReference Unique number of the order in merchant’s system
amount Amount of refund
currency Currency of order: UAH
comment Merchant Comment, Description reversal reason

An example of request:

{
  "orderReference": "DH783023",
  "amount": 100,
  "currency": "UAH",
  "comment": "Not in stock"
}

Withdrawal of blocked amount (Settle)

Wayforpay::Payments.settle(parameters)

Required parameters:

Parameter Description
orderReference Unique number of the order in merchant’s system
amount The amount of write-offs confirmation
currency Write-off currency

An example of request:

{
  "orderReference": "DH783023",
  "amount": 100 ,
  "currency": "UAH"
}

Creating invoices to the clients for payment for goods/services. (Invoice)

Wayforpay::Payments.create_invoice(parameters)

Required parameters:

Parameter Description
orderReference Unique number of the order in merchant’s system
orderDate Date of order placing
amount Amount of refund
currency Currency of order: UAH (USD, EUR)
productName[] Array with the names of ordered products
productPrice[] Array with the prices per product unit
productCount[] Array with the quantity of ordered goods by each item

An example of request:

{
  "orderReference": "myOrder1",
  "orderDate": 1421412898,
  "amount": 0.13,
  "currency": "UAH",
  "productName": ["Samsung WB1100F","Samsung Galaxy Tab 4 7.0 8GB 3G Black"],
  "productPrice": [21.1,30.99],
  "productCount": [1,2]
}

An example of response:

{
  "reason": "1100",
  "reasonCode": "Ok",
  "invoiceUrl": "https://secure.wayforpay.com/invoice/i99edb6518fb5"
}

Acceptance of invoice payments. (Invoice, scroll down)

Wayforpay::Payments.accept_invoice_payment(parameters)

Required parameters:

Parameter Description
orderReference Unique number of the order in merchant’s system
time Time of acceptance

An example of request:

{
  "orderReference": "myOrder1",
  "time": 1421412898
}

Receiving client data. (Get Client)

Wayforpay::Payments.get_client(parameters)

Required parameters: one of card or recToken !

Parameter Description
card Card number 16 characters
recToken Card token

Note: field card or recToken should be required.

An example of request:

{
  "card": "4111111111111111"
}
{
  "recToken": "55111111-1111-0000-9988-68c457123456"
}

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Copyright

Copyright (c) 2018 Active Bridge, LLC. See LICENSE for details.

About

Ruby wrapper for WayForPay API

https://wayforpay.com

License:MIT License


Languages

Language:Ruby 100.0%