moka-payment 0.0.9 → 0.0.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 642da8f111f27c2aac14a235b3b2cef38a4f5498
4
- data.tar.gz: 670acfa8535249923da327bff2f124a15ef61fd7
2
+ SHA256:
3
+ metadata.gz: 50460327b06a75dcdd12654e7d35bc21f80b9ec4c907c04584276cb8d8fb5c4c
4
+ data.tar.gz: 1b52022c7b95c3a1558f6bf4e7ffe08a0011bba6b82e91484681ffc1812c32a5
5
5
  SHA512:
6
- metadata.gz: 1a867d69b4de794c98d0c001c2e8dd2f9c2883d0441d0debadd21cd82abb21aa48a5646ea7328586b44f7856e055fd22d719ffd1a265ddd496fabd10f7611c81
7
- data.tar.gz: d3b1fe34ecf0ba8d887d6b0eed8c3dbbfd17f0337c16628e0d340601c2af9bb9d14c6895db6b9fcff8d07f359112dcb47568ee8947383b9e2d0790867ad794d7
6
+ metadata.gz: 1a8fce886c89b10314fcf5a2bb01eeddd31d7ca2c242a0f50b31e423f99b413ffbbf30d323926e0341ebce166c1bb35f53ab87956443937e4f0032fb2533d6e1
7
+ data.tar.gz: ffb56eac68de010a69bbe19acac1456dfa026f5c8a68fe462d205c3b82e6599ba809338799d6288705042967df87fcf72b64ad999991b4e90f854de6ecb5ada6
data/.gitignore CHANGED
@@ -7,5 +7,5 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  Gemfile.lock
10
- *gemspec
11
10
  .rake_tasks~
11
+ /test/moka_test.rb
data/Gemfile CHANGED
@@ -1,7 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'rest-client', '~> 2.0', '>= 2.0.2'
4
- gem 'minitest', '~> 5.11', '>= 5.11.3'
5
- gem 'rake', '~> 12.3', '>= 12.3.1'
6
- gem 'json', '~> 2.1'
7
- gem 'sinatra'
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gemspec
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
3
 
4
4
  Rake::TestTask.new(:test) do |t|
5
5
  t.libs << "test"
@@ -1,28 +1,25 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $: << '../lib'
4
- require 'bundler/setup'
5
- Bundler.require
3
+ $: << File.expand_path('./lib')
6
4
  require 'moka'
7
5
  require 'sinatra'
8
6
 
9
-
10
7
  get '/' do
11
- Moka.configure do |config|
8
+ Moka.configure env: :test do |config|
12
9
  config.dealer_code = ENV['MOKA_DEALER_CODE']
13
10
  config.username = ENV['MOKA_USERNAME']
14
11
  config.password = ENV['MOKA_PASSWORD']
15
12
  end
16
13
 
17
- @direct_payment = Moka::Payment::Direct3D.details do |detail|
14
+ direct_payment = Moka::Payment::Direct3D.details do |detail|
18
15
  detail.card_holder_full_name = "Ali Yılmaz"
19
16
  detail.card_number = "5269552233334444"
20
17
  detail.exp_month = "12"
21
18
  detail.exp_year = "2022"
22
- detail.cvc_number = "123"
19
+ detail.cvc_number = "000"
23
20
  detail.amount = 35.5
24
21
  detail.currency = "TL"
25
- detail.redirect_url = "https://ed0767d7.ngrok.io/payment?MyTrxId=1A2B3CD456"
22
+ detail.redirect_url = "https://7b9fd81b.ngrok.io/payment?MyTrxId=1A2B3CD456"
26
23
  detail.installment_number = "1"
27
24
  detail.client_ip = "195.155.96.234"
28
25
  detail.other_trx_code = "123456"
@@ -37,10 +34,14 @@ get '/' do
37
34
  detail.buyer_gsm_number = "1111111111"
38
35
  detail.buyer_address = "New York City"
39
36
  end
40
- @direct_payment.pay
41
- puts @direct_payment.response
42
- if @direct_payment.success?
43
- redirect @direct_payment.verify_payment_url
37
+
38
+ direct_payment.pay
39
+ puts direct_payment.response
40
+
41
+ if direct_payment.success?
42
+ redirect direct_payment.verify_payment_url
43
+ else
44
+ "Payment Declined"
44
45
  end
