workarea-payware_connect 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +20 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
- data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/workflows/ci.yml +54 -0
- data/.gitignore +13 -0
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +63 -0
- data/CODE_OF_CONDUCT.md +3 -0
- data/CONTRIBUTING.md +3 -0
- data/Gemfile +9 -0
- data/LICENSE.md +3 -0
- data/README.md +53 -0
- data/Rakefile +54 -0
- data/app/models/workarea/payment/authorize/credit_card.decorator +37 -0
- data/app/models/workarea/payment/capture/credit_card.decorator +14 -0
- data/app/models/workarea/payment/payware_credit_card.decorator +24 -0
- data/app/models/workarea/payment/purchase/credit_card.decorator +37 -0
- data/app/models/workarea/payment/refund/credit_card.decorator +14 -0
- data/app/models/workarea/payment/store_credit_card.decorator +13 -0
- data/app/workers/workarea/save_user_order_details.decorator +33 -0
- data/bin/rails +18 -0
- data/config/initializers/00_defaults.rb +1 -0
- data/doc/PWCTestAccount_WorldPay ecom.pages +0 -0
- data/doc/validation/(Completed v2)PAYware Connect Validation Worksheet 2015 V2 .doc +0 -0
- data/doc/validation/(Completed v3)PAYware Connect Validation Worksheet 2015 V2 .doc +0 -0
- data/doc/validation/PAYware Connect Validation Letter Weblinc 09-11-2015.pdf +0 -0
- data/doc/validation/PAYware Connect Validation Letter Weblinc 10-21-2015.pdf +0 -0
- data/lib/active_merchant/billing/bogus_payware_connect_gateway.rb +130 -0
- data/lib/active_merchant/billing/payware_connect_gateway.rb +137 -0
- data/lib/active_merchant/billing/payware_connect_gateway/actions/authorize.rb +63 -0
- data/lib/active_merchant/billing/payware_connect_gateway/actions/capture.rb +26 -0
- data/lib/active_merchant/billing/payware_connect_gateway/actions/purchase.rb +59 -0
- data/lib/active_merchant/billing/payware_connect_gateway/actions/refund.rb +29 -0
- data/lib/active_merchant/billing/payware_connect_gateway/actions/void.rb +20 -0
- data/lib/active_merchant/billing/payware_connect_gateway/admin_actions/add_contract.rb +9 -0
- data/lib/active_merchant/billing/payware_connect_gateway/admin_actions/add_customer.rb +9 -0
- data/lib/active_merchant/billing/payware_connect_gateway/admin_actions/add_customer_and_contract.rb +10 -0
- data/lib/active_merchant/billing/payware_connect_gateway/admin_actions/update_contract.rb +9 -0
- data/lib/active_merchant/billing/payware_connect_gateway/admin_actions/update_customer.rb +9 -0
- data/lib/active_merchant/billing/payware_connect_gateway/admin_xml_builder.rb +105 -0
- data/lib/active_merchant/billing/payware_connect_gateway/xml_builder.rb +35 -0
- data/lib/active_merchant/billing/payware_response.rb +9 -0
- data/lib/validation.rb +25 -0
- data/lib/workarea/payware_connect.rb +43 -0
- data/lib/workarea/payware_connect/engine.rb +8 -0
- data/lib/workarea/payware_connect/version.rb +5 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/config/manifest.js +4 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/jobs/application_job.rb +2 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +34 -0
- data/test/dummy/bin/update +29 -0
- data/test/dummy/config.ru +5 -0
- data/test/dummy/config/application.rb +24 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +9 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +56 -0
- data/test/dummy/config/environments/production.rb +86 -0
- data/test/dummy/config/environments/test.rb +44 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/new_framework_defaults.rb +23 -0
- data/test/dummy/config/initializers/workarea.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/puma.rb +47 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/db/seeds.rb +3 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/test/dummy/public/apple-touch-icon.png +0 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/integration/workarea/storefront/checkout_side_effects_integration_test.decorator +44 -0
- data/test/lib/active_merchant/billing/payware_connect_gateway_test.rb +280 -0
- data/test/models/workarea/payment/authorize/credit_card_test.decorator +47 -0
- data/test/models/workarea/payment/capture/credit_card_test.decorator +33 -0
- data/test/models/workarea/payment/credit_card_integration_test.decorator +25 -0
- data/test/models/workarea/payment/payware_credit_card_test.rb +44 -0
- data/test/models/workarea/payment/purchase/credit_card_test.decorator +54 -0
- data/test/models/workarea/payment/refund/credit_card_test.decorator +33 -0
- data/test/models/workarea/payment/store_credit_card_test.decorator +10 -0
- data/test/support/workarea/payware_connect_gateway_vcr_config.rb +24 -0
- data/test/system/workarea/admin/payment_transactions_system_test.decorator +37 -0
- data/test/test_helper.rb +12 -0
- data/test/vcr_cassettes/credit_card/auth_capture.yml +127 -0
- data/test/vcr_cassettes/credit_card/auth_void.yml +126 -0
- data/test/vcr_cassettes/credit_card/purchase_void.yml +126 -0
- data/test/vcr_cassettes/credit_card/store_auth.yml +67 -0
- data/test/vcr_cassettes/credit_card/store_purchase.yml +67 -0
- data/test/vcr_cassettes/payware/add_contract.yml +99 -0
- data/test/vcr_cassettes/payware/add_customer.yml +52 -0
- data/test/vcr_cassettes/payware/authorize_credit_card.yml +67 -0
- data/test/vcr_cassettes/payware/authorize_customer_and_contract.yml +161 -0
- data/test/vcr_cassettes/payware/authorize_for_0_credit_card.yml +67 -0
- data/test/vcr_cassettes/payware/authorize_for_0_troutd.yml +130 -0
- data/test/vcr_cassettes/payware/authorize_troutd.yml +130 -0
- data/test/vcr_cassettes/payware/capture.yml +127 -0
- data/test/vcr_cassettes/payware/refund.yml +223 -0
- data/test/vcr_cassettes/payware/refund_troutd.yml +128 -0
- data/test/vcr_cassettes/payware/void_authorization.yml +126 -0
- data/test/workers/workarea/save_user_order_details_test.decorator +56 -0
- data/workarea-payware_connect.gemspec +18 -0
- metadata +190 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
class PaywareConnectGateway < ActiveMerchant::Billing::Gateway
|
4
|
+
module Actions
|
5
|
+
class Capture < PaywareConnectGateway::XMLBuilder
|
6
|
+
attr_reader :cents, :authorization
|
7
|
+
|
8
|
+
def initialize(cents, authorization, merged_options)
|
9
|
+
@cents = cents
|
10
|
+
@authorization = authorization
|
11
|
+
|
12
|
+
super(merged_options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def build
|
16
|
+
build_credit_request do |xml|
|
17
|
+
xml.COMMAND "COMPLETION"
|
18
|
+
xml.TROUTD authorization
|
19
|
+
xml.TRANS_AMOUNT "%.2f" % (cents.to_f / 100.0)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
class PaywareConnectGateway::Actions::Purchase < PaywareConnectGateway::XMLBuilder
|
4
|
+
attr_reader :cents
|
5
|
+
|
6
|
+
def initialize(cents, merged_options)
|
7
|
+
@cents = cents
|
8
|
+
|
9
|
+
super(merged_options)
|
10
|
+
end
|
11
|
+
|
12
|
+
def build
|
13
|
+
build_credit_request do |xml|
|
14
|
+
xml.COMMAND "SALE"
|
15
|
+
xml.TRANS_AMOUNT "%.2f" % (cents.to_f / 100.0)
|
16
|
+
xml.PRESENT_FLAG "1"
|
17
|
+
|
18
|
+
if options[:invoice_number]
|
19
|
+
xml.INVOICE options[:invoice_number]
|
20
|
+
end
|
21
|
+
|
22
|
+
if options[:force]
|
23
|
+
xml.FORCE_FLAG "true"
|
24
|
+
end
|
25
|
+
|
26
|
+
if options[:billing_address]
|
27
|
+
address = options[:billing_address]
|
28
|
+
xml.CARDHOLDER "#{address.first_name} #{address.last_name}"
|
29
|
+
xml.CUSTOMER_STREET address.street[0..19] # max length of this field is 20 characters
|
30
|
+
xml.CUSTOMER_CITY address.city
|
31
|
+
xml.CUSTOMER_STATE address.region
|
32
|
+
xml.CUSTOMER_ZIP address.postal_code
|
33
|
+
end
|
34
|
+
|
35
|
+
if options[:customer_id] && options[:contract_id]
|
36
|
+
xml.RBCUSTOMER_ID options[:customer_id]
|
37
|
+
xml.RBCONTRACT_ID options[:contract_id]
|
38
|
+
|
39
|
+
elsif options[:credit_card]
|
40
|
+
credit_card = options[:credit_card]
|
41
|
+
xml.ACCT_NUM credit_card.number
|
42
|
+
xml.CVV2 credit_card.verification_value
|
43
|
+
|
44
|
+
month = credit_card.month
|
45
|
+
month = month.to_s.rjust(2, "0")
|
46
|
+
xml.EXP_MONTH month
|
47
|
+
xml.EXP_YEAR credit_card.year.to_s[-2, 2] # last two digits of year
|
48
|
+
|
49
|
+
elsif options[:troutd]
|
50
|
+
xml.REF_TROUTD options[:troutd]
|
51
|
+
|
52
|
+
else
|
53
|
+
raise "Purchase requires either 1) customer and contract ids, 2) credit card, 3) troutd from previous authorization"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
class PaywareConnectGateway::Actions::Refund < PaywareConnectGateway::XMLBuilder
|
4
|
+
attr_reader :cents
|
5
|
+
|
6
|
+
def initialize(cents, merged_options)
|
7
|
+
@cents = cents
|
8
|
+
|
9
|
+
super(merged_options)
|
10
|
+
end
|
11
|
+
|
12
|
+
def build
|
13
|
+
build_credit_request do |xml|
|
14
|
+
xml.COMMAND "CREDIT"
|
15
|
+
xml.TRANS_AMOUNT "%.2f" % (cents.to_f / 100.0)
|
16
|
+
|
17
|
+
if options[:customer_id] && options[:contract_id]
|
18
|
+
xml.RBCUSTOMER_ID options[:customer_id]
|
19
|
+
xml.RBCONTRACT_ID options[:contract_id]
|
20
|
+
elsif options[:troutd]
|
21
|
+
xml.TROUTD options[:troutd]
|
22
|
+
else
|
23
|
+
raise "Refund require either 1) customer and contract ids or 2) troutd"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
class PaywareConnectGateway::Actions::Void < PaywareConnectGateway::XMLBuilder
|
4
|
+
attr_reader :authorization
|
5
|
+
|
6
|
+
def initialize(authorization, merged_options)
|
7
|
+
@authorization = authorization
|
8
|
+
|
9
|
+
super(merged_options)
|
10
|
+
end
|
11
|
+
|
12
|
+
def build
|
13
|
+
build_credit_request do |xml|
|
14
|
+
xml.COMMAND "VOID"
|
15
|
+
xml.TROUTD authorization
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module ActiveMerchant::Billing::PaywareConnectGateway::AdminActions
|
2
|
+
class AddContract < ActiveMerchant::Billing::PaywareConnectGateway::AdminXMLBuilder
|
3
|
+
def build
|
4
|
+
build_admin_request("ADDON_NEW_CONTRACT") do |xml|
|
5
|
+
build_contract(xml, options[:customer_id], options[:contract_id], options)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module ActiveMerchant::Billing::PaywareConnectGateway::AdminActions
|
2
|
+
class AddCustomer < ActiveMerchant::Billing::PaywareConnectGateway::AdminXMLBuilder
|
3
|
+
def build
|
4
|
+
build_admin_request("ADDON_NEW_CUSTOMER") do |xml|
|
5
|
+
build_customer(xml, options[:customer_id], options)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
data/lib/active_merchant/billing/payware_connect_gateway/admin_actions/add_customer_and_contract.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
module ActiveMerchant::Billing::PaywareConnectGateway::AdminActions
|
2
|
+
class AddCustomerAndContract < ActiveMerchant::Billing::PaywareConnectGateway::AdminXMLBuilder
|
3
|
+
def build
|
4
|
+
build_admin_request("ADDON_NEW_CUSTOMER_CONTRACT") do |xml|
|
5
|
+
build_customer(xml, options[:customer_id], options)
|
6
|
+
build_contract(xml, nil, options[:contract_id], options)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module ActiveMerchant::Billing::PaywareConnectGateway::AdminActions
|
2
|
+
class UpdateContract < ActiveMerchant::Billing::PaywareConnectGateway::AdminXMLBuilder
|
3
|
+
def build
|
4
|
+
build_admin_request("ADDON_UPDATE_CONTRACT") do |xml|
|
5
|
+
build_contract(xml, options[:customer_id], options[:contract_id], options)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module ActiveMerchant::Billing::PaywareConnectGateway::AdminActions
|
2
|
+
class UpdateCustomer < ActiveMerchant::Billing::PaywareConnectGateway::AdminXMLBuilder
|
3
|
+
def build
|
4
|
+
build_admin_request("ADDON_UPDATE_CUSTOMER") do |xml|
|
5
|
+
build_customer(xml, options[:customer_id], options)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
class ActiveMerchant::Billing::PaywareConnectGateway::AdminXMLBuilder
|
2
|
+
def initialize(merged_options)
|
3
|
+
@client_id = merged_options[:client_id]
|
4
|
+
@merchant_key = merged_options[:merchant_key]
|
5
|
+
@login = merged_options[:login]
|
6
|
+
@password = merged_options[:password]
|
7
|
+
@options = merged_options
|
8
|
+
end
|
9
|
+
|
10
|
+
def build
|
11
|
+
raise NotImplemented
|
12
|
+
end
|
13
|
+
|
14
|
+
def build_customer(xml, customer_id, options)
|
15
|
+
xml.CUSTOMER("Merchant_Customer_ID" => customer_id) do
|
16
|
+
if options[:billing_address]
|
17
|
+
build_address(xml, options)
|
18
|
+
else
|
19
|
+
xml.First_Name options[:first_name]
|
20
|
+
xml.Last_Name options[:last_name]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def build_address(xml, options)
|
26
|
+
address = options[:billing_address]
|
27
|
+
xml.Company_Name address.company
|
28
|
+
xml.First_Name address.first_name
|
29
|
+
xml.Last_Name address.last_name
|
30
|
+
xml.Address_1 address.street
|
31
|
+
xml.Address_2 address.street_2
|
32
|
+
xml.City address.city
|
33
|
+
xml.Zip address.postal_code
|
34
|
+
xml.Pri_Phone address.phone_number
|
35
|
+
xml.Pri_Email options[:email]
|
36
|
+
end
|
37
|
+
|
38
|
+
def build_contract(xml, customer_id, contract_id, options)
|
39
|
+
xml.CONTRACT do
|
40
|
+
xml.Merchant_Customer_ID(customer_id) if customer_id
|
41
|
+
xml.Merchant_Contract_ID(contract_id)
|
42
|
+
|
43
|
+
credit_card = options[:credit_card]
|
44
|
+
build_credit_card(xml, credit_card)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def build_credit_card(xml, credit_card)
|
49
|
+
brand = credit_card.brand.try(:upcase)
|
50
|
+
brand =
|
51
|
+
if brand == "MASTER"
|
52
|
+
"MC"
|
53
|
+
else
|
54
|
+
brand
|
55
|
+
end
|
56
|
+
|
57
|
+
month = credit_card.month
|
58
|
+
month = month.to_s.rjust(2, "0")
|
59
|
+
|
60
|
+
xml.Card_Type brand if brand
|
61
|
+
xml.Pri_Account_Number credit_card.number if credit_card.number.present?
|
62
|
+
xml.Pri_Exp_Month month
|
63
|
+
xml.Pri_Exp_Year credit_card.year.to_s[-2, 2] # last two digits of year
|
64
|
+
xml.fAlt_Payment(false) # "This signals the system to use the alternate card until such time that it is switched to the primary card. This value must be included and defaulted to false"
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
attr_reader :options, :client_id, :merchant_key, :login, :password
|
70
|
+
|
71
|
+
def build_admin_request(command_type)
|
72
|
+
xml = Builder::XmlMarkup.new
|
73
|
+
xml.AdminRequest do
|
74
|
+
build_admin_header(xml, command_type)
|
75
|
+
|
76
|
+
xml.AdminBody do
|
77
|
+
xml.HEADER do
|
78
|
+
build_header(xml)
|
79
|
+
end
|
80
|
+
|
81
|
+
xml.DETAIL do
|
82
|
+
xml.RECORD do
|
83
|
+
yield xml
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
xml.target!
|
89
|
+
end
|
90
|
+
|
91
|
+
def build_admin_header(xml, command_type)
|
92
|
+
xml.AdminHeader do
|
93
|
+
xml.RequestType("IPCRB_ADMIN")
|
94
|
+
xml.FunctionType("ADDON")
|
95
|
+
xml.CommandType(command_type)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def build_header(xml)
|
100
|
+
xml.Client_ID(client_id)
|
101
|
+
xml.MERCHANTKEY(merchant_key)
|
102
|
+
xml.USERID(login)
|
103
|
+
xml.USERPWD(password)
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
class PaywareConnectGateway::XMLBuilder
|
4
|
+
def initialize(merged_options)
|
5
|
+
@client_id = merged_options[:client_id]
|
6
|
+
@merchant_key = merged_options[:merchant_key]
|
7
|
+
@login = merged_options[:login]
|
8
|
+
@password = merged_options[:password]
|
9
|
+
@options = merged_options
|
10
|
+
end
|
11
|
+
|
12
|
+
def build
|
13
|
+
raise NotImplemented
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_reader :options, :client_id, :merchant_key, :login, :password
|
19
|
+
|
20
|
+
def build_credit_request
|
21
|
+
xml = Builder::XmlMarkup.new
|
22
|
+
xml.TRANSACTION do
|
23
|
+
xml.FUNCTION_TYPE "PAYMENT"
|
24
|
+
xml.PAYMENT_TYPE "CREDIT"
|
25
|
+
xml.CLIENT_ID(client_id)
|
26
|
+
xml.MERCHANTKEY(merchant_key)
|
27
|
+
xml.USER_ID(login)
|
28
|
+
xml.USER_PW(password)
|
29
|
+
yield xml
|
30
|
+
end
|
31
|
+
xml.target!
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/validation.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Use these commands in the console to log all of the requests and responses for validation
|
2
|
+
|
3
|
+
gateway = Workarea.config.gateways.credit_card
|
4
|
+
|
5
|
+
card = OpenStruct.new(number: "4111111111111111", verification_value: "900", month: "12", year: "2018")
|
6
|
+
billing_address = OpenStruct.new(first_name: "Mark", last_name: "Platt", street: "916 Bartram Ave.", city: "Collingdale", region: "PA", postal_code: "19023")
|
7
|
+
|
8
|
+
Rails.logger.debug("***Authorize(Void)***")
|
9
|
+
response = gateway.authorize(100.to_m, credit_card: card, billing_address: billing_address)
|
10
|
+
|
11
|
+
Rails.logger.debug("***Void***")
|
12
|
+
gateway.void(response.params["RESPONSE"]["TROUTD"])
|
13
|
+
|
14
|
+
Rails.logger.debug("***Authorize(Capture)***")
|
15
|
+
response = gateway.authorize(101.to_m, credit_card: card, billing_address: billing_address)
|
16
|
+
|
17
|
+
Rails.logger.debug("***Capture***")
|
18
|
+
gateway.capture(101.to_m, response.params["RESPONSE"]["TROUTD"])
|
19
|
+
|
20
|
+
Rails.logger.debug("***Authorize(First)***")
|
21
|
+
gateway.authorize(104.to_m, credit_card: card, billing_address: billing_address, invoice_number: "123")
|
22
|
+
Rails.logger.debug("***Authorize(Dupe)***")
|
23
|
+
gateway.authorize(104.to_m, credit_card: card, billing_address: billing_address, invoice_number: "123")
|
24
|
+
Rails.logger.debug("***Authorize(Force)***")
|
25
|
+
gateway.authorize(104.to_m, credit_card: card, billing_address: billing_address, force: "true", invoice_number: "123")
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "workarea"
|
2
|
+
|
3
|
+
require "workarea/payware_connect/engine"
|
4
|
+
require "workarea/payware_connect/version"
|
5
|
+
|
6
|
+
require "active_merchant/billing/payware_connect_gateway"
|
7
|
+
require "active_merchant/billing/bogus_payware_connect_gateway"
|
8
|
+
|
9
|
+
module Workarea
|
10
|
+
module PaywareConnect
|
11
|
+
def self.auto_configure_gateway
|
12
|
+
secrets = Rails.application.secrets.payware_connect
|
13
|
+
|
14
|
+
if secrets.present?
|
15
|
+
secrets = secrets.deep_symbolize_keys
|
16
|
+
|
17
|
+
self.gateway = ActiveMerchant::Billing::PaywareConnectGateway.new(
|
18
|
+
client_id: secrets[:client_id],
|
19
|
+
login: secrets[:login],
|
20
|
+
password: secrets[:password],
|
21
|
+
merchant_key: secrets[:merchant_key],
|
22
|
+
test: secrets.fetch(:test, true)
|
23
|
+
)
|
24
|
+
else
|
25
|
+
self.gateway = ActiveMerchant::Billing::BogusPaywareConnectGateway.new
|
26
|
+
end
|
27
|
+
|
28
|
+
if ENV["HTTP_PROXY"].present? && gateway.present?
|
29
|
+
parsed = URI.parse(ENV["HTTP_PROXY"])
|
30
|
+
ActiveMerchant::Billing::PaywareConnectGateway.proxy_address = parsed.host
|
31
|
+
ActiveMerchant::Billing::PaywareConnectGateway.proxy_port = parsed.port
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.gateway=(gateway)
|
36
|
+
Workarea.config.gateways.credit_card = gateway
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.gateway
|
40
|
+
Workarea.config.gateways.credit_card
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/test/dummy/Rakefile
ADDED