Class: ActiveMerchant::Billing::VposGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::VposGateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/vpos.rb
Constant Summary
collapse
- ENDPOINTS =
{
pci_encryption_key: '/vpos/api/0.3/application/encryption-key',
pay_pci_buy_encrypted: '/vpos/api/0.3/pci/encrypted',
pci_buy_rollback: '/vpos/api/0.3/pci_buy/rollback',
refund: '/vpos/api/0.3/refunds'
}
Constants inherited
from Gateway
Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE
Instance Attribute Summary
Attributes inherited from Gateway
#options
Instance Method Summary
collapse
Methods inherited from Gateway
#add_field_to_post_if_present, #add_fields_to_post_if_present, #card_brand, card_brand, #generate_unique_id, inherited, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #test?
#expdate, #format
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ VposGateway
Returns a new instance of VposGateway.
26
27
28
29
30
31
32
|
# File 'lib/active_merchant/billing/gateways/vpos.rb', line 26
def initialize(options = {})
requires!(options, :private_key, :public_key)
@private_key = options[:private_key]
@public_key = options[:public_key]
@shop_process_id = options[:shop_process_id] || SecureRandom.random_number(10**15)
super
end
|
Instance Method Details
#credit(money, payment, options = {}) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/active_merchant/billing/gateways/vpos.rb', line 66
def credit(money, payment, options = {})
commerce = options[:commerce] || @options[:commerce]
commerce_branch = options[:commerce_branch] || @options[:commerce_branch]
token = generate_token(@shop_process_id, 'refund', commerce, commerce_branch, amount(money), currency(money))
post = {}
post[:token] = token
post[:commerce] = commerce.to_i
post[:commerce_branch] = commerce_branch.to_i
post[:shop_process_id] = @shop_process_id
add_invoice(post, money, options)
add_card_data(post, payment)
add_customer_data(post, options)
post[:origin_shop_process_id] = options[:original_shop_process_id] if options[:original_shop_process_id]
commit(:refund, post)
end
|
#purchase(money, payment, options = {}) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/active_merchant/billing/gateways/vpos.rb', line 34
def purchase(money, payment, options = {})
commerce = options[:commerce] || @options[:commerce]
commerce_branch = options[:commerce_branch] || @options[:commerce_branch]
shop_process_id = options[:shop_process_id] || @shop_process_id
token = generate_token(shop_process_id, 'pay_pci', commerce, commerce_branch, amount(money), currency(money))
post = {}
post[:token] = token
post[:commerce] = commerce.to_s
post[:commerce_branch] = commerce_branch.to_s
post[:shop_process_id] = shop_process_id
post[:number_of_payments] = options[:number_of_payments] || 1
post[:recursive] = options[:recursive] || false
add_invoice(post, money, options)
add_card_data(post, payment)
add_customer_data(post, options)
commit(:pay_pci_buy_encrypted, post)
end
|
#refund(money, authorization, options = {}) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/active_merchant/billing/gateways/vpos.rb', line 84
def refund(money, authorization, options = {})
commerce = options[:commerce] || @options[:commerce]
commerce_branch = options[:commerce_branch] || @options[:commerce_branch]
shop_process_id = options[:shop_process_id] || @shop_process_id
_, original_shop_process_id = authorization.to_s.split('#')
token = generate_token(shop_process_id, 'refund', commerce, commerce_branch, amount(money), currency(money))
post = {}
post[:token] = token
post[:commerce] = commerce.to_i
post[:commerce_branch] = commerce_branch.to_i
post[:shop_process_id] = shop_process_id
add_invoice(post, money, options)
add_customer_data(post, options)
post[:origin_shop_process_id] = original_shop_process_id || options[:original_shop_process_id]
commit(:refund, post)
end
|
#remove_invalid_utf_8_byte_sequences(transcript) ⇒ Object
113
114
115
|
# File 'lib/active_merchant/billing/gateways/vpos.rb', line 113
def remove_invalid_utf_8_byte_sequences(transcript)
transcript.encode('UTF-8', 'binary', undef: :replace, replace: '')
end
|
#scrub(transcript) ⇒ Object
106
107
108
109
110
111
|
# File 'lib/active_merchant/billing/gateways/vpos.rb', line 106
def scrub(transcript)
clean_transcript = remove_invalid_utf_8_byte_sequences(transcript)
clean_transcript.
gsub(/(token\\":\\")[.\-\w]+/, '\1[FILTERED]').
gsub(/(card_encrypted_data\\":\\")[.\-\w]+/, '\1[FILTERED]')
end
|
#supports_scrubbing? ⇒ Boolean
102
103
104
|
# File 'lib/active_merchant/billing/gateways/vpos.rb', line 102
def supports_scrubbing?
true
end
|
#void(authorization, options = {}) ⇒ Object
56
57
58
59
60
61
62
63
64
|
# File 'lib/active_merchant/billing/gateways/vpos.rb', line 56
def void(authorization, options = {})
_, shop_process_id = authorization.to_s.split('#')
token = generate_token(shop_process_id, 'rollback', '0.00')
post = {
token: token,
shop_process_id: shop_process_id
}
commit(:pci_buy_rollback, post)
end
|