bf-mokapay 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +79 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/moka/configuration.rb +32 -0
- data/lib/moka/endpoint.rb +44 -0
- data/lib/moka/model/card.rb +73 -0
- data/lib/moka/model/customer.rb +103 -0
- data/lib/moka/model/dealer.rb +9 -0
- data/lib/moka/model/payment.rb +116 -0
- data/lib/moka/model.rb +4 -0
- data/lib/moka/version.rb +3 -0
- data/lib/moka.rb +12 -0
- data/mokapay.gemspec +29 -0
- metadata +133 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3862cd94c9a865fe529ece06374d17d206ba2b28785baae43e4a6651297fcdc9
|
4
|
+
data.tar.gz: 833d0eb368503d217d550be4383d7554da62a42f2987066816be22bea837889a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cf11c8bd58ef809f962c18e1934db60dfc6dc5d1f17db327236a61adccb62d6b5625c14c06847826be411d0cf414d9cda658154ddcd6a36f67aaf3ee1d80acc1
|
7
|
+
data.tar.gz: d20eb07395fc99a59236a90b95da8e3b9621889d3988743ae1ad462a2a9d1fcd6544bbff5ff7a3e2e3de5a000e43d7a3d276f558dea41d2d8374b34d5475cc7b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at huseyin.tunc@bulutfon.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Hüseyin TUNÇ
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# Mokapay
|
2
|
+
|
3
|
+
Unofficial API wrapper for [MOKA](https://www.moka.com/) Payment System.
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'mokapay', require: 'moka'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install mokapay
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
```ruby
|
24
|
+
require 'moka'
|
25
|
+
|
26
|
+
Moka.configure do |config|
|
27
|
+
config.dealer_code = '1730'
|
28
|
+
config.username = 'TestMoka1'
|
29
|
+
config.password = 'YHSUSHDYHUDHD'
|
30
|
+
config.env = 'test' # Default production
|
31
|
+
end
|
32
|
+
```
|
33
|
+
Note: When making any request, you can use all parameters on the official [documentation](https://developer.moka.com/home.php?page=3dsiz-odeme) with snake case.
|
34
|
+
For example you can use card_holder_full_name for CardHolderFullName on official documentation.
|
35
|
+
|
36
|
+
|
37
|
+
#### Create Direct Payment
|
38
|
+
```ruby
|
39
|
+
payment = Moka::Payment.new({
|
40
|
+
card_holder_full_name: 'Huseyin TUNC',
|
41
|
+
card_number: '5269552233334444',
|
42
|
+
exp_month: '12',
|
43
|
+
exp_year: '2022',
|
44
|
+
cvc_number: '000',
|
45
|
+
amount: 10.10,
|
46
|
+
client_ip: '1.2.3.4',
|
47
|
+
other_trx_code: 1
|
48
|
+
})
|
49
|
+
|
50
|
+
payment.pay # Make request (also returns the response)
|
51
|
+
payment.success? # To check if it success
|
52
|
+
payment.response # Returns the response
|
53
|
+
```
|
54
|
+
|
55
|
+
#### Create 3D Payment
|
56
|
+
```ruby
|
57
|
+
payment = Moka::Payment.new({
|
58
|
+
card_holder_full_name: 'Huseyin TUNC',
|
59
|
+
card_number: '5269552233334444',
|
60
|
+
exp_month: '12',
|
61
|
+
exp_year: '2022',
|
62
|
+
cvc_number: '000',
|
63
|
+
amount: 10.10,
|
64
|
+
client_ip: '1.2.3.4',
|
65
|
+
other_trx_code: 1,
|
66
|
+
redirect_url: 'http://localhost:3000/payments/success'
|
67
|
+
})
|
68
|
+
|
69
|
+
payment.pay_three_d
|
70
|
+
```
|
71
|
+
|
72
|
+
|
73
|
+
## Contributing
|
74
|
+
|
75
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/hsyntnc/mokapay. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
76
|
+
|
77
|
+
## License
|
78
|
+
|
79
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "mokapay"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
module Moka
|
2
|
+
class << self
|
3
|
+
attr_accessor :configuration, :endpoints
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.configure
|
7
|
+
self.configuration ||= Configuration.new
|
8
|
+
yield(configuration)
|
9
|
+
self.endpoints ||= Endpoint.new
|
10
|
+
end
|
11
|
+
|
12
|
+
class Configuration
|
13
|
+
attr_accessor :dealer_code, :username, :password, :env
|
14
|
+
|
15
|
+
def check_key
|
16
|
+
Digest::SHA256.hexdigest "#{dealer_code}MK#{username}PD#{password}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def test?
|
20
|
+
env == 'test'
|
21
|
+
end
|
22
|
+
|
23
|
+
def config_hash
|
24
|
+
{
|
25
|
+
"DealerCode": dealer_code,
|
26
|
+
"UserName": username,
|
27
|
+
"Password": password,
|
28
|
+
"CheckKey": check_key
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Moka
|
2
|
+
class Endpoint
|
3
|
+
BASE_URL = 'https://service.moka.com'
|
4
|
+
TEST_BASE_URL = 'https://service.testmoka.com'
|
5
|
+
|
6
|
+
ENDPOINTS = {
|
7
|
+
# Payment Options
|
8
|
+
direct_payment: '/PaymentDealer/DoDirectPayment',
|
9
|
+
direct_payment_three_d: '/PaymentDealer/DoDirectPaymentThreeD',
|
10
|
+
capture: '/PaymentDealer/DoCapture',
|
11
|
+
approve_pool_payment: '/PaymentDealer/DoApprovePoolPayment',
|
12
|
+
void: '/PaymentDealer/DoVoid',
|
13
|
+
refund: '/PaymentDealer/DoCreateRefundRequest',
|
14
|
+
get_payment_list: '/PaymentDealer/GetPaymentList',
|
15
|
+
get_transaction_list: '/PaymentDealer/GetPaymentTrxList',
|
16
|
+
get_payment_detail_list: '/PaymentDealer/GetDealerPaymentTrxDetailList',
|
17
|
+
|
18
|
+
# Customer Options
|
19
|
+
add_customer: '/DealerCustomer/AddCustomer',
|
20
|
+
update_customer: '/DealerCustomer/UpdateCustomer',
|
21
|
+
get_customer: '/DealerCustomer/GetCustomer',
|
22
|
+
remove_customer: '/DealerCustomer/RemoveCustomer',
|
23
|
+
add_customer_with_card: '/DealerCustomer/AddCustomerWithCard',
|
24
|
+
|
25
|
+
# Card Options
|
26
|
+
add_card: '/DealerCustomer/AddCard',
|
27
|
+
update_card: '/DealerCustomer/UpdateCard',
|
28
|
+
get_card: '/DealerCustomer/GetCard',
|
29
|
+
get_card_list: '/DealerCustomer/GetCardList',
|
30
|
+
remove_card: '/DealerCustomer/RemoveCard'
|
31
|
+
}
|
32
|
+
|
33
|
+
ENDPOINTS.each_key do |attribute|
|
34
|
+
attr_accessor attribute
|
35
|
+
end
|
36
|
+
|
37
|
+
def initialize
|
38
|
+
base_url = Moka.configuration.test? ? TEST_BASE_URL : BASE_URL
|
39
|
+
ENDPOINTS.each do |attribute, value|
|
40
|
+
send("#{attribute}=".to_sym, "#{base_url}#{value}")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Moka
|
2
|
+
class Card
|
3
|
+
attr_accessor :dealer_customer_id, :customer_code, :card_holder_full_name,
|
4
|
+
:card_number, :exp_month, :exp_year, :card_name, :card_token,
|
5
|
+
:bank_name, :card_number_first_six, :card_number_last_four,
|
6
|
+
:customer, :response
|
7
|
+
|
8
|
+
def initialize(opts = {})
|
9
|
+
opts.each do |o|
|
10
|
+
send("#{o.first.to_s}=".to_sym, o.last)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def create
|
15
|
+
response = RestClient.post Moka.endpoints.add_card, create_hash
|
16
|
+
self.response = JSON.parse(response)
|
17
|
+
end
|
18
|
+
|
19
|
+
def update
|
20
|
+
response = RestClient.post Moka.endpoints.update_card, update_hash
|
21
|
+
self.response = JSON.parse(response)
|
22
|
+
end
|
23
|
+
|
24
|
+
def get
|
25
|
+
response = RestClient.post Moka.endpoints.get_card, get_and_delete_hash
|
26
|
+
self.response = JSON.parse(response)
|
27
|
+
end
|
28
|
+
|
29
|
+
def delete
|
30
|
+
response = RestClient.post Moka.endpoints.get_card, get_and_delete_hash
|
31
|
+
self.response = JSON.parse(response)
|
32
|
+
end
|
33
|
+
|
34
|
+
def success?
|
35
|
+
response && response['ResultCode'] == 'Success'
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def create_hash
|
40
|
+
{
|
41
|
+
"DealerCustomerAuthentication": Moka.configuration.config_hash,
|
42
|
+
"DealerCustomerRequest": {
|
43
|
+
"DealerCustomerId": dealer_customer_id,
|
44
|
+
"CustomerCode": customer_code,
|
45
|
+
"CardHolderFullName": card_holder_full_name,
|
46
|
+
"CardNumber": card_number,
|
47
|
+
"ExpMonth": exp_month,
|
48
|
+
"ExpYear": exp_year,
|
49
|
+
"CardName": card_name
|
50
|
+
}
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def update_hash
|
55
|
+
{
|
56
|
+
"DealerCustomerAuthentication": Moka.configuration.config_hash,
|
57
|
+
"DealerCustomerRequest": {
|
58
|
+
"CardToken": card_token,
|
59
|
+
"CardName": card_name
|
60
|
+
}
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
def get_and_delete_hash
|
65
|
+
{
|
66
|
+
"DealerCustomerAuthentication": Moka.configuration.config_hash,
|
67
|
+
"DealerCustomerRequest": {
|
68
|
+
"CardToken": card_token
|
69
|
+
}
|
70
|
+
}
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module Moka
|
2
|
+
class Customer
|
3
|
+
attr_accessor :dealer_customer_id, :customer_code, :password, :first_name, :last_name,
|
4
|
+
:gender, :birth_date, :gsm_number, :email, :address,
|
5
|
+
:credit_card, :card_list, :response
|
6
|
+
|
7
|
+
def initialize(opts = {})
|
8
|
+
opts.each do |o|
|
9
|
+
send("#{o.first.to_s}=".to_sym, o.last)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def full_name
|
14
|
+
"#{first_name} #{last_name}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def create
|
18
|
+
response = RestClient.post Moka.endpoints.add_customer, create_hash
|
19
|
+
self.response = JSON.parse(response)
|
20
|
+
end
|
21
|
+
|
22
|
+
def get
|
23
|
+
response = RestClient.post Moka.endpoints.add_customer, get_and_delete_hash
|
24
|
+
self.response = JSON.parse(response)
|
25
|
+
end
|
26
|
+
|
27
|
+
def update
|
28
|
+
response = RestClient.post Moka.endpoints.add_customer, update_hash
|
29
|
+
self.response = JSON.parse(response)
|
30
|
+
end
|
31
|
+
|
32
|
+
def delete
|
33
|
+
response = RestClient.post Moka.endpoints.add_customer, get_and_delete_hash
|
34
|
+
self.response = JSON.parse(response)
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_with_card
|
38
|
+
response = RestClient.post Moka.endpoints.add_customer_with_card, get_and_delete_hash
|
39
|
+
self.response = JSON.parse(response)
|
40
|
+
end
|
41
|
+
|
42
|
+
def success?
|
43
|
+
response && response['ResultCode'] == 'Success'
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
def create_hash(with_card = false)
|
48
|
+
hsh = {
|
49
|
+
"DealerCustomerAuthentication": Moka.configuration.config_hash,
|
50
|
+
"DealerCustomerRequest": {
|
51
|
+
"CustomerCode": customer_code,
|
52
|
+
"Password": password,
|
53
|
+
"FirstName": first_name,
|
54
|
+
"LastName": last_name,
|
55
|
+
"Gender": gender,
|
56
|
+
"BirthDate": birth_date,
|
57
|
+
"GsmNumber": gsm_number,
|
58
|
+
"Email": email,
|
59
|
+
"Address": address
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
if with_card && credit_card && credit_card.is_a?(Moka::Card)
|
64
|
+
hsh[:DealerCustomerRequest][:CardHolderFullName] = credit_card.card_holder_full_name
|
65
|
+
hsh[:DealerCustomerRequest][:CardNumber] = credit_card.card_number
|
66
|
+
hsh[:DealerCustomerRequest][:ExpMonth] = credit_card.exp_month
|
67
|
+
hsh[:DealerCustomerRequest][:ExpYear] = credit_card.exp_year
|
68
|
+
hsh[:DealerCustomerRequest][:CardName] = credit_card.card_name
|
69
|
+
end
|
70
|
+
|
71
|
+
hsh
|
72
|
+
end
|
73
|
+
|
74
|
+
def update_hash
|
75
|
+
{
|
76
|
+
"DealerCustomerAuthentication": Moka.configuration.config_hash,
|
77
|
+
"DealerCustomerRequest": {
|
78
|
+
"DealerCustomerId": dealer_customer_id,
|
79
|
+
"CustomerCode": customer_code,
|
80
|
+
"Password": password,
|
81
|
+
"FirstName": first_name,
|
82
|
+
"LastName": last_name,
|
83
|
+
"Gender": gender,
|
84
|
+
"BirthDate": birth_date,
|
85
|
+
"GsmNumber": gsm_number,
|
86
|
+
"Email": email,
|
87
|
+
"Address": address
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
def get_and_delete_hash
|
94
|
+
{
|
95
|
+
"DealerCustomerAuthentication": Moka.configuration.config_hash,
|
96
|
+
"DealerCustomerRequest": {
|
97
|
+
"DealerCustomerId": dealer_customer_id,
|
98
|
+
"CustomerCode": customer_code
|
99
|
+
}
|
100
|
+
}
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module Moka
|
2
|
+
class Payment
|
3
|
+
attr_accessor :card_holder_full_name, :card_number, :exp_month, :exp_year,
|
4
|
+
:cvc_number, :amount, :currency, :installment_number, :client_ip,
|
5
|
+
:other_trx_code, :is_pre_auth, :is_pool_payment, :integrator_id,
|
6
|
+
:software, :redirect_url, :redirect_type, :description,
|
7
|
+
:buyer, :credit_card, :card_token,
|
8
|
+
|
9
|
+
:virtual_pos_order_id, :void_refund_reason, :refund_request_id,
|
10
|
+
|
11
|
+
:response, :result_code
|
12
|
+
|
13
|
+
def initialize(opts = {})
|
14
|
+
opts.each do |o|
|
15
|
+
send("#{o.first.to_s}=".to_sym, o.last)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def pay
|
20
|
+
response = RestClient.post Moka.endpoints.direct_payment, payment_hash
|
21
|
+
self.response = JSON.parse(response.body)
|
22
|
+
self.result_code = self.response['ResultCode']
|
23
|
+
self.response
|
24
|
+
end
|
25
|
+
|
26
|
+
def pay_three_d
|
27
|
+
response = RestClient.post Moka.endpoints.direct_payment_three_d, three_d_payment_hash
|
28
|
+
self.response = JSON.parse(response.body)
|
29
|
+
self.result_code = self.response['ResultCode']
|
30
|
+
self.response
|
31
|
+
end
|
32
|
+
|
33
|
+
def void
|
34
|
+
response = RestClient.post Moka.endpoints.void, void_hash
|
35
|
+
self.response = JSON.parse(response.body)
|
36
|
+
self.result_code = self.response['ResultCode']
|
37
|
+
self.response
|
38
|
+
end
|
39
|
+
|
40
|
+
def refund
|
41
|
+
response = RestClient.post Moka.endpoints.refund, refund_hash
|
42
|
+
self.response = JSON.parse(response.body)
|
43
|
+
self.result_code = self.response['ResultCode']
|
44
|
+
self.response
|
45
|
+
end
|
46
|
+
|
47
|
+
def success?
|
48
|
+
response && response['ResultCode'] == 'Success' && response['Data']['IsSuccessful'] == true
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
def payment_hash
|
53
|
+
hsh = {
|
54
|
+
"PaymentDealerAuthentication": Moka.configuration.config_hash,
|
55
|
+
"PaymentDealerRequest": {
|
56
|
+
"CardHolderFullName": card_holder_full_name,
|
57
|
+
"CardNumber": card_number,
|
58
|
+
"ExpMonth": exp_month,
|
59
|
+
"ExpYear": exp_year,
|
60
|
+
"CvcNumber": cvc_number,
|
61
|
+
"CardToken": card_token,
|
62
|
+
"Amount": amount,
|
63
|
+
"Currency": currency,
|
64
|
+
"InstallmentNumber": installment_number || 0,
|
65
|
+
"ClientIP": client_ip,
|
66
|
+
"OtherTrxCode": other_trx_code,
|
67
|
+
"IsPreAuth": is_pre_auth || 0,
|
68
|
+
"IsPoolPayment": is_pool_payment || 0,
|
69
|
+
"IntegratorId": integrator_id,
|
70
|
+
"Software": software,
|
71
|
+
"Description": description
|
72
|
+
}
|
73
|
+
}
|
74
|
+
if buyer && buyer.is_a?(Moka::Customer)
|
75
|
+
hsh[:PaymentDealerRequest][:BuyerInformation] = {
|
76
|
+
"BuyerFullName": buyer.full_name,
|
77
|
+
"BuyerEmail": buyer.email,
|
78
|
+
"BuyerGsmNumber": buyer.email,
|
79
|
+
"BuyerAddress": buyer.address
|
80
|
+
}
|
81
|
+
end
|
82
|
+
hsh
|
83
|
+
end
|
84
|
+
|
85
|
+
def three_d_payment_hash
|
86
|
+
hsh = payment_hash
|
87
|
+
hsh[:PaymentDealerRequest][:RedirectUrl] = redirect_url
|
88
|
+
hsh[:PaymentDealerRequest][:RedirectType] = redirect_type
|
89
|
+
hsh
|
90
|
+
end
|
91
|
+
|
92
|
+
def void_hash
|
93
|
+
{
|
94
|
+
"PaymentDealerAuthentication": Moka.configuration.config_hash,
|
95
|
+
"PaymentDealerRequest": {
|
96
|
+
"VirtualPosOrderId": virtual_pos_order_id,
|
97
|
+
"ClientIP": client_ip,
|
98
|
+
"VoidRefundReason": void_refund_reason || 2
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
def refund_hash
|
105
|
+
{
|
106
|
+
"PaymentDealerAuthentication": Moka.configuration.config_hash,
|
107
|
+
"PaymentDealerRequest": {
|
108
|
+
"VirtualPosOrderId": virtual_pos_order_id,
|
109
|
+
"OtherTrxCode": "",
|
110
|
+
"Amount": amount
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
data/lib/moka/model.rb
ADDED
data/lib/moka/version.rb
ADDED
data/lib/moka.rb
ADDED
data/mokapay.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "moka/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bf-mokapay"
|
8
|
+
spec.version = Moka::VERSION
|
9
|
+
spec.authors = ["Bulutfon Geliştirme Ekibi"]
|
10
|
+
spec.email = ["dev@bulutfon.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Ruby gem for Moka payment system.}
|
13
|
+
spec.homepage = "https://github.com/onurozgurozkan/bf-mokapay"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
spec.add_development_dependency "rest-client", "~> 2.0"
|
27
|
+
|
28
|
+
spec.add_dependency 'rest-client', '~> 2.0'
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bf-mokapay
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bulutfon Geliştirme Ekibi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-08-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rest-client
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rest-client
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- dev@bulutfon.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- CODE_OF_CONDUCT.md
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bin/console
|
99
|
+
- bin/setup
|
100
|
+
- lib/moka.rb
|
101
|
+
- lib/moka/configuration.rb
|
102
|
+
- lib/moka/endpoint.rb
|
103
|
+
- lib/moka/model.rb
|
104
|
+
- lib/moka/model/card.rb
|
105
|
+
- lib/moka/model/customer.rb
|
106
|
+
- lib/moka/model/dealer.rb
|
107
|
+
- lib/moka/model/payment.rb
|
108
|
+
- lib/moka/version.rb
|
109
|
+
- mokapay.gemspec
|
110
|
+
homepage: https://github.com/onurozgurozkan/bf-mokapay
|
111
|
+
licenses:
|
112
|
+
- MIT
|
113
|
+
metadata: {}
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubygems_version: 3.2.33
|
130
|
+
signing_key:
|
131
|
+
specification_version: 4
|
132
|
+
summary: Ruby gem for Moka payment system.
|
133
|
+
test_files: []
|