Actions with payments in MobilePay system.
Add this line to your application's Gemfile:
gem 'mobilepay'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mobilepay
require 'mobilepay'
security = Mobilepay::Security.new subscription_key: 'subscription_key', privatekey: 'key.pvk'
merchant_id - Merchant ID, required
require 'mobilepay'
client = Mobilepay::Client.new merchant_id: 'merchant_id', subscription_key: 'subscription_key', privatekey: 'key.pvk', test_mode: true
subscription_key - Subscription Key for MobilePay, required
merchant_id - Merchant ID, required
privatekey - File with secret key for creating signature for requests, required
test_mode - turn on test mode, optional
Request for getting MobilePay's public key to use when signing up new merchants.
security.public_key
{
"PublicKey": "-----BEGIN CERTIFICATE-----certificate body-----END CERTIFICATE-----"
}
Request for getting the status of a given order is #payment_status.
client.payment_status order_id: '111'
order_id - Order ID, required
{
"LatestPaymentStatus": "Captured",
"TransactionId": "61872634691623746",
"OriginalAmount": 123.45
}
Request for getting the transactions for a given order is #payment_transactions.
client.payment_transactions order_id: '111'
order_id - Order ID, required
[
{
"TimeStamp": "2016-04-08T07:45:36.533Z",
"PaymentStatus": "Captured",
"TransactionId": "61872634691623746",
"Amount": 11.5
},
{
"TimeStamp": "2016-04-09T07:45:36.672Z",
"PaymentStatus": "Cancelled",
"TransactionId": "61872634691623799",
"Amount": 18.9
}
]
Request for getting the reservations for a particular date/time interval, and alternatively also for a specific customer is #reservations.
client.reservations datetime_from: 'YYYY-MM-DDTHH_MM', datetime_to: 'YYYY-MM-DDTHH_MM', customer_id: '111'
datetime_from - Date from, required
datetime_to - Date to, required
customer_id - Customer ID, optional
[
{
"TimeStamp": "2016-04-08T07_45_36Z",
"OrderId": "DB TESTING 2015060908",
"TransactionId": "61872634691623746",
"Amount": 100.25,
"CaptureType": "Full"
},
{
"TimeStamp": "2016-04-09T07_45_36Z",
"OrderId": "DB TESTING 2015060908",
"TransactionId": "61872634691623799"
"Amount": 100.25,
"CaptureType": "Partial"
}
]
Request for refunding the transaction amount, either the entire amount or just a part of the amount is #refund_amount.
client.refund_amount order_id: '111', body: '{}'
order_id - Order ID, required
body - text body for request, optional
{
"Amount" : 100.00,
"BulkRef" : "123456789"
}
{
"Amount" : 100.00
}
{
}
{
"TransactionId" : "61872634691623757",
"OriginalTransactionId" : "61872634691623746",
"Remainder" : 20.00
}
Request for capturing the transaction, i.e. carries out the actual payment is #capture_amount.
client.capture_amount order_id: '111', body: '{}'
order_id - Order ID, required
body - text body for request, optional
{
"Amount" : 100.00,
"BulkRef" : "123456789"
}
{
"Amount" : 100.00
}
{
}
{
"TransactionId" : "61872634691623746"
}
Request for canceling previously made reservations is #cancel_reservation.
client.cancel_reservation order_id: '111'
order_id - Order ID, required
{
"TransactionId" : "61872634691623746"
}
Bug reports and pull requests are welcome on GitHub at https://github.com/WebGents/mobilepay.
The gem is available as open source under the terms of the MIT License.