spree_vpago 2.0.8.pre.beta → 2.0.8.pre.beta3
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 +4 -4
- data/Gemfile.lock +1 -1
- data/app/controllers/spree/vpago_payments_controller.rb +7 -1
- data/app/models/spree/gateway/true_money.rb +7 -7
- data/app/models/vpago/payment_decorator.rb +7 -2
- data/app/serializers/spree/v2/storefront/payment_serializer_decorator.rb +1 -1
- data/app/services/vpago/payment_processable.rb +1 -1
- data/app/services/vpago/payment_url_constructor.rb +13 -3
- data/app/services/vpago/rsa_handler.rb +1 -1
- data/app/views/spree/vpago_payments/forms/spree/gateway/_true_money.html.erb +3 -6
- data/lib/spree_vpago/version.rb +1 -1
- data/lib/vpago/true_money/base.rb +2 -2
- data/lib/vpago/true_money/checkout.rb +16 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a60df6ffc7539631a90fd4076f856cb62517d0c589a6f0bb18f9e109e4708dc5
|
4
|
+
data.tar.gz: 572c3179370f5ddc763cfffe3a4cbbce054537b0a26620c7e4e9041e2e5b14bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb331771b411e9b54d85d2810d4849e18574c5155a878922730014a0618393b27392d167c3596471e3322a32b12b111c8eda97718955675c72450d1ffee02a46
|
7
|
+
data.tar.gz: 89f4e3adbb4a08772e0b32a584a412934b6697d9b96a92da2af2904ada71233f481886b50a9c863a98eea5015d41d969376b61e8af499a5be84938d318481b7a
|
data/Gemfile.lock
CHANGED
@@ -5,7 +5,7 @@ module Spree
|
|
5
5
|
|
6
6
|
skip_before_action :verify_authenticity_token, only: [:process_payment]
|
7
7
|
|
8
|
-
rescue_from ActiveRecord::RecordNotFound, with: :
|
8
|
+
rescue_from ActiveRecord::RecordNotFound, with: :render_not_found
|
9
9
|
rescue_from CanCan::AccessDenied, with: :access_denied
|
10
10
|
|
11
11
|
# GET
|
@@ -33,6 +33,12 @@ module Spree
|
|
33
33
|
|
34
34
|
@order = @payment.order
|
35
35
|
raise CanCan::AccessDenied unless @order.completed?
|
36
|
+
|
37
|
+
if params[:offsite_payment].present?
|
38
|
+
redirect_to @payment.payment_url, allow_other_host: true
|
39
|
+
else
|
40
|
+
render :success
|
41
|
+
end
|
36
42
|
end
|
37
43
|
|
38
44
|
# POST
|
@@ -8,8 +8,8 @@ module Spree
|
|
8
8
|
preference :client_id, :string
|
9
9
|
preference :client_secret, :string
|
10
10
|
preference :private_key, :text
|
11
|
-
preference :
|
12
|
-
preference :
|
11
|
+
preference :return_url_scheme, :string
|
12
|
+
preference :android_package_name, :string
|
13
13
|
|
14
14
|
def method_type
|
15
15
|
'true_money'
|
@@ -55,12 +55,12 @@ module Spree
|
|
55
55
|
success, params[:refund_response] = true_money_refund(payment)
|
56
56
|
|
57
57
|
if success
|
58
|
-
ActiveMerchant::Billing::Response.new(true, '
|
58
|
+
ActiveMerchant::Billing::Response.new(true, 'True money Gateway: successfully canceled.', params)
|
59
59
|
else
|
60
|
-
ActiveMerchant::Billing::Response.new(false, '
|
60
|
+
ActiveMerchant::Billing::Response.new(false, 'True money Gateway: Failed to canceleed', params)
|
61
61
|
end
|
62
62
|
else
|
63
|
-
ActiveMerchant::Billing::Response.new(true, '
|
63
|
+
ActiveMerchant::Billing::Response.new(true, 'True money Gateway: Payment has been voided.')
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -68,12 +68,12 @@ module Spree
|
|
68
68
|
refund_issuer = Vpago::TrueMoney::RefundIssuer.new(payment, {})
|
69
69
|
refund_issuer.call
|
70
70
|
|
71
|
-
[refund_issuer.success?, refund_issuer.
|
71
|
+
[refund_issuer.success?, refund_issuer.parsed_response]
|
72
72
|
end
|
73
73
|
|
74
74
|
def cancel(_response_code, _payment)
|
75
75
|
# we can use this to send request to payment gateway api to cancel the payment ( void )
|
76
|
-
# currently
|
76
|
+
# currently True money does not support to cancel the gateway
|
77
77
|
|
78
78
|
# in our case don't do anything
|
79
79
|
ActiveMerchant::Billing::Response.new(true, '')
|
@@ -5,10 +5,12 @@ module Vpago
|
|
5
5
|
base.after_create -> { Vpago::PayoutsGenerator.new(self).call }, if: :should_generate_payouts?
|
6
6
|
|
7
7
|
base.delegate :checkout_url,
|
8
|
+
:web_checkout_url,
|
8
9
|
:processing_url,
|
10
|
+
:processing_deeplink_url,
|
9
11
|
:success_url,
|
10
12
|
:process_payment_url,
|
11
|
-
:
|
13
|
+
:payment_url,
|
12
14
|
to: :url_constructor
|
13
15
|
end
|
14
16
|
|
@@ -57,10 +59,13 @@ module Vpago
|
|
57
59
|
pre_auth_status == 'CANCELLED'
|
58
60
|
end
|
59
61
|
|
62
|
+
def true_money_payment?
|
63
|
+
payment_method.type_true_money?
|
64
|
+
end
|
65
|
+
|
60
66
|
def vattanac_mini_app_payment?
|
61
67
|
payment_method.type_vattanac_mini_app?
|
62
68
|
end
|
63
|
-
|
64
69
|
end
|
65
70
|
end
|
66
71
|
|
@@ -3,7 +3,7 @@ module Spree
|
|
3
3
|
module Storefront
|
4
4
|
module PaymentSerializerDecorator
|
5
5
|
def self.prepended(base)
|
6
|
-
base.attributes :pre_auth_status, :checkout_url, :process_payment_url
|
6
|
+
base.attributes :pre_auth_status, :checkout_url, :process_payment_url, :web_checkout_url
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
@@ -16,7 +16,7 @@ module Vpago
|
|
16
16
|
# 2. Pre-auth is enabled, ensuring funds can be released to user if processing fails.
|
17
17
|
# PaymentProcessor is usually called after payment is made, so canceling pre-auth typically works.
|
18
18
|
def can_cancel_pre_auth?
|
19
|
-
@payment.pending? || @payment.payment_method.enable_pre_auth? || @payment.vattanac_mini_app_payment?
|
19
|
+
@payment.pending? || @payment.payment_method.enable_pre_auth? || @payment.vattanac_mini_app_payment? || @payment.true_money_payment?
|
20
20
|
end
|
21
21
|
|
22
22
|
def extract_completer_failure_reason_code(error)
|
@@ -10,14 +10,24 @@ module Vpago
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def checkout_url = "#{base_url}/vpago_payments/checkout?#{query}"
|
13
|
+
def web_checkout_url = "#{base_url}/vpago_payments/checkout?#{query}&platform=web"
|
13
14
|
def processing_url = "#{base_url}/vpago_payments/processing?#{query}"
|
15
|
+
def processing_deeplink_url = "#{@payment.payment_method.preferred_return_url_scheme}/vpago_payments/processing?#{query}"
|
14
16
|
def success_url = "#{base_url}/vpago_payments/success?#{query}"
|
15
17
|
def process_payment_url = "#{base_url}/vpago_payments/process_payment?#{query}"
|
16
|
-
|
17
|
-
def processing_app_url = "#{@payment.payment_method.preferred_merchant_scheme}/vpago_payments/processing?#{query}"
|
18
|
+
def payment_url = "#{base_url}/book/payment?number=#{@payment.order.number}&tk=#{@payment.order.token}"
|
18
19
|
|
19
20
|
def query
|
20
|
-
{
|
21
|
+
{
|
22
|
+
payment_number: payment.number,
|
23
|
+
order_number: order.number,
|
24
|
+
order_jwt_token: order_jwt_token,
|
25
|
+
offsite_payment: offsite_payment? ? true : nil
|
26
|
+
}.compact.to_query
|
27
|
+
end
|
28
|
+
|
29
|
+
def offsite_payment?
|
30
|
+
payment.payment_method.type_true_money?
|
21
31
|
end
|
22
32
|
|
23
33
|
private
|
@@ -1,12 +1,9 @@
|
|
1
1
|
<% @checkout = ::Vpago::TrueMoney::Checkout.new(@payment) %>
|
2
|
-
<%
|
2
|
+
<% redirect_url = @checkout.generate_payment_urls(params[:platform])%>
|
3
3
|
|
4
|
-
<% if webview_url.present? %>
|
5
4
|
<script>
|
6
5
|
document.addEventListener("DOMContentLoaded", function () {
|
7
|
-
window.location.href = "<%= j
|
6
|
+
window.top.location.href = "<%= j redirect_url %>";
|
8
7
|
});
|
9
8
|
</script>
|
10
|
-
|
11
|
-
<p>Unable to generate the payment URL. Please try again.</p>
|
12
|
-
<% end %>
|
9
|
+
|
data/lib/spree_vpago/version.rb
CHANGED
@@ -85,8 +85,8 @@ module Vpago
|
|
85
85
|
payment_method.preferred_access_token_url
|
86
86
|
end
|
87
87
|
|
88
|
-
def
|
89
|
-
payment_method.
|
88
|
+
def android_package_name
|
89
|
+
payment_method.preferred_android_package_name
|
90
90
|
end
|
91
91
|
|
92
92
|
def parse_json(body)
|
@@ -1,25 +1,27 @@
|
|
1
1
|
module Vpago
|
2
2
|
module TrueMoney
|
3
3
|
class Checkout < Base
|
4
|
-
def generate_payment_urls
|
4
|
+
def generate_payment_urls(platform)
|
5
|
+
redirection_type = platform == 'web' ? 'web_redirect' : 'mobileapp'
|
6
|
+
|
7
|
+
request_body = {
|
8
|
+
payment_info: payload.to_json,
|
9
|
+
redirectionType: redirection_type,
|
10
|
+
merchantDeepLink: @payment.processing_deeplink_url,
|
11
|
+
merchantAndroidPackageName: android_package_name,
|
12
|
+
refererLink: @payment.processing_url
|
13
|
+
}
|
14
|
+
|
5
15
|
response = Faraday.post(generate_payment_url) do |req|
|
6
16
|
req.headers = default_headers
|
7
|
-
req.body =
|
8
|
-
payment_info: payload.to_json,
|
9
|
-
redirectionType: 'mobileapp',
|
10
|
-
merchantDeepLink: @payment.processing_app_url,
|
11
|
-
merchantAndroidPackageName: merchant_android_package_name
|
12
|
-
}.to_json
|
17
|
+
req.body = request_body.to_json
|
13
18
|
end
|
14
19
|
|
15
20
|
body = parse_json(response.body)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
webview: body['data']['webview'],
|
21
|
-
deeplink: body['data']['deeplink']
|
22
|
-
}
|
21
|
+
platform == 'web' ? body['data']['webview'] : body['data']['deeplink']
|
22
|
+
rescue Faraday::Error, JSON::ParserError, NoMethodError => e
|
23
|
+
Rails.logger.error("Failed to generate payment URL: #{e.class} - #{e.message}")
|
24
|
+
raise
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_vpago
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.8.pre.
|
4
|
+
version: 2.0.8.pre.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- You
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-07-
|
11
|
+
date: 2025-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|