effective_orders 6.32.1 → 6.32.2

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
2
  SHA256:
3
- metadata.gz: 1a4fa010c99844c3b5f27e6cb56ee768dca109db8571c374ec9e821eea404ea3
4
- data.tar.gz: b81744573b5b6067e419813f0a8d89c0cf352d4bf269421d7cbb0bef2daaae63
3
+ metadata.gz: 0f51ea548ef96074bb66ede0cf1656b1ccf4ac73b810a1b5d41dc84f61ff3d78
4
+ data.tar.gz: b884d8b50d14ecb6d55f199003c58a903ee9a086b32c65e0fc00ccb1868edbed
5
5
  SHA512:
6
- metadata.gz: 6a06fa4df6b658f3709e9bbfa15ba9f223bfbc10d9239becd6859b247e9fa378a607dcb6f3fa9609c9b89e8e71956ccdd62adcc9ffcf200100ff0e9c3dab2f2f
7
- data.tar.gz: b1de2ae9a22e26705be7a8631c01620fdae063faf3658d15d99f5faa172f104d43163f3f43d652705be20ac3ded5f36ca4e52a9f748cb6b148b0b27c9fda4891
6
+ metadata.gz: 5e8bcb7e9b5d3b9b4eb54d673db566630a125f6fd7224670d56d7094d347035be79d9a74e299b3028e1daec994d80577996c9ec6d7da3e1b91de9720518cf9e0
7
+ data.tar.gz: 18426d89a198672f566a65be9b82db09ed2131f41d2cc01a3a6581b75ad39df5dec195c411a2d6bf50517a700935d416f0beabba67a419ea126813efcdb68270
@@ -32,13 +32,21 @@ function helcimPayIframeEvent(event) {
32
32
  window.removeEventListener('message', helcimPayIframeEvent, false);
33
33
 
34
34
  let payment = btoa(event.data.eventMessage);
35
-
35
+
36
36
  let $form = $('form[data-helcim-checkout]').first();
37
37
  $form.find('input[name="helcim[payment]"]').val(payment);
38
38
  $form.submit();
39
-
39
+
40
40
  $('#helcimCheckout').fadeOut('slow');
41
41
  $('#helcim-checkout-loading').text('Thank you! Processing payment information. Please wait...');
42
42
  }
43
+
44
+ if(event.data.eventStatus == 'ABORTED') {
45
+ let payment = btoa(event.data.eventMessage);
46
+
47
+ let $form = $('form[data-helcim-checkout]').first();
48
+ $form.find('input[name="helcim[payment]"]').val(payment);
49
+ $form.submit();
50
+ }
43
51
  }
44
52
  };
@@ -17,6 +17,12 @@ module Effective
17
17
  # Decode the payment payload
18
18
  payment_payload = api.decode_payment_payload(helcim_params[:payment])
19
19
 
20
+ # Check for a declined payment payload
21
+ if payment_payload == :declined
22
+ return order_declined(payment: {}, provider: 'helcim', card: nil, declined_url: helcim_params[:declined_url])
23
+ end
24
+
25
+ # Check for an unexpected payment payload
20
26
  if payment_payload.blank?
21
27
  flash[:danger] = 'Unable to process helcim order without payment. please try again.'
22
28
  return order_not_processed(declined_url: helcim_params[:declined_url])
@@ -1,5 +1,7 @@
1
1
  # https://devdocs.helcim.com/docs/overview-of-helcimpayjs
2
2
  # Effective::HelcimApi.new.health_check
3
+ # use card 4242, expiry 01/28, CVV 209 for a general decline
4
+
3
5
  module Effective
4
6
  class HelcimApi
5
7
  # All required
@@ -134,12 +136,22 @@ module Effective
134
136
  # "invoiceNumber"=>"#26-1760118464",
135
137
  # "customerCode"=>"CST0000"}
136
138
 
139
+ # When the payment is aborted, the decoded payload is a string with the error
140
+ # "HelcimPay.js transaction aborted - \"Transaction declined. DECLINED - Do Not Honor\"
141
+
137
142
  def decode_payment_payload(payload)
138
143
  return if payload.blank?
139
144
  raise('expected a string') unless payload.kind_of?(String)
140
145
 
141
- payment = (JSON.parse(Base64.decode64(payload)) rescue nil)
142
- raise('expected payment to be a Hash') unless payment.kind_of?(Hash)
146
+ decoded = (Base64.decode64(payload) rescue nil)
147
+ payment = (JSON.parse(decoded) rescue nil)
148
+
149
+ if payment.blank? && decoded.to_s.downcase.include?('declined')
150
+ return :declined
151
+ end
152
+
153
+ raise('expected payment to be a Hash') unless payment.kind_of?(Hash) || payment.blank?
154
+ return payment if payment.blank?
143
155
 
144
156
  payment = payment.dig('data', 'data')
145
157
  raise('expected payment data') unless payment.kind_of?(Hash)
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '6.32.1'.freeze
2
+ VERSION = '6.32.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.32.1
4
+ version: 6.32.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect