processing_kz 0.1.4

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: 4ede2eb5b7952ea5edc431e4cee5dd54d29bc534
4
+ data.tar.gz: d702ec39466235e6c2b323ab3a73a8ee95b1821a
5
+ SHA512:
6
+ metadata.gz: fe0f71af7b6b1ff8e8d07c82701f21ab81e087dab04975ce8b46a48a5387cea8fb3a9246779d26cf5bfcba72247e82cb898d58772d1a94e2682ad161c736b32b
7
+ data.tar.gz: 35ae9791688bf5a4f98c6310be19b709b19dd5153096d6ad6406c3b954e7f8e795f584554bbf061bc298eaaa194b9a1341169d06f6053480afc5dd1f8f5234a5
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ processing_kz
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.2.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in processing_kz.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Pavel Tkachenko
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # ProcessingKz
2
+
3
+ Integrate Ruby projects with Processing.kz without pain. Current version supports only standard payments without refunding. Please watch project for new releases.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'processing_kz'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install processing_kz
20
+
21
+ If you are using Rails 3+, please initiate configuration file by running:
22
+
23
+ rails g processing_kz:config
24
+
25
+ We will generate configuration file for you in `config/initializers`. You have to set all credentials received from Processing.kz provider.
26
+
27
+ ProcessingKz.config do |config|
28
+ config.wsdl = 'wsdl address'
29
+ config.host = 'processing_kz server address'
30
+ config.merchant_id = 'your merhant id'
31
+ config.language_code = 'ru' # ru, en or kz
32
+ config.currency_code = 398 # KZT code
33
+ end
34
+
35
+ If you are not using Rails, include this configuration in appropriate place, so processing_kz gem can obtain all neccesary information.
36
+
37
+ ## Usage
38
+
39
+ Full transaction process includes 3 steps. First you need to initiate transaction process and provide at least order_id, list of goods (see additional info below) and return url.
40
+
41
+ start = ProcessingKz.start(order_id: 1, goods_list: @goods, return_url: 'page for customer to continiue after payment')
42
+
43
+ Next step is to check that money is successfuly blocked on customer's card. Just pass customer_reference obtained from previous method.
44
+
45
+ transaction = ProcessingKz.get(customer_reference: start.customer_reference)
46
+ transaction.status #=> 'AUTHORISED'
47
+
48
+ Finaly you need to complete transaction to withdraw money from card. Again just pass customer_reference which you obtained during starting transaction.
49
+
50
+ ProcessingKz.complete(customer_reference: start.customer_reference)
51
+
52
+ Check that everything is alright. You have to get `'PAID'` status.
53
+
54
+ transaction = ProcessingKz.get(customer_reference: start.customer_reference)
55
+ transaction.status #=> 'PAID'
56
+
57
+ ### List of Goods
58
+
59
+ ProcessingKz is requiring list of goods or services for transaction. You can pass one good or array of goods in transaction.
60
+
61
+ my_good = ProcessingKz.good(title: 'Title of good', amount 1200.99)
62
+ start = ProcessingKz.start(order_id: 1, goods_list: my_good, return_url: 'page for customer to continiue after payment')
63
+
64
+ ### Return URL
65
+
66
+ After finishing paying process in Processing.kz frame, user will be redirected to URL, which you defined in return_url. This will help you to continiue process on your site after successful payment.
67
+
68
+
69
+ ## Contributing
70
+
71
+ 1. Fork it ( https://github.com/paveltkachenko/processing_kz/fork )
72
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
73
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
74
+ 4. Push to the branch (`git push origin my-new-feature`)
75
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task default: :spec
7
+ task test: :spec
8
+
@@ -0,0 +1,11 @@
1
+ module ProcessingKz
2
+ module Generators
3
+ class ConfigGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../templates', __FILE__)
5
+
6
+ def generate_config
7
+ copy_file 'processing_kz.rb', 'config/initializers/processing_kz.rb'
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ ProcessingKz.config do |config|
2
+ config.wsdl = 'wsdl address'
3
+ config.host = 'processing_kz server address'
4
+ config.merchant_id = 'your merhant id'
5
+ config.language_code = 'ru' # ru, en or kz
6
+ config.currency_code = 398 # KZT code
7
+ end
@@ -0,0 +1,55 @@
1
+ require 'savon'
2
+
3
+ module ProcessingKz
4
+ class CompleteTransaction
5
+ attr_reader :merchant_id,
6
+ :customer_reference,
7
+ :transaction_success,
8
+ :override_amount,
9
+ :goods_list,
10
+ :success
11
+
12
+ def initialize(args= {})
13
+ @merchant_id = args[:merchant_id] || Config.merchant_id
14
+ @customer_reference = args[:customer_reference]
15
+ @transaction_success = args[:transaction_success] || true
16
+ @override_amount = args[:override_amount]
17
+ @goods_list = args[:goods_list]
18
+ request!
19
+ end
20
+
21
+ def total_amount
22
+ raise NoGoodsError unless goods_list
23
+ total = 0
24
+ goods_list.each do |good|
25
+ total += good.amount
26
+ end
27
+ total
28
+ end
29
+
30
+ def hashed_goods_list
31
+ hash = []
32
+ goods_list.each do |good|
33
+ hash << good.to_hash
34
+ end
35
+ hash
36
+ end
37
+
38
+ def request!
39
+ client = Savon.client(wsdl: Config.wsdl, endpoint: Config.host)
40
+ response = client.call(:complete_transaction, message: {
41
+ merchant_id: merchant_id,
42
+ customer_reference: customer_reference,
43
+ transaction_success: transaction_success,
44
+ override_amount: override_amount,
45
+ goods_list: goods_list
46
+ }
47
+ )
48
+ response(response.body[:complete_transaction_response][:return])
49
+ end
50
+
51
+ def response(success)
52
+ @success = success
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,54 @@
1
+ module ProcessingKz
2
+
3
+ def self.config(&block)
4
+ Config.set(&block)
5
+ end
6
+
7
+ class Config
8
+
9
+ def self.set(&block)
10
+ instance_eval(&block)
11
+ end
12
+
13
+ def self.merchant_id=(merchant_id)
14
+ @@merchant_id = merchant_id
15
+ end
16
+
17
+ def self.merchant_id
18
+ @@merchant_id
19
+ end
20
+
21
+ def self.currency_code=(currency_code)
22
+ @@currency_code = currency_code
23
+ end
24
+
25
+ def self.currency_code
26
+ @@currency_code
27
+ end
28
+
29
+ def self.language_code=(language_code)
30
+ raise UnsupportedLanguageError unless ['ru', 'en', 'kz'].include?(language_code)
31
+ @@language_code = language_code
32
+ end
33
+
34
+ def self.language_code
35
+ @@language_code
36
+ end
37
+
38
+ def self.wsdl=(wsdl)
39
+ @@wsdl = wsdl
40
+ end
41
+
42
+ def self.wsdl
43
+ @@wsdl
44
+ end
45
+
46
+ def self.host=(host)
47
+ @@host = host
48
+ end
49
+
50
+ def self.host
51
+ @@host
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,2 @@
1
+ class UnsupportedLanguageError < StandardError ; end
2
+ class NoGoodsError < StandardError ; end
@@ -0,0 +1,78 @@
1
+ require 'savon'
2
+
3
+ module ProcessingKz
4
+ class GetTransaction
5
+
6
+ attr_reader :merchant_id,
7
+ :customer_reference,
8
+ :transaction_status,
9
+ :transaction_currency_code,
10
+ :amount_requested,
11
+ :amount_authorized,
12
+ :amount_refunded,
13
+ :goods,
14
+ :auth_code,
15
+ :purchaser_name,
16
+ :purchaser_email,
17
+ :purchaser_phone,
18
+ :merchant_local_date_time,
19
+ :merchant_online_address
20
+
21
+ def initialize(args= {})
22
+ @merchant_id = args[:merchant_id] || Config.merchant_id
23
+ @customer_reference = args[:customer_reference]
24
+ request!
25
+ end
26
+
27
+ def status
28
+ @transaction_status
29
+ end
30
+
31
+ def goods=(goods)
32
+ @goods = goods if goods.class == Array
33
+ @goods = [goods] unless goods.class == Array
34
+ end
35
+
36
+ def total_amount
37
+ raise NoGoodsError unless goods_list
38
+ total = 0
39
+ goods_list.each do |good|
40
+ total += good.amount
41
+ end
42
+ total
43
+ end
44
+
45
+ def hashed_goods_list
46
+ hash = []
47
+ goods_list.each do |good|
48
+ hash << good.to_hash
49
+ end
50
+ hash
51
+ end
52
+
53
+ def request!
54
+ client = Savon.client(wsdl: Config.wsdl, endpoint: Config.host)
55
+ response = client.call(:get_transaction_status, message: {
56
+ merchant_id: merchant_id,
57
+ customer_reference: customer_reference
58
+ }
59
+ )
60
+ response(response.body[:get_transaction_status_response][:return])
61
+ end
62
+
63
+ def response(args = {})
64
+ @transaction_status = args[:transaction_status]
65
+ @transaction_currency_code = args[:currency_code] || Config.currency_code
66
+ @amount_requested = args[:amount_requested]
67
+ @amount_authorized = args[:amount_authorized]
68
+ @amount_refunded = args[:amount_refunded]
69
+ @auth_code = args[:auth_code]
70
+ @purchaser_name = args[:purchaser_name]
71
+ @purchaser_email = args[:purchaser_email]
72
+ @purchaser_phone = args[:purchaser_phone]
73
+ @merchant_online_address = args[:merchant_online_address]
74
+ @merchant_local_date_time = args[:merchant_local_date_time] || Time.now
75
+ self.goods = args[:goods_list]
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,28 @@
1
+ module ProcessingKz
2
+ class GoodsItem
3
+
4
+ attr_reader :title,
5
+ :good_id,
6
+ :amount,
7
+ :currency_code
8
+
9
+ def initialize(args = {})
10
+ @currency_code = args[:currency_code] || Config.currency_code
11
+ @title = args[:title]
12
+ @good_id = args[:good_id]
13
+ @amount = (args[:amount] * 100).to_i
14
+ end
15
+
16
+ def merchants_goods_id
17
+ @good_id
18
+ end
19
+
20
+ def name_of_goods
21
+ @title
22
+ end
23
+
24
+ def to_hash
25
+ { currency_code: @currency_code, name_of_goods: name_of_goods, merchants_goods_id: merchants_goods_id, amount: @amount }
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,94 @@
1
+ require 'savon'
2
+
3
+ module ProcessingKz
4
+ class StartTransaction
5
+ attr_reader :merchant_id,
6
+ :currency_code,
7
+ :language_code,
8
+ :terminal_id,
9
+ :customer_reference,
10
+ :order_id,
11
+ :description,
12
+ :goods_list,
13
+ :billing_address,
14
+ :return_url,
15
+ :purchaser_name,
16
+ :purchaser_email,
17
+ :purchaser_phone,
18
+ :merchant_local_date_time,
19
+ :success,
20
+ :redirect_url,
21
+ :error_description
22
+
23
+ def initialize(args = {})
24
+ @merchant_id = args[:merchant_id] || Config.merchant_id
25
+ @currency_code = args[:currency_code] || Config.currency_code
26
+ @language_code = args[:language_code] || Config.language_code
27
+ @terminal_id = args[:terminal_id]
28
+ @order_id = args[:order_id]
29
+ @description = args[:description]
30
+ @purchaser_name = args[:purchaser_name]
31
+ @return_url = args[:return_url]
32
+ @purchaser_email = args[:purchaser_email]
33
+ @purchaser_phone = args[:purchaser_phone]
34
+ @customer_reference = args[:customer_reference]
35
+ self.goods_list = args[:goods_list]
36
+ self.merchant_local_date_time = args[:merchant_local_date_time] || Time.now
37
+ request!
38
+ end
39
+
40
+ def goods_list=(goods)
41
+ if goods.class == Array
42
+ @goods_list = goods
43
+ else
44
+ @goods_list = [goods]
45
+ end
46
+ end
47
+
48
+ def merchant_local_date_time=(time)
49
+ raise ArgumentError unless time.class == Time
50
+ @merchant_local_date_time = time.strftime('%d.%m.%Y %H:%M:%S')
51
+ end
52
+
53
+ def total_amount
54
+ raise NoGoodsError unless goods_list
55
+ total = 0
56
+ goods_list.each do |good|
57
+ total += good.amount
58
+ end
59
+ total
60
+ end
61
+
62
+ def hashed_goods_list
63
+ raise NoGoodsError unless goods_list
64
+ hash = []
65
+ goods_list.reduce { |good| hash << good.to_hash }
66
+ hash
67
+ end
68
+
69
+ def request!
70
+ client = Savon.client(wsdl: Config.wsdl, endpoint: Config.host)
71
+ request = client.call(:start_transaction, message: {
72
+ transaction: {
73
+ merchant_id: merchant_id,
74
+ currency_code: currency_code,
75
+ language_code: language_code,
76
+ order_id: order_id,
77
+ goods_list: hashed_goods_list,
78
+ merchant_local_date_time: merchant_local_date_time,
79
+ return_u_r_l: return_url,
80
+ total_amount: total_amount.to_i
81
+ }
82
+ }
83
+ )
84
+ response(request.body[:start_transaction_response][:return])
85
+ end
86
+
87
+ def response(args = {})
88
+ @success = args[:success]
89
+ @redirect_url = args[:redirect_url]
90
+ @error_description = args[:error_description]
91
+ @customer_reference = args[:customer_reference]
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,5 @@
1
+ class String
2
+ def camel_case_lower
3
+ self.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
4
+ end
5
+ end
@@ -0,0 +1,18 @@
1
+ module ProcessingKz
2
+
3
+ def self.start(*args)
4
+ StartTransaction.new(*args)
5
+ end
6
+
7
+ def self.get(*args)
8
+ GetTransaction.new(*args)
9
+ end
10
+
11
+ def self.complete(*args)
12
+ CompleteTransaction.new(*args)
13
+ end
14
+
15
+ def self.good(*args)
16
+ ProcessingKz::GoodsItem.new(*args)
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module ProcessingKz
2
+ VERSION = '0.1.4'
3
+ end
@@ -0,0 +1,9 @@
1
+ require 'processing_kz/version'
2
+ require 'processing_kz/config'
3
+ require 'processing_kz/errors'
4
+ require 'processing_kz/string'
5
+ require 'processing_kz/transaction'
6
+ require 'processing_kz/start_transaction'
7
+ require 'processing_kz/get_transaction'
8
+ require 'processing_kz/complete_transaction'
9
+ require 'processing_kz/goods_item'
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'processing_kz/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'processing_kz'
9
+ spec.version = ProcessingKz::VERSION
10
+ spec.authors = ['Pavel Tkachenko']
11
+ spec.email = ['tpepost@gmail.com']
12
+ spec.summary = 'Integrate with processing.kz easily'
13
+ spec.description = 'Helps to integrate with processing.kz without pain. Merchant ID is required for work.'
14
+ spec.homepage = 'http://processing.kz'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.7'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'rspec'
25
+ spec.add_development_dependency 'capybara'
26
+ spec.add_development_dependency 'selenium-webdriver'
27
+
28
+ spec.add_runtime_dependency 'savon'
29
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe ProcessingKz do
4
+
5
+ it 'sets and returns merchant_id properly' do
6
+ ProcessingKz.config do |config|
7
+ config.merchant_id = '333000000000000'
8
+ end
9
+ expect(ProcessingKz::Config.merchant_id).to eq('333000000000000')
10
+ end
11
+
12
+ it 'sets and returns language_code properly' do
13
+ ProcessingKz.config do |config|
14
+ config.language_code = 'ru'
15
+ end
16
+ expect(ProcessingKz::Config.language_code).to eq('ru')
17
+ end
18
+
19
+ it 'restricts to set unsupported languages' do
20
+ expect do
21
+ ProcessingKz.config do |config|
22
+ config.language_code = 'de'
23
+ end
24
+ end.to raise_error(UnsupportedLanguageError)
25
+ end
26
+
27
+ it 'sets and returns currency_code properly' do
28
+ ProcessingKz.config do |config|
29
+ config.currency_code = '398'
30
+ end
31
+ expect(ProcessingKz::Config.currency_code).to eq('398')
32
+ end
33
+
34
+ it 'sets and returns wsdl properly' do
35
+ ProcessingKz.config do |config|
36
+ config.wsdl = 'https://test.processing.kz/CNPMerchantWebServices/CNPMerchantWebService.wsdl'
37
+ end
38
+ expect(ProcessingKz::Config.wsdl).to eq('https://test.processing.kz/CNPMerchantWebServices/CNPMerchantWebService.wsdl')
39
+ end
40
+
41
+ it 'sets and returns host properly' do
42
+ ProcessingKz.config do |config|
43
+ config.host = 'https://test.processing.kz/CNPMerchantWebServices/services/CNPMerchantWebService'
44
+ end
45
+ expect(ProcessingKz::Config.host).to eq('https://test.processing.kz/CNPMerchantWebServices/services/CNPMerchantWebService')
46
+ end
47
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe ProcessingKz::GoodsItem do
4
+
5
+ it 'creates goods item' do
6
+ goods_item = ProcessingKz::GoodsItem.new(title: 'Cool stuff', good: 124, amount: 1200.00, currency_code: 398)
7
+ expect(goods_item.name_of_goods).to eq('Cool stuff')
8
+ end
9
+ end
@@ -0,0 +1,4 @@
1
+ require 'processing_kz'
2
+ require 'capybara'
3
+ require 'capybara/rspec'
4
+ Capybara.default_driver = :selenium
@@ -0,0 +1,83 @@
1
+ require 'spec_helper'
2
+
3
+ feature 'Transaction' do
4
+
5
+ before do
6
+
7
+ ProcessingKz.config do |config|
8
+ config.wsdl = 'https://test.processing.kz/CNPMerchantWebServices/CNPMerchantWebService.wsdl'
9
+ config.host = 'https://test.processing.kz/CNPMerchantWebServices/services/CNPMerchantWebService'
10
+ config.merchant_id = '333000000000000'
11
+ config.language_code = 'en'
12
+ config.currency_code = 398
13
+ end
14
+
15
+ @goods = []
16
+ @goods << ProcessingKz::GoodsItem.new(title: 'Cool stuff', good_id: 124, amount: 1200.00)
17
+ @goods << ProcessingKz::GoodsItem.new(title: 'Mega stuff', good_id: 125, amount: 120.99)
18
+
19
+ @good = ProcessingKz::GoodsItem.new(title: 'One stuff', good_id: 125, amount: 12070)
20
+ end
21
+
22
+ it 'handles total amount correctly (*100)' do
23
+ request = ProcessingKz::StartTransaction.new(order_id: rand(1..1000000), goods_list: @goods, return_url: 'http://localhost')
24
+ expect(request.total_amount).to eq(132099)
25
+ end
26
+
27
+ it 'makes a successful start transaction request' do
28
+ request = ProcessingKz::StartTransaction.new(order_id: rand(1..1000000), goods_list: @goods, return_url: 'http://localhost')
29
+ expect(request.success).to eq(true)
30
+ end
31
+
32
+ it 'makes a unsuccessful star transaction request' do
33
+ request = ProcessingKz::StartTransaction.new(merchant_id: 'bad_id', goods_list: @goods)
34
+ expect(request.success).to eq(false)
35
+ end
36
+
37
+ it 'makes request for transaction status which is pending' do
38
+ request = ProcessingKz::StartTransaction.new(order_id: rand(1..1000000), goods_list: @goods, return_url: 'http://localhost')
39
+ status = ProcessingKz::GetTransaction.new(customer_reference: request.customer_reference)
40
+ expect(status.transaction_status).to eq('PENDING_CUSTOMER_INPUT')
41
+ end
42
+
43
+ it 'makes request for transaction status which is authorised' do
44
+ request = ProcessingKz::StartTransaction.new(order_id: rand(1..1000000), goods_list: @goods, return_url: 'http://google.com')
45
+ visit request.redirect_url
46
+ fill_in 'panPart1', with: '4012'
47
+ fill_in 'panPart2', with: '0010'
48
+ fill_in 'panPart3', with: '3844'
49
+ fill_in 'panPart4', with: '3335'
50
+ select '01', from: 'expiryMonth'
51
+ select '2029', from: 'expiryYear'
52
+ fill_in 'cardHolder', with: 'IVAN INAVOV'
53
+ fill_in 'cardSecurityCode', with: '123'
54
+ fill_in 'cardHolderEmail', with: 'test@processing.kz'
55
+ fill_in 'cardHolderPhone', with: '87771234567'
56
+ click_button 'Pay'
57
+ sleep 5
58
+ status = ProcessingKz::GetTransaction.new(customer_reference: request.customer_reference)
59
+ expect(status.transaction_status).to eq('AUTHORISED')
60
+ click_button 'Return'
61
+ end
62
+
63
+ it 'successfuly makes all process of transaction through coder friendly interface' do
64
+ start = ProcessingKz.start(order_id: rand(1..1000000), goods_list: @good, return_url: 'http://google.com')
65
+ visit start.redirect_url
66
+ fill_in 'panPart1', with: '4012'
67
+ fill_in 'panPart2', with: '0010'
68
+ fill_in 'panPart3', with: '3844'
69
+ fill_in 'panPart4', with: '3335'
70
+ select '01', from: 'expiryMonth'
71
+ select '2029', from: 'expiryYear'
72
+ fill_in 'cardHolder', with: 'MARIA SIDOROVA'
73
+ fill_in 'cardSecurityCode', with: '123'
74
+ fill_in 'cardHolderEmail', with: 'test@processing.kz'
75
+ fill_in 'cardHolderPhone', with: '87011234567'
76
+ click_button 'Pay'
77
+ sleep 5
78
+ ProcessingKz.complete(customer_reference: start.customer_reference, transaction_success: true)
79
+ status = ProcessingKz.get(customer_reference: start.customer_reference)
80
+ expect(status.transaction_status).to eq('PAID')
81
+ click_button 'Return'
82
+ end
83
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: processing_kz
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
5
+ platform: ruby
6
+ authors:
7
+ - Pavel Tkachenko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-22 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: capybara
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: selenium-webdriver
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: savon
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Helps to integrate with processing.kz without pain. Merchant ID is required
98
+ for work.
99
+ email:
100
+ - tpepost@gmail.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".ruby-gemset"
107
+ - ".ruby-version"
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - lib/generators/processing_kz/config/config_generator.rb
113
+ - lib/generators/processing_kz/config/templates/processing_kz.rb
114
+ - lib/processing_kz.rb
115
+ - lib/processing_kz/complete_transaction.rb
116
+ - lib/processing_kz/config.rb
117
+ - lib/processing_kz/errors.rb
118
+ - lib/processing_kz/get_transaction.rb
119
+ - lib/processing_kz/goods_item.rb
120
+ - lib/processing_kz/start_transaction.rb
121
+ - lib/processing_kz/string.rb
122
+ - lib/processing_kz/transaction.rb
123
+ - lib/processing_kz/version.rb
124
+ - processing_kz.gemspec
125
+ - spec/config_spec.rb
126
+ - spec/goods_item_spec.rb
127
+ - spec/spec_helper.rb
128
+ - spec/transaction_spec.rb
129
+ homepage: http://processing.kz
130
+ licenses:
131
+ - MIT
132
+ metadata: {}
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubyforge_project:
149
+ rubygems_version: 2.4.6
150
+ signing_key:
151
+ specification_version: 4
152
+ summary: Integrate with processing.kz easily
153
+ test_files:
154
+ - spec/config_spec.rb
155
+ - spec/goods_item_spec.rb
156
+ - spec/spec_helper.rb
157
+ - spec/transaction_spec.rb