ruby-gpwebpay 0.1.0 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd62ae0dcdc32dd0a8f31f7010d9583e895ebf91db3fb2b287c37fef21b7f9b9
4
- data.tar.gz: c6a4bb0a3ba295ab25e947a61a94db8928d08d3c5ffa0ffede7cdad832ae64f1
3
+ metadata.gz: 1792faa9020776a63e8e2c1ac0627409d877bdee1bbdec3b7ac807be222a85d7
4
+ data.tar.gz: 7287f8a204b434f02b465c3ccabc394a9c3a0084a6ade9bf959bb6fe76cd9e7d
5
5
  SHA512:
6
- metadata.gz: 011060e88a5dbaf8cf6bf919e985d99c11914fee36d98d31c5f6a4b35c28bb73254c3fb0123f18c4434def9abf629b04e5ccb451bbb1b13af806a35a0d0e69ac
7
- data.tar.gz: 22d6f3eca73020be4c8bcb094903338ececba81a77b8f8e26ac081e109d480de1f9524a72df75fa7c4f1ec7fa82a1cc1abe3988932122b9f480cc8d976960a36
6
+ metadata.gz: e655b1c79712a6a12da62451fdb239e242dc5b29fc90b35db94de4a6d474aa6b4eff02e4c43bafe168dbd98bfe52dd620c1d8661f1055dcdeae8d6c04d0a67ec
7
+ data.tar.gz: f7b9d913cac4c2ddc2a2a11fba64fe65788e56c6f9b8130f39bcf6e15ac6fac3191c2fe0198376ee2fa16628e435db1f13bbc7a7e4e30a4540595eec22eeaec3
@@ -25,6 +25,7 @@ module GpWebpay
25
25
  config_accessor :environment do
26
26
  defined?(Rails) && Rails.env || "test"
27
27
  end
28
+ config_accessor :debug do false; end
28
29
 
29
30
  def param_name
30
31
  config.param_name.respond_to?(:call) ? config.param_name.call : config.param_name
@@ -43,7 +43,7 @@ module GpWebpay
43
43
  private
44
44
 
45
45
  def pay_verification_attrs
46
- %i(operation order_number prcode srcode resulttext)
46
+ %i(OPERATION ORDERNUMBER PRCODE SRCODE RESULTTEXT)
47
47
  end
48
48
 
49
49
  def pay_attributes
@@ -6,7 +6,7 @@ module GpWebpay
6
6
  @payment_attributes = payment_attributes
7
7
  GpWebpay.logger.info "Payment Attrs: #{@payment_attributes}"
8
8
  @verification_attrs = verification_attrs
9
- GpWebpay.logger.info "Verification Attrs: #{@verification_attrs}"
9
+ GpWebpay.logger.info "Verification Attrs: #{@verification_attrs}" if @verification_attrs
10
10
  end
11
11
 
12
12
  def verified_response?(params)
@@ -1,3 +1,3 @@
1
1
  module GpWebpay
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -9,6 +9,7 @@ module GpWebpay
9
9
  extend ActiveSupport::Concern
10
10
 
11
11
  def send_request(request_xml)
12
+ GpWebpay.logger.debug "WS Raw request: #{request_xml}" if GpWebpay.config.debug
12
13
  request = Curl::Easy.new(config.web_services_url)
13
14
  request.headers["Content-Type"] = "text/xml;charset=UTF-8"
14
15
  request.http_post(request_xml)
@@ -30,24 +31,28 @@ module GpWebpay
30
31
  def ws_process_regular_subscription_payment
31
32
  attributes = request_attributes("processRegularSubscriptionPayment")
32
33
  raw_response = send_request(template.process_regular_subscription_payment(attributes)).body_str
34
+ GpWebpay.logger.debug "WS Raw response: #{raw_response}" if GpWebpay.config.debug
33
35
  get_params_from(raw_response)
34
36
  end
35
37
 
36
38
  def ws_get_payment_detail
37
39
  attributes = request_attributes("getPaymentDetail")
38
40
  raw_response = send_request(template.get_payment_detail(attributes)).body_str
