paylane 0.0.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +88 -5
- data/lib/paylane/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,16 +1,99 @@
|
|
1
1
|
# Paylane
|
2
2
|
|
3
|
-
Ruby client for [PayLane](http://paylane.com)
|
3
|
+
Ruby client for [PayLane](http://www.paylane.com) payments.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
|
7
|
+
$ gem install paylane
|
8
8
|
|
9
|
-
|
9
|
+
or
|
10
10
|
|
11
|
-
|
11
|
+
gem 'paylane'
|
12
12
|
|
13
|
-
|
13
|
+
## Usage - API
|
14
|
+
|
15
|
+
Start from create a client for API.
|
16
|
+
|
17
|
+
gateway = PayLane::Gateway.new('login, 'password')
|
18
|
+
client = PayLane::API.new(gateway.connect)
|
19
|
+
|
20
|
+
Now all methods from [original API](http://devzone.paylane.com/wp-content/uploads/2012/05/paylane_direct_system.pdf) are available in the client object.
|
21
|
+
|
22
|
+
params = {
|
23
|
+
"payment_method" => {
|
24
|
+
"card_data" => {
|
25
|
+
"card_number" => 4111111111111111,
|
26
|
+
"card_code" => 123,
|
27
|
+
"expiration_month" => 12,
|
28
|
+
"expiration_year" => 2020,
|
29
|
+
"name_on_card" => "John Smith"
|
30
|
+
}
|
31
|
+
},
|
32
|
+
"customer" => {
|
33
|
+
"name" => "John Smith",
|
34
|
+
"email" => "johnsmith@example.com",
|
35
|
+
"ip" => "127.0.0.1",
|
36
|
+
"address" => {
|
37
|
+
"street_house" => "1st Avenue",
|
38
|
+
"city" => "Lodz",
|
39
|
+
"state" => "Lodz",
|
40
|
+
"zip" => "00-000",
|
41
|
+
"country_code" => "PL"
|
42
|
+
}
|
43
|
+
},
|
44
|
+
"amount" => 9.99,
|
45
|
+
"currency_code" => "EUR",
|
46
|
+
"product" => {
|
47
|
+
"description" => "paylane_api_test"
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
client.multi_sale(params) #=> {ok: {id_sale: "2772323"}, data: {fraud_score: "8.76"}}
|
52
|
+
|
53
|
+
If something went wrong `PayLane::ConnectionError` error will be raised.
|
54
|
+
|
55
|
+
## Usage - custom methods
|
56
|
+
|
57
|
+
Gem provides custom methods to simplify an implementation of payments in your app.
|
58
|
+
|
59
|
+
### Configuration
|
60
|
+
|
61
|
+
Firstly you need to set up credential settings. For Rails put it in initializer `config/initializers/paylane.rb`.
|
62
|
+
|
63
|
+
PayLane.login = 'login'
|
64
|
+
PayLane.password = 'password'
|
65
|
+
|
66
|
+
Besides `login` and `password` you can also set `currency` ('EUR' by default) and `logger`.
|
67
|
+
|
68
|
+
### Usage
|
69
|
+
|
70
|
+
Inherit your class from `PayLane::Payment` and overload `card_data` (or `account_data`) and `customer` methods. This is how it should looks for `params` from the previous example.
|
71
|
+
|
72
|
+
class Payment < PayLane::Payment
|
73
|
+
def initialize(params, options = {})
|
74
|
+
super(options)
|
75
|
+
@params = params
|
76
|
+
end
|
77
|
+
|
78
|
+
def card_data
|
79
|
+
params[:payment_method][:card_data]
|
80
|
+
end
|
81
|
+
|
82
|
+
def customer
|
83
|
+
params[:customer]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
payment = Payment.new(params, product: 'Additional pylon')
|
88
|
+
payment.charge_card(9.99) #=> {ok: {id_sale: "2772323"}, data: {fraud_score: "8.76"}}
|
89
|
+
|
90
|
+
It works similar for recurring payments
|
91
|
+
|
92
|
+
class RecurringPayment < PayLane::RecurringPayment
|
93
|
+
end
|
94
|
+
|
95
|
+
recurring_payment = RecurringPayment.new(2772323, product: 'Subscription')
|
96
|
+
recurring_payment.charge_card(30.00) #=> {ok: {id_sale: "3131151"}, data: {fraud_score: "7.00"}}
|
14
97
|
|
15
98
|
## Contributing
|
16
99
|
|
data/lib/paylane/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paylane
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: savon
|