45
46
  end
46
47
 
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: << File.expand_path('./lib')
4
+ require 'moka'
5
+
6
+ Moka.configure env: :test do |config|
7
+ config.dealer_code = ENV['MOKA_DEALER_CODE']
8
+ config.username = ENV['MOKA_USERNAME']
9
+ config.password = ENV['MOKA_PASSWORD']
10
+ end
11
+
12
+ capture_payment = Moka::Payment::Capture.details do |detail|
13
+ detail.virtual_pos_order_id = "Your-Virtual-Pos-Order-ID"
14
+ detail.other_trx_code = ""
15
+ detail.amount = 35.5
16
+ detail.client_ip = "195.155.96.234"
17
+ end
18
+
19
+ capture_payment.capture
20
+ puts capture_payment.response
21
+
22
+ if capture_payment.success?
23
+ puts "Captured Succesfully"
24
+ else
25
+ puts "Capture Declined"
26
+ end
27
+ puts capture_payment.error
28
+ pp capture_payment.request_details
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: << File.expand_path('./lib')
4
+ require 'moka'
5
+
6
+ Moka.configure env: :test do |config|
7
+ config.dealer_code = ENV['MOKA_DEALER_CODE']
8
+ config.username = ENV['MOKA_USERNAME']
9
+ config.password = ENV['MOKA_PASSWORD']
10
+ end
11
+
12
+ direct_payment = Moka::Payment::Direct.details do |detail|
13
+ detail.card_holder_full_name = "Ali Yılmaz"
14
+ detail.card_number = "5269552233334444"
15
+ detail.exp_month = "12"
16
+ detail.exp_year = "2022"
17
+ detail.cvc_number = "123"
18
+ detail.amount = 35.5
19
+ detail.currency = "TL"
20
+ detail.installment_number = "1"
21
+ detail.client_ip = "195.155.96.234"
22
+ detail.other_trx_code = "123456"
23
+ detail.is_pre_auth = 0
24
+ detail.is_pool_payment = 0
25
+ detail.integrator_id = 1
26
+ detail.software = "OpenCart"
27
+ detail.sub_merchant_name = "Company"
28
+ detail.description = "Test Description"
29
+ detail.buyer_full_name = "Elif Yetimoğlu"
30
+ detail.buyer_email = "test@test.com"
31
+ detail.buyer_gsm_number = "1111111111"
32
+ detail.buyer_address = "New York City"
33
+ end
34
+
35
+ direct_payment.pay
36
+ puts direct_payment.response
37
+
38
+ if direct_payment.success?
39
+ puts "Paid Succesfully"
40
+ else
41
+ puts "Payment Declined"
42
+ end
43
+ puts direct_payment.error
44
+ pp direct_payment.request_details
@@ -66,7 +66,7 @@ module Moka
66
66
  return false
67
67
  end
68
68
 
69
- def errors
69
+ def error
70
70
  @error
71
71
  end
72
72
  end
@@ -3,7 +3,7 @@ require 'moka/request'
3
3
 
4
4
  module Moka
5
5
  module Configuration
6
- def configure(options = { env: ENV['RACK_ENV'] }) #TODO bos gelse ne olacaq?
6
+ def configure(options = { env: ENV['RACK_ENV'] })
7
7
  @config = Moka::Dealer.new
8
8
  @config.env = options[:env] ? options[:env].to_s : 'production'
9
9
  Moka::Request::set_env
@@ -13,10 +13,11 @@ module Moka
13
13
  end
14
14
 
15
15
  def get_check_key
16
+ required_params = [ @dealer_code, @username, @password ]
17
+ raise Moka::Error::NullRequiredParameter if required_params.any? { |params| params.nil? }
16
18
  return @check_key = Moka::Request.get_check_key(
17
19
  @dealer_code, @username, @password
18
- ).body unless [ @dealer_code, @username, @password ].any? { |key| key.nil? }
19
- raise "Error" # Hamsi gonderilmelidi ona uygun xeta yarad
20
+ ).body
20
21
  end
21
22
  end
22
23
  end
@@ -51,7 +51,6 @@ module Moka
51
51
  end if @@response
52
52
  return 0