41
+ GpWebpay.logger.debug "WS Raw response: #{raw_response}" if GpWebpay.config.debug
39
42
  get_params_from(raw_response)
40
43
  end
41
44
 
42
45
  def ws_get_payment_status
43
46
  attributes = request_attributes("getPaymentStatus")
44
47
  raw_response = send_request(template.get_payment_status(attributes)).body_str
48
+ GpWebpay.logger.debug "WS Raw response: #{raw_response}" if GpWebpay.config.debug
45
49
  get_params_from(raw_response)
46
50
  end
47
51
 
48
52
  def ws_get_master_payment_status
49
53
  attributes = request_attributes("getMasterPaymentStatus")
50
54
  raw_response = send_request(template.get_master_payment_status(attributes)).body_str
55
+ GpWebpay.logger.debug "WS Raw response: #{raw_response}" if GpWebpay.config.debug
51
56
  get_params_from(raw_response)
52
57
  end
53
58
 
@@ -71,39 +76,49 @@ module GpWebpay
71
76
  hash_response = hash_response["#{first_lvl_key}"]
72
77
  second_lvl_key = hash_response.keys.last
73
78
  hash_response = hash_response["#{second_lvl_key}"]
79
+ GpWebpay.logger.info "Response: #{hash_response}"
74
80
  GpWebpay::WebServices::Response.new(hash_response)
75
81
  end
76
82
 
77
83
  def request_attributes(type = "")
78
- {
84
+ base_attributes = {
79
85
  message_id: message_id(type),
80
86
  merchant_number: config.merchant_number,
81
87
  order_number: order_number,
82
- merchant_order_number: merchant_order_number,
83
- master_order_number: master_order_number,
84
- amount: amount_in_cents,
85
- capture_flag: capture_flag,
86
- card_holder_name: card_holder.name,
87
- card_holder_email: card_holder.email,
88
- card_holder_phone_country: card_holder.phone_country,
89
- card_holder_phone: card_holder.phone,
90
- card_holder_mobile_phone_country: card_holder.mobile_phone_country,
91
- card_holder_mobile_phone: card_holder.mobile_phone,
92
- address_match: address_match,
93
- billing_name: billing.name,
94
- billing_address1: billing.address1,
95
- billing_city: billing.city,
96
- billing_postal_code: billing.postal_code,
97
- billing_country: billing.country,
98
- shipping_name: shipping.name,
99
- shipping_address1: shipping.address1,
100
- shipping_city: shipping.city,
101
- shipping_postal_code: shipping.postal_code,
102
- shipping_country: shipping.country,
103
88
  digest: ws_verification(type).digest,
104
- # Deprecated Attrs, will remove
105
- currency: currency,
106
89
  }
90
+
91
+ case type
92
+ when "processRegularSubscriptionPayment"
93
+ payment_attributes = {
94
+ merchant_order_number: merchant_order_number,
95
+ master_order_number: master_order_number,
96
+ amount: amount_in_cents,
97
+ capture_flag: capture_flag,
98
+ card_holder_name: card_holder.name,
99
+ card_holder_email: card_holder.email,
100
+ card_holder_phone_country: card_holder.phone_country,
101
+ card_holder_phone: card_holder.phone,
102
+ card_holder_mobile_phone_country: card_holder.mobile_phone_country,
103
+ card_holder_mobile_phone: card_holder.mobile_phone,
104
+ address_match: address_match,
105
+ billing_name: billing.name,
106
+ billing_address1: billing.address1,
107
+ billing_city: billing.city,
108
+ billing_postal_code: billing.postal_code,
109
+ billing_country: billing.country,
110
+ shipping_name: shipping.name,
111
+ shipping_address1: shipping.address1,
112
+ shipping_city: shipping.city,
113
+ shipping_postal_code: shipping.postal_code,
114
+ shipping_country: shipping.country,
115
+ # Deprecated Attrs, will remove
116
+ currency: currency,
117
+ }
118
+ base_attributes.merge(payment_attributes)
119
+ else
120
+ base_attributes
121
+ end
107
122
  end
108
123
 
109
124
  def config
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-gpwebpay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrej Antas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-07 00:00:00.000000000 Z
11
+ date: 2021-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport