wirecard-elastic 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +130 -1
- data/lib/wirecard/elastic.rb +15 -2
- data/lib/wirecard/elastic/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ad65f0c4a71801ab0563eaa4abe98cb944573ba
|
4
|
+
data.tar.gz: e736a0c468e1e73210fb0d816c7affd3483bd4cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4adc95a95cab5d15e9ce189652e81d296c51f8516e39dc713635b58187072a6100a1bd208cedcfbec696352b176dd79998cc7d4be7aa5962aba7ef9ae4641dea
|
7
|
+
data.tar.gz: 87a5d22947b3eb7bdeb77c0b9c21c60350aa883fc77f5e7872b3aa1322648dbd5441515c64aaddf491058537a5805f611750e775b11ce3cb87a440c8bc244300
|
data/README.md
CHANGED
@@ -1 +1,130 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
# Wirecard Elastic
|
3
|
+
|
4
|
+

|
5
|
+
|
6
|
+
This library integrates the Elastic API for Wirecard Payment Service in Ruby. This library could actually be extended to manage any Elastic API service provider.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'wirecard-elastic'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle install
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install wirecard-elastic
|
23
|
+
|
24
|
+
## Configuration
|
25
|
+
|
26
|
+
Add the following lines into your `config/initializer/` folder
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
# use this to configure anything
|
30
|
+
# on the wirecard elastic api gem
|
31
|
+
Wirecard::Elastic.config do |config|
|
32
|
+
|
33
|
+
# the engine URL must be a full URL to the elastic engine you use
|
34
|
+
# you can add different credentials for each type of payment (Credit Card, China Union Pay, ...)
|
35
|
+
config.creditcard = {
|
36
|
+
:username => "USERNAME FOR CREDIT CARD",
|
37
|
+
:password => "PASSWORD FOR CREDIT CARD",
|
38
|
+
:engine_url => "http://api.engine-url.com/"
|
39
|
+
}
|
40
|
+
config.upop = {
|
41
|
+
:username => "USERNAME FOR UNION PAY",
|
42
|
+
:password => "PASSWORD FOR UNION PAY",
|
43
|
+
:engine_url => "http://api.engine-url.com/"
|
44
|
+
}
|
45
|
+
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
## Usage
|
50
|
+
|
51
|
+
Recover a transaction or/and refund from the API.
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
# Any of the following instructions work for both transaction and refund request
|
55
|
+
# the payment method can be either :upop or :creditcard for now
|
56
|
+
response = Wirecard::Elastic.transaction("MERCHANT ID", "TRANSACTION ID", "PAYMENT METHOD").response
|
57
|
+
response = Wirecard::Elastic.refund("MERCHANT ID", "PARENT TRANSACTION ID", "PAYMENT METHOD").response
|
58
|
+
```
|
59
|
+
|
60
|
+
You can get any result from the API. The results will be processed and converted to symbol / underscore depending on the response current mapping
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
# different response datas from the API
|
64
|
+
response.transaction_state
|
65
|
+
response.transaction_type
|
66
|
+
response.request_status
|
67
|
+
response.requested_amount
|
68
|
+
# ... and so forth
|
69
|
+
```
|
70
|
+
|
71
|
+
You can catch the done request itself without processed response like so
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
# get request
|
75
|
+
request = Wirecard::Elastic.transaction("MERCHANT ID", "TRANSACTION ID", "PAYMENT METHOD").request
|
76
|
+
# check the exact query final URL
|
77
|
+
request.query
|
78
|
+
# see the raw result of the request
|
79
|
+
request.feedback
|
80
|
+
```
|
81
|
+
|
82
|
+
You can also check if the transaction / refund was successful via this small shortcut. It will raise an error if not, you can then use whatever functionality you could normally use
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
safe_transaction = Wirecard::Elastic.transaction("MERCHANT ID", "TRANSACTION ID", "PAYMENT METHOD").safe
|
86
|
+
safe_transaction.request
|
87
|
+
safe_transaction.response
|
88
|
+
```
|
89
|
+
|
90
|
+
Concrete use in your code could look like this
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
def check
|
94
|
+
puts "Transaction current state : #{response.transaction_state}"
|
95
|
+
end
|
96
|
+
|
97
|
+
# errors are basically raised and
|
98
|
+
# must be catch by yourself
|
99
|
+
def response
|
100
|
+
@response ||= Wirecard::Elastic.refund(order_payment.merchant_id, order_payment.transaction_id, order_payment.payment_method).response
|
101
|
+
rescue Wirecard::Elastic::Error => exception
|
102
|
+
raise Error, "A problem occurred : #{exception}"
|
103
|
+
end
|
104
|
+
```
|
105
|
+
|
106
|
+
## Development
|
107
|
+
|
108
|
+
I created this library for my company. It lacks several functionalities but it's way enough for us ; everything is easily extendable so don't hesitate to add your own needed methods to it.
|
109
|
+
|
110
|
+
You will notice there a lot of sub-functionalities which isn't quoted in the instructions. For instance, there's a XML body builder with template system which can be easily extended to other file formats if needed.
|
111
|
+
|
112
|
+
It was originally created for [Wirecard](https://www.wirecard.com/) but I see no restriction to use it for any other service with the elastic structure.
|
113
|
+
|
114
|
+
## Contributing
|
115
|
+
|
116
|
+
1. Fork it ( https://github.com/[my-github-username]/wirecard-elastic/fork )
|
117
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
118
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
119
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
120
|
+
5. Create a new Pull Request
|
121
|
+
|
122
|
+
## Author
|
123
|
+
|
124
|
+
[Laurent Schaffner](http://www.laurentschaffner.com)
|
125
|
+
|
126
|
+
## License
|
127
|
+
|
128
|
+
MIT License.
|
129
|
+
|
130
|
+
## Changelog
|
data/lib/wirecard/elastic.rb
CHANGED
@@ -1,5 +1,18 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# we load the classes
|
2
|
+
require 'wirecard/elastic/request/body/builder/xml'
|
3
|
+
require 'wirecard/elastic/request/body/params/refund'
|
4
|
+
require 'wirecard/elastic/request/body/builder'
|
5
|
+
require 'wirecard/elastic/request/base'
|
6
|
+
require 'wirecard/elastic/request/refund'
|
7
|
+
require 'wirecard/elastic/request/transaction'
|
8
|
+
require 'wirecard/elastic/response/base'
|
9
|
+
require 'wirecard/elastic/response/refund'
|
10
|
+
require 'wirecard/elastic/response/transaction'
|
11
|
+
require 'wirecard/elastic/configuration'
|
12
|
+
require 'wirecard/elastic/error'
|
13
|
+
require 'wirecard/elastic/request'
|
14
|
+
require 'wirecard/elastic/response'
|
15
|
+
require 'wirecard/elastic/version'
|
3
16
|
|
4
17
|
# this is the entry point of the gem, here goes the configuration system
|
5
18
|
# also the different methods that should be publicly called
|