53
53
  end
54
-
55
54
  end
56
55
  end
57
56
  end
@@ -2,74 +2,125 @@ require 'moka/request'
2
2
  require 'moka/configuration'
3
3
  require 'moka/error'
4
4
 
5
- module Moka
6
- module Payment
7
- class Payment
5
+ module Moka::Payment
6
+ def self.included(base)
7
+ base.class_eval do
8
8
  attr_accessor :dealer_code, :username, :password, :check_key,
9
9
  :card_holder_full_name, :card_number, :exp_month, :exp_year,
10
10
  :cvc_number, :card_token, :amount, :currency, :redirect_url, :redirect_type,
11
11
  :client_ip, :other_trx_code, :is_pre_auth, :is_pool_payment,
12
12
  :integrator_id, :software, :description, :sub_merchant_name, :installment_number,
13
- :buyer_full_name, :buyer_email, :buyer_gsm_number, :buyer_address
13
+ :buyer_full_name, :buyer_email, :buyer_gsm_number, :buyer_address, :virtual_pos_order_id
14
+
14
15
 
15
16
  def initialize(details = {})
16
17
  @dealer_code = Moka.config.dealer_code
17
18
  @username = Moka.config.username
18
19
  @password = Moka.config.password
19
20
  @check_key = Moka.config.check_key
21
+ @card_number = details[:card_number]
22
+ @card_holder_full_name = details[:card_holder_full_name]
23
+ @exp_month = details[:exp_month]
24
+ @exp_year = details[:exp_year]
25
+ @cvc_number = details[:cvc_number]
26
+ @card_token = details[:card_token]
27
+ @amount = details[:amount]
28
+ @currency = details[:currency] || "USD"
29
+ @redirect_url = details[:redirect_url]
30
+ @redirect_type = details[:redirect_type]
31
+ @installment_number = details[:installment_number] || 1
32
+ @client_ip = details[:client_ip]
33
+ @other_trx_code = details[:other_trx_code]
34
+ @is_pre_auth = details[:is_pre_auth] || 0
35
+ @is_pool_payment = details[:is_pool_payment]
36
+ @integrator_id = details[:installment_number]
37
+ @software = details[:software]
38
+ @sub_merchant_name = details[:sub_merchant_name]
39
+ @description = details[:description]
40
+ @virtual_pos_order_id = details[:virtual_pos_order_id]
41
+ @buyer_full_name = details[:buyer_full_name]
42
+ @buyer_email = details[:buyer_email]
43
+ @buyer_gsm_number = details[:buyer_gsm_number]
44
+ @buyer_address = details[:buyer_address]
20
45
  end
21
46
 
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)
47
+ if base.to_s == "Moka::Payment::Capture"
48
+ def capture
49
+ @@response = Moka::Request.capture(@@payment_details)
50
+ @@error = Moka::Error::RequestError.new
51
+ @@error.message = @@response["ResultCode"] unless @@response["Data"]
52
+ return @@response
35
53
  end
54
+ else
55
+ def pay
56
+ raise Moka::Error::NullRedirectUrl if self.class.to_s == "Moka::Payment::Direct3D" && @@payment_details.redirect_url.nil?
36
57
 
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
58
+ required_params = [
59
+ @dealer_code, @username, @password, @check_key,
60
+ @card_holder_full_name, @card_token, @amount
61
+ ]
62
+
63
+ unless @card_token
64
+ required_params.delete(@card_token)
65
+ required_params.push(@card_number, @exp_month, @exp_year, @cvc_number)
66
+ end
42
67
 
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
68
+ if self.class == Moka::Payment::Direct3D
69
+ required_params.push(@redirect_url)
70
+ else
71
+ @@payment_details.redirect_url = nil
72
+ end
73
+
74
+ raise Moka::Error::NullPaymentInformation if required_params.any? {|param| param.nil?}
75
+ @@response = Moka::Request.direct_payment(@@payment_details)
76
+ @@error = Moka::Error::RequestError.new
77
+ @@error.message = @@response["ResultCode"] unless @@response["Data"]
78
+ return @@response
79
+ end
48
80
  end
49
81
 
50
- def self.details(details)
51
- @@payment_details = details
82
+ def self.details
83
+ @@payment_details = self.new
52
84
  yield @@payment_details if block_given?
