spree_vpago 2.2.2.pre.pre16 → 2.2.2.pre.pre17

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: c069c6d08d71cab3036cd97f94c053b4b633219c8a9919646bc2782dfa2fde03
4
- data.tar.gz: 5ae430280310306aa6622d08161730d00d5058456b934602893684d5670167a9
3
+ metadata.gz: a41c53551544436fc2973a85d085bf8dd9712ebd84ae9d6b8d820ffeeea6d5b2
4
+ data.tar.gz: e0141d5b5968a647843616bfcea9a458c2805215cc78bc3651a999565bed6a59
5
5
  SHA512:
6
- metadata.gz: 4c500caadeaf75c7d1eb2f50a6d39e0b78cb28f11a3c5fc4d28e2f9da4acd2e03b7a8296cbb506069edcdde2a42b64a208c74ac038101d3297329bbbb29c3dd4
7
- data.tar.gz: 0c955a9832cb835c05cd9da3fea7271fb9991eb7ef8f784954a6e20173feb188d23449b62c6fea60bc2a796c9de52a0065237cd0a7cadd52c5634aba2b340e1f
6
+ metadata.gz: dc3468dcff8511b38149ec840b73c09ed669c0347d0daa84956983edde8b8e4470f23825efc5e662424f6057d008f5ca788623a580cd21f45f3ab726923638a8
7
+ data.tar.gz: 9ed4fe39e71672992963611effb80f9e781b24b677a9ac040de0b75cf56762d2e210a3c60abde7e3e69a838816715d7969412a92db588de3cf543eba81a39cd2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spree_vpago (2.2.2.pre.pre16)
4
+ spree_vpago (2.2.2.pre.pre17)
5
5
  faraday
6
6
  google-cloud-firestore
7
7
  spree_api (>= 4.5)
@@ -16,15 +16,29 @@ module Vpago
16
16
  # when return nil, each payment method should use their default URL.
17
17
  # eg. PayWayV2 will use the continue_success_url as deeplink back URL.
18
18
  def custom_return_deeplink_url
19
- user_agent = request.user_agent.to_s.downcase
20
-
21
- if user_agent.include?('telegram')
19
+ if telegram_user_agent?
22
20
  'tg://'
23
- elsif user_agent.include?('fban') || user_agent.include?('facebook')
21
+ elsif facebook_user_agent?
24
22
  'fb://'
25
- elsif user_agent.include?('messenger')
23
+ elsif messenger_user_agent?
26
24
  'fb-messenger://'
27
25
  end
28
26
  end
27
+
28
+ def mobile_user_agent?
29
+ request.user_agent.to_s.downcase.match?(/android|iphone|ipad|ipod/)
30
+ end
31
+
32
+ def telegram_user_agent?
33
+ request.user_agent.to_s.downcase.include?('telegram')
34
+ end
35
+
36
+ def facebook_user_agent?
37
+ request.user_agent.to_s.downcase.include?('fban') || request.user_agent.to_s.downcase.include?('facebook')
38
+ end
39
+
40
+ def messenger_user_agent?
41
+ request.user_agent.to_s.downcase.include?('messenger')
42
+ end
29
43
  end
30
44
  end
@@ -8,22 +8,29 @@
8
8
  </form>
9
9
 
10
10
  <script>
11
+ const isTelegram = <%= telegram_user_agent? %>;
12
+ const isMobile = <%= mobile_user_agent? %>;
13
+
11
14
  const abapayKhqrDeeplink = "<%= @payment.payment_method.abapay_khqr_deeplink? %>";
12
- const shouldOpenAbaPayDeeplink = <%= @payment.payment_method.open_abapay_deeplink? %>;
15
+ const shouldOpenAbaPayDeeplink = isMobile && <%= @payment.payment_method.open_abapay_deeplink? %>;
13
16
  const shouldOpenCheckoutUrl = <%= @payment.payment_method.open_checkout_url? %>;
14
17
 
15
- function isMobile() {
16
- return /Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
18
+ function openDeeplink(abapay_deeplink) {
19
+ if(isTelegram){
20
+ window.open(abapay_deeplink, '_blank');
21
+ } else {
22
+ window.location.href = abapay_deeplink;
23
+ }
17
24
  }
18
25
 
19
26
  function openAbapayDeeplink(abapay_deeplink) {
20
27
  document.getElementById("vpago_primary_button").style.display = "block";
21
28
  document.getElementById("vpago_primary_button").innerText = "Open ABA Pay";
22
29
  document.getElementById("vpago_primary_button").addEventListener("click", function() {
23
- window.open(abapay_deeplink, "_blank");
30
+ openDeeplink(abapay_deeplink)
24
31
  });
25
32
 
26
- window.open(abapay_deeplink, "_blank");
33
+ openDeeplink(abapay_deeplink)
27
34
  }
28
35
 
29
36
  function openCheckoutUrl(checkout_qr_url, delay = 0) {
@@ -57,7 +64,7 @@
57
64
  }
58
65
 
59
66
  if (data.checkout_qr_url && shouldOpenCheckoutUrl) {
60
- openCheckoutUrl(data.checkout_qr_url, shouldDelayBeforeOpenCheckoutUrl ? 3000 : 0);
67
+ openCheckoutUrl(data.checkout_qr_url, shouldDelayBeforeOpenCheckoutUrl ? 500 : 0);
61
68
  }
62
69
  })
63
70
  .catch(function(error) {
@@ -1,7 +1,7 @@
1
1
  module SpreeVpago
2
2
  module_function
3
3
 
4
- VERSION = '2.2.2-pre16'.freeze
4
+ VERSION = '2.2.2-pre17'.freeze
5
5
 
6
6
  def version
7
7
  Gem::Version.new VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_vpago
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2.pre.pre16
4
+ version: 2.2.2.pre.pre17
5
5
  platform: ruby
6
6
  authors:
7
7
  - You