moka-payment 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a6b9cad47074ebd552f5d5b3adb0faeb63e43deb
4
+ data.tar.gz: ef084123b83c151d59b1badfeba7e838ff263f34
5
+ SHA512:
6
+ metadata.gz: bc3e250bbc4bb89ce3c98007121284c4aacf09da085eb6e34c6956e07c9e504faa73aca4e5a8f9d270234d72e64ad01c9384bce4e26acfbaf5184ada8ed6e27b
7
+ data.tar.gz: f70b583ddc63694e1f30869b85f2b00801f6e0e2cbf3e1fe70d0f9cd8d77f88af2e59df1600bc29b67ab275a75a93624f00f6af630921c3f928263c69bce070d
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
10
+ *gemspec
11
+ .rake_tasks~
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+
6
+ gem 'rest-client', '~> 2.0', '>= 2.0.2'
7
+ gem 'minitest', '~> 5.11', '>= 5.11.3'
8
+ gem 'rake', '~> 12.3', '>= 12.3.1'
9
+ gem 'json', '~> 2.1'
10
+ gem 'minitest-hooks', '~> 1.5'
11
+ gem 'sinatra'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Farhad
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,69 @@
1
+ # Moka
2
+ [![Progress](http://progressed.io/bar/12?title=completed)](http://progressed.io/bar/12?title=completed) [![Gem Version](https://badge.fury.io/rb/moka-payment.svg)](https://badge.fury.io/rb/moka-payment)
3
+
4
+ MOKA'nın ödeme alma, ödeme isteği gönderme, kart saklama ve tekrarlayan ödeme servisleri ile ödemelerinizi alabilirsiniz.
5
+ [Üye](https://mokapos.moka.com/) olun ve Moka'yı kullanmaya hemen başlayın!
6
+
7
+ ## Kurulum
8
+
9
+ Moka'yı Gemfile içine dahil edin
10
+
11
+ ```ruby
12
+ gem 'moka-payment', :require => 'moka'
13
+ ```
14
+
15
+ Gerekli paketlerin tamamen kurulduğundan emin olun
16
+
17
+ $ bundle
18
+
19
+ Veya kendiniz kurun
20
+
21
+ $ gem install moka-payment
22
+
23
+ ## Kullanım
24
+ İlk önce Moka'dan aldığınız bayi numarasını, kullanıcı adınızı ve parolanızı tanıtmanız gerekiyor
25
+
26
+ ```ruby
27
+ require 'moka'
28
+
29
+ Moka.configure do |config|
30
+ config.dealer_code = "123456"
31
+ config.username = "ZXCVBNVBN"
32
+ config.password = "abcdef"
33
+ end
34
+ ```
35
+ Şimdi ilk ödememizi yapabiliriz
36
+ ```ruby
37
+ @payment = Moka::Payment::Direct.details do |detail|
38
+ detail.card_holder_full_name = "Ali Yılmaz"
39
+ detail.card_number = "5269552233334444"
40
+ detail.exp_month = "12"
41
+ detail.exp_year = "2022"
42
+ detail.cvc_number = "123"
43
+ detail.amount = 35.5
44
+ detail.currency = "TL"
45
+ detail.client_ip = "195.155.96.234"
46
+ detail.software = "OpenCart"
47
+ detail.sub_merchant_name = "Company"
48
+ detail.description = "Test Description"
49
+ detail.buyer_full_name = "Elif Yetimoğlu"
50
+ detail.buyer_email = "test@test.com"
51
+ detail.buyer_gsm_number = "1111111111"
52
+ detail.buyer_address = "New York City"
53
+ end
54
+
55
+ @payment.pay
56
+
57
+ if @payment.success?
58
+ puts "Ödeme başarı ile tamamlanmıştır"
59
+ end
60
+ ```
61
+ Daha detaylı bilgi için wiki kısmına ve resmi Moka dökümantasyonuna göz atın.
62
+
63
+ ## Contributing
64
+
65
+ Bug reports and pull requests are welcome on GitHub at https://github.com/0x2C6/moka-payment.
66
+
67
+ ## License
68
+
69
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: << "../lib"
4
+ require "bundler/setup"
5
+ Bundler.require
6
+ require "moka"
7
+ require "irb"
8
+
9
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
data/bin/sinatra.rb ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: << "../lib"
4
+ require "bundler/setup"
5
+ Bundler.require
6
+ require "moka"
7
+ require "sinatra"
8
+
9
+
10
+ get '/' do
11
+ Moka.configure do |config|
12
+ config.dealer_code = ENV['MOKA_DEALER_CODE']
13
+ config.username = ENV['MOKA_USERNAME']
14
+ config.password = ENV['MOKA_PASSWORD']
15
+ end
16
+
17
+ @direct_payment = Moka::Payment::Direct3D.details do |detail|
18
+ detail.card_holder_full_name = "Ali Yılmaz"
19
+ detail.card_number = "5269552233334444"
20
+ detail.exp_month = "12"
21
+ detail.exp_year = "2022"
22
+ detail.cvc_number = "123"
23
+ detail.amount = 35.5
24
+ detail.currency = "TL"
25
+ detail.redirect_url = "https://ed0767d7.ngrok.io/payment?MyTrxId=1A2B3CD456"
26
+ detail.installment_number = "1"
27
+ detail.client_ip = "195.155.96.234"
28
+ detail.other_trx_code = "123456"
29
+ detail.is_pre_auth = 0
30
+ detail.is_pool_payment = 0
31
+ detail.integrator_id = 1
32
+ detail.software = "OpenCart"
33
+ detail.sub_merchant_name = "Company"
34
+ detail.description = "Test Description"
35
+ detail.buyer_full_name = "Elif Yetimoğlu"
36
+ detail.buyer_email = "test@test.com"
37
+ detail.buyer_gsm_number = "1111111111"
38
+ detail.buyer_address = "New York City"
39
+ end
40
+ @direct_payment.pay
41
+ puts @direct_payment.response
42
+ if @direct_payment.success?
43
+ redirect @direct_payment.verify_payment_url
44
+ end
45
+ end
46
+
47
+ post '/payment' do
48
+ if Moka::Payment::Direct3D.paid_successfully?(params)
49
+ "Paid Succesfully"
50
+ else
51
+ "Payment Declined"
52
+ end
53
+ end
data/lib/moka.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'moka/version'
2
+ require 'moka/configuration'
3
+ require 'moka/payment/payment'
4
+ require 'moka/payment/direct'
5
+ require 'moka/payment/direct3d'
6
+ require 'moka/payment/capture'
7
+ require 'moka/get/payment_list'
8
+ require 'moka/add/customer'
9
+
10
+ module Moka
11
+ extend Configuration
12
+ end
@@ -0,0 +1,56 @@
1
+ require 'moka/request'
2
+ require 'moka/configuration'
3
+
4
+ module Moka
5
+ module Add
6
+ class Customer
7
+ attr_accessor :dealer_code, :username, :password, :check_key,
8
+ :customer_code, :customer_password, :first_name,
9
+ :last_name, :gender, :birth_date, :gsm_number,
10
+ :email, :address
11
+
12
+ def initialize(details = {})
13
+ @dealer_code = Moka.config.dealer_code
14
+ @username = Moka.config.username
15
+ @password = Moka.config.password
16
+ @check_key = Moka.config.check_key
17
+ @customer_code = details[:customer_code]
18
+ @customer_password = details[:customer_password]
19
+ @first_name = details[:first_name]
20
+ @last_name = details[:last_name]
21
+ @gender = details[:gender]
22
+ @birth_date = details[:birth_date]
23
+ @gsm_number = details[:gsm_number]
24
+ @email = details[:email]
25
+ @address = details[:address]
26
+ end
27
+
28
+ def self.details
29
+ @@response = nil
30
+ @@customer_details = Moka::Add::Customer.new
31
+ yield @@customer_details if block_given?
32
+ return @@customer_details
33
+ end
34
+
35
+ def add
36
+ @@response = Moka::Request.add_user(@@customer_details)
37
+ end
38
+
39
+ def response
40
+ @@response
41
+ end
42
+
43
+ def request_details
44
+ @@customer_details
45
+ end
46
+
47
+ def success?
48
+ if @@response["ResultCode"] == "Success"
49
+ return true
50
+ end if @@response
51
+ return false
52
+ end
53
+
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,17 @@
1
+ require 'moka/dealer'
2
+
3
+ module Moka
4
+ module Configuration
5
+
6
+ def configure
7
+ @config = Moka::Dealer.new
8
+ yield @config if block_given?
9
+ @config.get_check_key
10
+ end
11
+
12
+ def config
13
+ @config if @config
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+ require 'moka/request'
2
+ require 'moka/error'
3
+
4
+ module Moka
5
+ class Dealer
6
+ attr_accessor :dealer_code, :username, :password, :check_key
7
+
8
+ def initialize(dealer_code = nil, username = nil, password = nil)
9
+ @dealer_code = dealer_code
10
+ @username = username
11
+ @password = password
12
+ end
13
+
14
+ def get_check_key
15
+ return @check_key = Moka::Request.get_check_key(
16
+ @dealer_code, @username, @password
17
+ ).body unless [ @dealer_code, @username, @password ].any? { |key| key.nil? }
18
+ raise "Error" # Hamsi gonderilmelidi ona uygun xeta yarad
19
+ end
20
+
21
+ end
22
+ end
data/lib/moka/error.rb ADDED
@@ -0,0 +1,20 @@
1
+ module Moka
2
+ module Error
3
+ class RequestError < StandardError
4
+ attr_accessor :message
5
+
6
+ def initialize(message = nil)
7
+ @message = message
8
+ end
9
+
10
+ def to_s
11
+ "You have an error #{@message}" if @message
12
+ end
13
+ end
14
+
15
+ class NullPaymentInformation < StandardError; end
16
+ class NullRedirectUrl < StandardError; end
17
+ class NotDirectOrDirect3DPayment < StandardError; end
18
+ class NotCapturePayment < StandardError; end
19
+ end
20
+ end
@@ -0,0 +1,57 @@
1
+ require 'moka/request'
2
+ require 'moka/configuration'
3
+
4
+ module Moka
5
+ module Get
6
+ class PaymentList
7
+ attr_accessor :dealer_code, :username, :password, :check_key, :payment_start_date,
8
+ :payment_end_date, :payment_status, :trx_status
9
+
10
+ def initialize(details = {})
11
+ @dealer_code = Moka.config.dealer_code
12
+ @username = Moka.config.username
13
+ @password = Moka.config.password
14
+ @check_key = Moka.config.check_key
15
+ @payment_start_date = details[:payment_start_date]
16
+ @payment_end_date = details[:payment_end_date]
17
+ @payment_status = details[:payment_status]
18
+ @trx_status = details[:trx_status]
19
+ end
20
+
21
+ def self.details
22
+ @@response = nil
23
+ @@payment_list_details = Moka::Get::PaymentList.new
24
+ yield @@payment_list_details if block_given?
25
+ return @@payment_list_details
26
+ end
27
+
28
+ def request_details
29
+ @@payment_list_details
30
+ end
31
+
32
+ def get_list
33
+ @@response = Moka::Request.get_payment_list(@@payment_list_details)
34
+ end
35
+
36
+ def response
37
+ @@response
38
+ end
39
+
40
+
41
+ def success?
42
+ if @@response["Data"]
43
+ return true if @@response["Data"]["IsSuccessful"]
44
+ end if @@response
45
+ return false
46
+ end
47
+
48
+ def list_count
49
+ if @@response["Data"]
50
+ return @@response["Data"]["ListItemCount"]
51
+ end if @@response
52
+ return 0
53
+ end
54
+
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,35 @@
1
+ require 'moka/payment/payment'
2
+ require 'moka/request'
3
+
4
+ module Moka
5
+ module Payment
6
+ class Capture < Moka::Payment::Payment
7
+ attr_accessor :virtual_pos_order_id, :other_trx_code, :amount, :client_ip
8
+
9
+ def initialize(details = {})
10
+ super
11
+ @virtual_pos_order_id = details[:virtual_pos_order_id]
12
+ @other_trx_code = details[:other_trx_code]
13
+ @amount = details[:amount]
14
+ @client_ip = details[:client_ip]
15
+ end
16
+
17
+ def self.details
18
+ @@capture_details = Moka::Payment::Capture.new
19
+ super @@capture_details
20
+ end
21
+
22
+ def capture
23
+ @response = Moka::Request.capture(@@capture_details)
24
+ @error = Moka::Error::RequestError.new
25
+ @error.message = @response["ResultCode"] unless @response["Data"]
26
+ return @response
27
+ end
28
+
29
+ def request_details
30
+ @@capture_details
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,40 @@
1
+ require 'moka/payment/payment'
2
+
3
+ module Moka
4
+ module Payment
5
+ class Direct < Moka::Payment::Payment
6
+
7
+ def initialize(details = {})
8
+ super
9
+ @card_holder_full_name = details[:card_number]
10
+ @card_number = details[:card_number]
11
+ @card_holder_full_name = details[:card_holder_full_name]
12
+ @exp_month = details[:exp_month]
13
+ @exp_year = details[:exp_year]
14
+ @cvc_number = details[:cvc_number]
15
+ @card_token = details[:card_token]
16
+ @amount = details[:amount]
17
+ @currency = details[:currency] || "USD"
18
+ @installment_number = details[:installment_number] || 1
19
+ @client_ip = details[:client_ip]
20
+ @other_trx_code = details[:other_trx_code]
21
+ @is_pre_auth = details[:is_pre_auth] || 0
22
+ @is_pool_payment = details[:is_pool_payment]
23
+ @integrator_id = details[:installment_number]
24
+ @software = details[:software]
25
+ @sub_merchant_name = details[:sub_merchant_name]
26
+ @description = details[:description]
27
+ @buyer_full_name = details[:buyer_full_name]
28
+ @buyer_email = details[:buyer_email]
29
+ @buyer_gsm_number = details[:buyer_gsm_number]
30
+ @buyer_address = details[:buyer_address]
31
+ end
32
+
33
+ def self.details
34
+ @payment_details = Moka::Payment::Direct.new
35
+ super @payment_details
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,61 @@
1
+ require 'moka/payment/payment'
2
+
3
+ module Moka
4
+ module Payment
5
+ class Direct3D < Moka::Payment::Payment
6
+ def initialize(details={})
7
+ super
8
+ @card_holder_full_name = details[:card_number]
9
+ @card_number = details[:card_number]
10
+ @card_holder_full_name = details[:card_holder_full_name]
11
+ @exp_month = details[:exp_month]
12
+ @exp_year = details[:exp_year]
13
+ @cvc_number = details[:cvc_number]
14
+ @card_token = details[:card_token]
15
+ @amount = details[:amount]
16
+ @currency = details[:currency] || "USD"
17
+ @redirect_url = details[:redirect_url]
18
+ @installment_number = details[:installment_number] || 1
19
+ @client_ip = details[:client_ip]
20
+ @other_trx_code = details[:other_trx_code]
21
+ @is_pre_auth = details[:is_pre_auth] || 0
22
+ @is_pool_payment = details[:is_pool_payment]
23
+ @integrator_id = details[:installment_number]
24
+ @software = details[:software]
25
+ @sub_merchant_name = details[:sub_merchant_name]
26
+ @description = details[:description]
27
+ @buyer_full_name = details[:buyer_full_name]
28
+ @buyer_email = details[:buyer_email]
29
+ @buyer_gsm_number = details[:buyer_gsm_number]
30
+ @buyer_address = details[:buyer_address]
31
+ end
32
+
33
+ def success?
34
+ return true if @response["ResultCode"] == "Success"
35
+ return false
36
+ end
37
+
38
+ def verify_payment_url
39
+ return @response["Data"] if @response["Data"]
40
+ return false
41
+ end
42
+
43
+ class << self
44
+
45
+ def paid_successfully?(params)
46
+ #TODO burdan qayidan hersey ucun xeta kodu var olari hamsini add ele
47
+ unless params["isSuccessful"] == "False"
48
+ return params
49
+ end
50
+ return false
51
+ end
52
+
53
+ def details
54
+ @payment_details = Moka::Payment::Direct3D.new
55
+ super @payment_details
56
+ end
57
+
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,77 @@
1
+ require 'moka/request'
2
+ require 'moka/configuration'
3
+ require 'moka/error'
4
+
5
+ module Moka
6
+ module Payment
7
+ class Payment
8
+ attr_accessor :dealer_code, :username, :password, :check_key,
9
+ :card_holder_full_name, :card_number, :exp_month, :exp_year,
10
+ :cvc_number, :card_token, :amount, :currency, :redirect_url, :installment_number,
11
+ :client_ip, :other_trx_code, :is_pre_auth, :is_pool_payment,
12
+ :integrator_id, :software, :description, :sub_merchant_name,
13
+ :buyer_full_name, :buyer_email, :buyer_gsm_number, :buyer_address
14
+
15
+ def initialize(details = {})
16
+ @dealer_code = Moka.config.dealer_code
17
+ @username = Moka.config.username
18
+ @password = Moka.config.password
19
+ @check_key = Moka.config.check_key
20
+ end
21
+
22
+ def pay
23
+ return raise Moka::Error::NotDirectOrDirect3DPayment unless @@payment_details.is_a?(Moka::Payment::Direct) ||
24
+ @@payment_details.is_a?(Moka::Payment::Direct3D)
25
+ return raise Moka::Error::NullRedirectUrl if @@payment_details.is_a?(Moka::Payment::Direct3D) &&
26
+ @@payment_details.redirect_url.nil?
27
+ non_blank_details = [
28
+ @dealer_code, @username, @password, @check_key,
29
+ @card_holder_full_name, @card_token, @amount
30
+ ]
31
+
32
+ unless @card_token
33
+ non_blank_details.delete(@card_token)
34
+ non_blank_details.push(@card_number, @exp_month, @exp_year, @cvc_number)
35
+ end
36
+
37
+ if @@payment_details.is_a? Moka::Payment::Direct3D
38
+ non_blank_details.push(@redirect_url)
39
+ else
40
+ @@payment_details.redirect_url = nil
41
+ end
42
+
43
+ return raise Moka::Error::NullPaymentInformation if non_blank_details.any? {|detail| detail.nil?}
44
+ @response = Moka::Request.direct_payment(@@payment_details)
45
+ @error = Moka::Error::RequestError.new
46
+ @error.message = @response["ResultCode"] unless @response["Data"]
47
+ return @response
48
+ end
49
+
50
+ def self.details(details)
51
+ @@payment_details = details
52
+ yield @@payment_details if block_given?
53
+ return @@payment_details
54
+ end
55
+
56
+ def response
57
+ @response
58
+ end
59
+
60
+ def request_details
61
+ @@payment_details
62
+ end
63
+
64
+ def success?
65
+ if @response["Data"]
66
+ return true if @response["Data"]["IsSuccessful"]
67
+ end
68
+ return false
69
+ end
70
+
71
+ def errors
72
+ @error
73
+ end
74
+
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,151 @@
1
+ require 'rest-client'
2
+ require 'json'
3
+ require 'pp'
4
+
5
+ module Moka
6
+ module Request
7
+ TEST_SERVICE_URL = "https://service.testmoka.com"
8
+ SERVICE_URL = "https://service.moka.com"
9
+ DIRECT_PAYMENT_URL = "#{SERVICE_URL}/PaymentDealer/DoDirectPayment"
10
+ DIRECT3D_PAYMENT_URL = "#{SERVICE_URL}/PaymentDealer/DoDirectPaymentThreeD"
11
+ CAPTURE_PAYMENT_URL = "#{SERVICE_URL}/PaymentDealer/DoCapture"
12
+ GET_PAYMENT_LIST_URL = "#{SERVICE_URL}/PaymentDealer/GetPaymentList"
13
+ ADD_CUSTOMER_URL = "#{SERVICE_URL}/DealerCustomer/AddCustomer"
14
+
15
+ class << self
16
+
17
+ def get_check_key(dealer_code, username, password)
18
+ RestClient.get 'http://developer.moka.com/pages/checkkey.php',
19
+ {
20
+ params: {
21
+ DealerCode: dealer_code,
22
+ Username: username,
23
+ Password: password
24
+ }
25
+ }
26
+ end
27
+
28
+ def direct_payment(payment_details)
29
+ payment_dealer_authentication = {
30
+ "DealerCode": payment_details.dealer_code,
31
+ "Username": payment_details.username,
32
+ "Password": payment_details.password,
33
+ "CheckKey": payment_details.check_key
34
+ }
35
+
36
+ payment_dealer_request = {
37
+ "CardHolderFullName": payment_details.card_holder_full_name,
38
+ "CardNumber": payment_details.card_number,
39
+ "ExpMonth": payment_details.exp_month,
40
+ "ExpYear": payment_details.exp_year,
41
+ "CvcNumber": payment_details.cvc_number,
42
+ "Amount": payment_details.amount,
43
+ "Currency": payment_details.currency,
44
+ "InstallmentNumber": payment_details.installment_number,
45
+ "IsPreAuth": payment_details.is_pre_auth
46
+ }
47
+
48
+ ["CardNumber", "ExpMonth", "ExpMonth", "CvcNumber"].each do |detail|
49
+ payment_dealer_request.delete(detail.to_sym)
50
+ end && payment_dealer_request["CardToken"] = payment_details.card_token if payment_details.card_token
51
+
52
+ payment_dealer_request["RedirectUrl"] = payment_details.redirect_url if payment_details.redirect_url
53
+ payment_dealer_request["ClientIP"] = payment_details.client_ip if payment_details.client_ip
54
+ payment_dealer_request["OtherTrxCode"] = payment_details.other_trx_code if payment_details.other_trx_code
55
+ payment_dealer_request["IsPoolPayment"] = payment_details.is_pool_payment if payment_details.is_pool_payment
56
+ payment_dealer_request["IntegratorId"] = payment_details.integrator_id if payment_details.integrator_id
57
+ payment_dealer_request["Software"] = payment_details.software if payment_details.software
58
+ payment_dealer_request["Description"] = payment_details.description if payment_details.description
59
+
60
+ buyer_information = {}
61
+ buyer_information["BuyerFullName"] = payment_details.buyer_full_name if payment_details.buyer_full_name
62
+ buyer_information["BuyerEmail"] = payment_details.buyer_email if payment_details.buyer_email
63
+ buyer_information["BuyerGsmNumber"] = payment_details.buyer_gsm_number if payment_details.buyer_gsm_number
64
+ buyer_information["BuyerAddress"] = payment_details.buyer_address if payment_details.buyer_address
65
+
66
+ response = RestClient.post payment_details.redirect_url ? DIRECT3D_PAYMENT_URL : DIRECT_PAYMENT_URL,
67
+ {
68
+ "PaymentDealerAuthentication": payment_dealer_authentication,
69
+ "PaymentDealerRequest": payment_dealer_request,
70
+ "BuyerInformation": buyer_information
71
+ }
72
+ return JSON.parse(response.body)
73
+ end
74
+
75
+ def capture(capture_details)
76
+ payment_dealer_authentication = {
77
+ "DealerCode": capture_details.dealer_code,
78
+ "Username": capture_details.username,
79
+ "Password": capture_details.password,
80
+ "CheckKey": capture_details.check_key
81
+ }
82
+
83
+ payment_dealer_request = {
84
+ "VirtualPosOrderId": capture_details.virtual_pos_order_id,
85
+ "OtherTrxCode": capture_details.other_trx_code || "",
86
+ "Amount": capture_details.amount,
87
+ "ClientIP": capture_details.client_ip
88
+ }
89
+
90
+ response = RestClient.post CAPTURE_PAYMENT_URL,
91
+ {
92
+ "PaymentDealerAuthentication": payment_dealer_authentication,
93
+ "PaymentDealerRequest": payment_dealer_request
94
+ }
95
+ return JSON.parse(response.body)
96
+ end
97
+
98
+ def get_payment_list(payment_list_details)
99
+ payment_dealer_authentication = {
100
+ "DealerCode": payment_list_details.dealer_code,
101
+ "Username": payment_list_details.username,
102
+ "Password": payment_list_details.password,
103
+ "CheckKey": payment_list_details.check_key
104
+ }
105
+
106
+ payment_dealer_request = {
107
+ "PaymentStartDate": payment_list_details.payment_start_date,
108
+ "PaymentEndDate": payment_list_details.payment_end_date,
109
+ }
110
+ payment_dealer_request["PaymentStatus"] = payment_list_details.payment_status.to_i if payment_list_details.payment_status
111
+ payment_dealer_request["TrxStatus"] = payment_list_details.trx_status.to_i if payment_list_details.trx_status
112
+
113
+ response = RestClient.post GET_PAYMENT_LIST_URL,
114
+ {
115
+ "PaymentDealerAuthentication": payment_dealer_authentication,
116
+ "PaymentDealerRequest": payment_dealer_request
117
+ }
118
+ return JSON.parse(response.body)
119
+ end
120
+
121
+ def add_user(customer_details)
122
+ dealer_customer_authentication = {
123
+ "DealerCode": customer_details.dealer_code,
124
+ "Username": customer_details.username,
125
+ "Password": customer_details.password,
126
+ "CheckKey": customer_details.check_key
127
+ }
128
+
129
+ dealer_customer_request = {
130
+ "CustomerCode": customer_details.customer_code,
131
+ "Password": customer_details.customer_password,
132
+ "FirstName": customer_details.first_name,
133
+ "LastName": customer_details.last_name,
134
+ "Gender": customer_details.gender,
135
+ "BirthDate": customer_details.birth_date,
136
+ "GsmNumber": customer_details.gsm_number,
137
+ "Email": customer_details.email,
138
+ "Address": customer_details.address
139
+ }
140
+
141
+ response = RestClient.post ADD_CUSTOMER_URL,
142
+ {
143
+ "DealerCustomerAuthentication": dealer_customer_authentication,
144
+ "DealerCustomerRequest": dealer_customer_request
145
+ }
146
+ return JSON.parse(response.body)
147
+ end
148
+
149
+ end
150
+ end
151
+ end
@@ -0,0 +1,3 @@
1
+ module Moka
2
+ VERSION = "0.0.5"
3
+ end
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: moka-payment
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ platform: ruby
6
+ authors:
7
+ - Farhad
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-06-04 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: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.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
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 2.0.2
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '2.0'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 2.0.2
75
+ - !ruby/object:Gem::Dependency
76
+ name: json
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '2.1'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '2.1'
89
+ - !ruby/object:Gem::Dependency
90
+ name: minitest-hooks
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '1.5'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '1.5'
103
+ description:
104
+ email:
105
+ - farhad9801@gmail.com
106
+ executables: []
107
+ extensions: []
108
+ extra_rdoc_files: []
109
+ files:
110
+ - ".gitignore"
111
+ - ".rake_tasks~"
112
+ - ".travis.yml"
113
+ - Gemfile
114
+ - Gemfile.lock
115
+ - LICENSE.txt
116
+ - README.md
117
+ - Rakefile
118
+ - bin/console
119
+ - bin/setup
120
+ - bin/sinatra.rb
121
+ - lib/moka.rb
122
+ - lib/moka/add/customer.rb
123
+ - lib/moka/configuration.rb
124
+ - lib/moka/dealer.rb
125
+ - lib/moka/error.rb
126
+ - lib/moka/get/payment_list.rb
127
+ - lib/moka/payment/capture.rb
128
+ - lib/moka/payment/direct.rb
129
+ - lib/moka/payment/direct3d.rb
130
+ - lib/moka/payment/payment.rb
131
+ - lib/moka/request.rb
132
+ - lib/moka/version.rb
133
+ - moka.gemspec
134
+ homepage: https://github.com/0x2C6/moka-payment
135
+ licenses:
136
+ - MIT
137
+ metadata: {}
138
+ post_install_message:
139
+ rdoc_options: []
140
+ require_paths:
141
+ - lib
142
+ required_ruby_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ requirements: []
153
+ rubyforge_project:
154
+ rubygems_version: 2.6.14
155
+ signing_key:
156
+ specification_version: 4
157
+ summary: Ruby gem for Moka payment system
158
+ test_files: []