53
85
  return @@payment_details
54
86
  end
55
87
 
56
88
  def response
57
- @response
89
+ @@response
58
90
  end
59
91
 
60
92
  def request_details
61
93
  @@payment_details
62
94
  end
63
95
 
64
- def success?
65
- if @response["Data"]
66
- return true if @response["Data"]["IsSuccessful"]
67
- end
68
- return false
96
+ def error
97
+ @@error
69
98
  end
70
99
 
71
- def errors
72
- @error
100
+ if base.to_s == "Moka::Payment::Direct3D"
101
+ def success?
102
+ return true if @@response["ResultCode"] == "Success"
103
+ return false
104
+ end
105
+
106
+ def verify_payment_url
107
+ return @@response["Data"] if @@response["Data"]
108
+ return false
109
+ end
110
+
111
+ def self.paid_successfully?(params)
112
+ unless params["isSuccessful"] == "False"
113
+ return params
114
+ end
115
+ return false
116
+ end
117
+ else
118
+ def success?
119
+ if @@response["Data"]
120
+ return true if @@response["Data"]["IsSuccessful"]
121
+ end
122
+ return false
123
+ end
73
124
  end
74
125
  end
75
126
  end
@@ -1,35 +1,47 @@
1
1
  require 'moka/payment'
2
- require 'moka/request'
3
2
 
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
3
+ class Moka::Payment::Capture
4
+ include Moka::Payment
5
+ # Capture İşlemi (Ön Provizyonu Satışa Dönüştürme)
6
+ #
7
+ # Servis Adresi: /PaymentDealer/DoCapture
8
+ #
9
+ # PaymentDealerAuthentication
10
+ #
11
+ # dealer_code: (string) Moka sistemi tarafından verilen bayi kodu
12
+ # username: (string) Moka sistemi tarafından verilen Api kullanıcı adı
13
+ # password: (string) Moka sistemi tarafından verilen Api şifresi
14
+ #
15
+ # PaymentDealerRequest
16
+ # virtual_pos_order_id: (string) Ön Provizyon alma işlemi sonucunda dönen işlem numarası bilgisidir.
17
+ # 3D ödemelerde trxCode ismiyle dönülen numaradır.
18
+ # Key: trxCode Value : ORDER-17131QQFG04026575
19
+ # other_trx_code: (string) Ön Provizyon işlemi gönderirken bayinin, kendine ait verdiği Unique işlem numarasıdır.
20
+ # VirtualPosOrderId verilmişse bu numarayı boş gönderebilirsiniz. Ya da kendi Unique numaranızı
21
+ # kullanmak istiyorsanız VirtualPosOrderId alanını boş gönderebilirsiniz.
22
+ # amount: (float) Ön Provizyon kapatma tutarı (Kuruş kısmı nokta ile yazılır. Örn: 27.50) Bu tutar alınan provizyona eşit ya da küçük olabilir
23
+ # client_ip: (string) Ön Provizyonu kapatan uygulamanın (desktop/web) çalıştırıldığı bilgisayarın IP bilgisi
24
+ #
25
+ # Kullanıla bilir methodlar.
26
+ #
27
+ # def capture
28
+ # Capture işlemini sunucuya gönderir.
29
+ # end
30
+ #
31
+ # def success?
32
+ # "Data" içinde yer alan "IsSuccessful" (true/false) alanı kontrol edilerek işlemin durumu kontrol edilir.
33
+ # "IsSuccessful" içindeki boolean değer döner.
34
+ # end
35
+ #
36
+ # def request_details
37
+ # Sunucuye gönderilmiş nesnenin kopyası döner.
38
+ # end
39
+ #
40
+ # def response
41
+ # Sunucudan alınan raw nesne döner.
42
+ # end
43
+ #
44
+ # def error
45
+ # Sunucudan alıan hata döner.
46
+ # end
35
47
  end
@@ -1,38 +1,76 @@
1
1
  require 'moka/payment'
2
2
 
3
- module Moka
4
- module Payment
5
- class Direct < 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
- @installment_number = details[:installment_number] || 1
18
- @client_ip = details[:client_ip]
19
- @other_trx_code = details[:other_trx_code]
20
- @is_pre_auth = details[:is_pre_auth] || 0
21
- @is_pool_payment = details[:is_pool_payment]
22
- @integrator_id = details[:installment_number]
23
- @software = details[:software]
24
- @sub_merchant_name = details[:sub_merchant_name]
25
- @description = details[:description]
26
- @buyer_full_name = details[:buyer_full_name]
27
- @buyer_email = details[:buyer_email]
28
- @buyer_gsm_number = details[:buyer_gsm_number]
29
- @buyer_address = details[:buyer_address]
30
- end
3
+ class Moka::Payment::Direct
4
+ include Moka::Payment
5
+ # 3D Secure Olmadan Ödeme (Non-3D Ödeme)
6
+ #
7
+ # Servis Adresi: /PaymentDealer/DoDirectPayment
8
+ #
9
+ # PaymentDealerAuthentication
10
+ #
11
+ # dealer_code: (string) Moka sistemi tarafından verilen bayi kodu
12
+ # username: (string) Moka sistemi tarafından verilen Api kullanıcı adı
13
+ # password: (string) Moka sistemi tarafından verilen Api şifresi
14
+ #
15
+ # PaymentDealerRequest
16
+ #
17
+ # card_holder_full_name: (string) Kart sahibinin adı soyadı
18
+ # card_number: (string) Kart numarası
19
+ # exp_month: (string) Son kullanma tarihi ay bilgisi (MM)
20
+ # exp_year: (string) Son kullanma tarihi yıl bilgisi (YYYY)
21
+ # cvc_number: (string) Kart güvenlik numarası
22
+ # card_token: (string) Moka üzerinde Kart saklama özelliği kullanılıyorsa, Kartın Token’ ı
23
+ # verilerek çekim yapılabilir. Token verilmişse, kart numarası ve diğer
24
+ # kart bilgilerinin (son kul. tarihi, cvc) verilmesine gerek yoktur.
25
+ # amount: (float) Ödeme tutarı (Kuruş kısmı nokta ile yazılır. Örn: 27.50)
26
+ # currency: (string) Para birimi. Opsiyonel alandır, hiç gönderilmezse veya boş gönderilirse,
27
+ # default’ u TL dir, Diğer değerler : USD, EUR, GBP
28
+ # installment_number: (integer) Taksit Sayısı. Opsiyonel alandır, hiç gönderilmezse, boş gönderilirse, 0 veya
29
+ # 1 gönderilirse Peşin satış demektir, Taksit için 2 ile 12 arasında bir değer gönderilmelidir.
30
+ # client_ip: (string) Kart numarasının alındığı uygulamanın (desktop/web) çalıştırıldığı bilgisayarın IP bilgisi
31
+ # other_trx_code: (string) Mütabakat sağlamak için kendi Unique Transaction (İşlem) Kodunuzu bu alanda gönderebilirsiniz.
32
+ # (Boş da gönderilebilir). Not : Bayi ödeme detay listesi alırken bu kodunuzu kullanarak Ödeme durumunu öğrenebilirsiniz.
33
+ # is_pre_auth: (integer) 0 : Doğrudan Çekim İşlemi
34
+ # 1 : Ön Provizyon Alma İşlemi (Bir süre sonra DoCapture servisi ile ödemeye dönüştürülmeli)
35
+ # is_pool_payment: (integer) Para kredi kartından çekilecek fakat havuzda bekletilecek. Bayi, müşteri hizmet veya ürünü
36
+ # teslim aldıktan sonra ödemeyi onaylayacak ve bu işlemle ilgili ödeme onaydan sonra bayinin
37
+ # ekstresine yansıyacak (opsiyonel). Havuz sisteminde bir ödeme göndermek için bu alanı 1 yapınız.
38
+ # integrator_id: (integer) Hazır ETicaret paketlerine Moka entegrasyonu yapan Sistem Entegratörü Firmanın ID si – (Entegratör firma değilseniz bu alanı göndermeyiniz !)
39
+ # software: (string) Moka ödeme sistemiyle entegre çalışan, bu servisi çağırdığınız E-ticaret paketinin veya yazılımınızın ismi. (Max 30 karakter)
40
+ # sub_merchant_name: (string) Ekstrede görünmesini istediğiniz isim – Mokaya önceden bildirilmeli
41
+ # description: (string) Açıklama alanıdır. Ödemeye ilişkin bir açıklama yazmak istenirse bu alana yazılabilir.(200 karaktere kadar yazılabilir.)
42
+ #
43
+ # BuyerInformation (Array)(opsiyonel)
44
+ #
45
+ # Bayimizden Ürün/Hizmet satın alan müşterisi ile ilgili alanlardır.
46
+ # Bu alanların gönderilmesi zorunlu olmamasına karşın, Moka ile paylaşılması,
47
+ # ileride ödemeyle ilgili oluşabilecek sorunlara karşı, hem bayimizin hem de Moka' nın menfaatinedir.
48
+ #
49
+ # buyer_full_name: (string) Opsiyonel alandır.Alıcının adı ve soyadıdır.
50
+ # buyer_email: (string) Opsiyonel alandır.Alıcının eposta adresidir.
51
+ # buyer_gsm_number: (string) Opsiyonel alandır.Alıcının cep telefonu numarasıdır.
52
+ # buyer_address: (string) Opsiyonel alandır.Alıcının adresidir.
31
53
 
32
- def self.details
33
- @payment_details = Moka::Payment::Direct.new
34
- super @payment_details
35
- end
36
- end
37
- end
54
+ # Kullanıla bilir methodlar.
55
+ #
56
+ # def pay
57
+ # Ödeme işlemini sunucuya gönderir.
58
+ # end
59
+ #
60
+ # def success?
61
+ # "Data" içinde yer alan "IsSuccessful" (true/false) alanı kontrol edilerek işlemin durumu kontrol edilir.
62
+ # "IsSuccessful" içindeki boolean değer döner.
63
+ # end
64
+ #
65
+ # def request_details
66
+ # Sunucuye gönderilmiş nesnenin kopyası döner.
67
+ # end
68
+ #
69
+ # def response
70
+ # Sunucudan alınan raw nesne döner.
71
+ # end
72
+ #
73
+ # def error
74
+ # Sunucudan alıan hata döner.
75
+ # end
38
76
  end
@@ -1,61 +1,87 @@
1
1
  require 'moka/payment'
2
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
- @redirect_type = details[:redirect_type]
19
- @installment_number = details[:installment_number] || 1
20
- @client_ip = details[:client_ip]
21
- @other_trx_code = details[:other_trx_code]
22
- @is_pre_auth = details[:is_pre_auth] || 0
23
- @is_pool_payment = details[:is_pool_payment]
24
- @integrator_id = details[:installment_number]
25
- @software = details[:software]
26
- @sub_merchant_name = details[:sub_merchant_name]
27
- @description = details[:description]
28
- @buyer_full_name = details[:buyer_full_name]
29
- @buyer_email = details[:buyer_email]
30
- @buyer_gsm_number = details[:buyer_gsm_number]
31
- @buyer_address = details[:buyer_address]
32
- end
3
+ class Moka::Payment::Direct3D
4
+ include Moka::Payment
5
+ # 3D Secure ile Ödeme
6
+ #
7
+ # Servis Adresi: /PaymentDealer/DoDirectPaymentThreeD
8
+ #
9
+ # PaymentDealerAuthentication
10
+ #
11
+ # dealer_code: (string) Moka sistemi tarafından verilen bayi kodu
12
+ # username: (string) Moka sistemi tarafından verilen Api kullanıcı adı
13
+ # password: (string) Moka sistemi tarafından verilen Api şifresi
14
+ #
15
+ # PaymentDealerRequest
16
+ #
17
+ # card_holder_full_name: (string) Kart sahibinin adı soyadı
18
+ # card_number: (string) Kart numarası
19
+ # exp_month: (string) Son kullanma tarihi ay bilgisi (MM)
20
+ # exp_year: (string) Son kullanma tarihi yıl bilgisi (YYYY)
21
+ # cvc_number: (string) Kart güvenlik numarası
22
+ # card_token: (string) Moka üzerinde Kart saklama özelliği kullanılıyorsa, Kartın Token’ ı
23
+ # verilerek çekim yapılabilir. Token verilmişse, kart numarası ve diğer
24
+ # kart bilgilerinin (son kul. tarihi, cvc) verilmesine gerek yoktur.
25
+ # amount: (float) Ödeme tutarı (Kuruş kısmı nokta ile yazılır. Örn: 27.50)
26
+ # currency: (string) Para birimi. Opsiyonel alandır, hiç gönderilmezse veya boş gönderilirse,
27
+ # default’ u TL dir, Diğer değerler : USD, EUR, GBP
28
+ # redirect_url: (string) 3D işlemi sonucunda, başarılı ya da başarısız işlem sonucunun döndürüldüğü ve
29
+ # kullanıcının yönlendirildiği bayi web sayfası. Bu URL’ yi verirken, sonuna parametre olarak
30
+ # kendi işlem ID’ nizi yazarsanız, hangi işleminizin sonucunu aldığınızı belirlemiş olursunuz.
31
+ # Örnek : https://www.mysite.com/PayResult?MyTrxId=1A2B3C4DF5R
32
+ # Önemli Not : URL sonuna yazdığınız kendinize ait işlem kodunun, güvenliğiniz için, tahmin edilemez bir kod olmasını tercih ediniz.
33
+ # redirect_type: (integer) Opsiyonel alandır. Default değeri 0 (sıfır) dır. Ödeme işleminin sonucu servisi çağıran web sitesinde ana sayfaya y
34
+ # önlendirme yapar. IFrame içerisinden bu servis çağrılmışsa ve sonuç IFrame içine redirect yapılsın isteniyorsa, bu alana 1 yazılmalıdır.
35
+ # installment_number: (integer) Taksit Sayısı. Opsiyonel alandır, hiç gönderilmezse, boş gönderilirse, 0 veya
36
+ # 1 gönderilirse Peşin satış demektir, Taksit için 2 ile 12 arasında bir değer gönderilmelidir.
37
+ # client_ip: (string) Kart numarasının alındığı uygulamanın (desktop/web) çalıştırıldığı bilgisayarın IP bilgisi
38
+ # other_trx_code: (string) Mütabakat sağlamak için kendi Unique Transaction (İşlem) Kodunuzu bu alanda gönderebilirsiniz.
39
+ # (Boş da gönderilebilir). Not : Bayi ödeme detay listesi alırken bu kodunuzu kullanarak Ödeme durumunu öğrenebilirsiniz.
40
+ # is_pre_auth: (integer) 0 : Doğrudan Çekim İşlemi
41
+ # 1 : Ön Provizyon Alma İşlemi (Bir süre sonra DoCapture servisi ile ödemeye dönüştürülmeli)
42
+ # is_pool_payment: (integer) Para kredi kartından çekilecek fakat havuzda bekletilecek. Bayi, müşteri hizmet veya ürünü
43
+ # teslim aldıktan sonra ödemeyi onaylayacak ve bu işlemle ilgili ödeme onaydan sonra bayinin
44
+ # ekstresine yansıyacak (opsiyonel). Havuz sisteminde bir ödeme göndermek için bu alanı 1 yapınız.
45
+ # integrator_id: (integer) Hazır ETicaret paketlerine Moka entegrasyonu yapan Sistem Entegratörü Firmanın ID si – (Entegratör firma değilseniz bu alanı göndermeyiniz !)
46
+ # software: (string) Moka ödeme sistemiyle entegre çalışan, bu servisi çağırdığınız E-ticaret paketinin veya yazılımınızın ismi. (Max 30 karakter)
47
+ # sub_merchant_name: (string) Ekstrede görünmesini istediğiniz isim – Mokaya önceden bildirilmeli
48
+ # description: (string) Açıklama alanıdır. Ödemeye ilişkin bir açıklama yazmak istenirse bu alana yazılabilir.(200 karaktere kadar yazılabilir.)
49
+ #
50
+ # BuyerInformation (Array)(opsiyonel)
51
+ #
52
+ # Bayimizden Ürün/Hizmet satın alan müşterisi ile ilgili alanlardır.
53
+ # Bu alanların gönderilmesi zorunlu olmamasına karşın, Moka ile paylaşılması,
54
+ # ileride ödemeyle ilgili oluşabilecek sorunlara karşı, hem bayimizin hem de Moka' nın menfaatinedir.
55
+ #
56
+ # buyer_full_name: (string) Opsiyonel alandır.Alıcının adı ve soyadıdır.
57
+ # buyer_email: (string) Opsiyonel alandır.Alıcının eposta adresidir.
58
+ # buyer_gsm_number: (string) Opsiyonel alandır.Alıcının cep telefonu numarasıdır.
59
+ # buyer_address: (string) Opsiyonel alandır.Alıcının adresidir.
33
60
 
34
- def success?
35
- return true if @response["ResultCode"] == "Success"
36
- return false
37
- end
38
-
39
- def verify_payment_url
40
- return @response["Data"] if @response["Data"]
41
- return false
42
- end
43
-
44
- class << self
45
-
46
- def paid_successfully?(params)
47
- #TODO burdan qayidan hersey ucun xeta kodu var olari hamsini add ele
48
- unless params["isSuccessful"] == "False"
49
- return params
50
- end
51
- return false
52
- end
53
-
54
- def details
55
- @payment_details = Moka::Payment::Direct3D.new
56
- super @payment_details
57
- end
58
- end
59
- end
60
- end
61
+ # Kullanıla bilir methodlar.
62
+ #
63
+ # def pay
64
+ # Ödeme işlemini sunucuya gönderir.
65
+ # end
66
+ #
67
+ # def success?
68
+ # "Data" içinde yer alan "IsSuccessful" (true/false) alanı kontrol edilerek işlemin durumu kontrol edilir.
69
+ # "IsSuccessful" içindeki boolean değer döner.
70
+ # end
71
+ #
72
+ # def request_details
73
+ # Sunucuye gönderilmiş nesnenin kopyası döner.
74
+ # end
75
+ #
76
+ # def response
77
+ # Sunucudan alınan raw nesne döner.
78
+ # end
79
+ #
80
+ # def error
81
+ # Sunucudan alıan hata döner.
82
+ # end
83
+ #
84
+ # def self.paid_successfully?(params)
85
+ # 3D Onaylama sonucu sizin URL’ nize post atılarak dönen değerler kontrol edirir
86
+ # end
61
87
  end
@@ -63,7 +63,7 @@ module Moka
63
63
  return false
64
64
  end
65
65
 
66
- def errors
66
+ def error
67
67
 
68
68
  end
69
69
 
@@ -1,3 +1,3 @@
1
1
  module Moka
2
- VERSION = '0.0.9'
2
+ VERSION = '0.0.10'
3
3
  end
@@ -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 = "moka-payment"
8
+ spec.version = Moka::VERSION
9
+ spec.authors = ["Farhad"]
10
+ spec.email = ["farhad9801@gmail.com"]
11
+
12
+ spec.summary = %q{Ruby gem for Moka payment system}
13
+ spec.homepage = "https://github.com/0x2C6/moka-payment"
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 "minitest", "~> 5.0"
26
+
27
+ spec.add_dependency 'rest-client', '~> 2.0', '>= 2.0.2'
28
+ spec.add_dependency 'json', '~> 2.1'
29
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moka-payment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Farhad
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-22 00:00:00.000000000 Z
11
+ date: 2019-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -62,7 +62,7 @@ dependencies:
62
62
  - - ">="
63
63
  - !ruby/object:Gem::Version
64
64
  version: 2.0.2
65
- type: :development
65
+ type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
@@ -79,27 +79,13 @@ dependencies:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
81
  version: '2.1'
82
- type: :development
82
+ type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
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
89
  description:
104
90
  email:
105
91
  - farhad9801@gmail.com
@@ -115,7 +101,9 @@ files:
115
101
  - Rakefile
116
102
  - bin/console
117
103
  - bin/setup
118
- - bin/sinatra.rb
104
+ - examples/payments/3d_secure_payment.rb
105
+ - examples/payments/capture_payment.rb
106
+ - examples/payments/direct_payment.rb
119
107
  - lib/moka.rb
120
108
  - lib/moka/add/customer.rb
121
109
  - lib/moka/configuration.rb
@@ -154,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
142
  version: '0'
155
143
  requirements: []
156
144
  rubyforge_project:
157
- rubygems_version: 2.6.14
145
+ rubygems_version: 3.0.0.beta3
158
146
  signing_key:
159
147
  specification_version: 4
160
148
  summary: Ruby gem for Moka payment system