spree_vpago 2.3.13.pre.pre1 → 2.4.0.pre.pre1
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 +2 -2
- data/app/assets/config/spree_vpago_manifest.js +0 -1
- data/app/controllers/spree/admin/payment_payway_queriers_controller.rb +0 -7
- data/app/controllers/spree/miniapp/acledas_controller.rb +29 -0
- data/app/controllers/spree/vpago_payments_controller.rb +0 -28
- data/app/models/spree/gateway/acleda_mini_app.rb +20 -0
- data/app/models/spree/gateway/payway_v2.rb +0 -6
- data/app/models/spree/gateway/true_money.rb +0 -4
- data/app/models/spree/payment_method/cash_on.rb +0 -7
- data/app/models/vpago/order_decorator.rb +1 -1
- data/app/models/vpago/payment_decorator.rb +4 -1
- data/app/models/vpago/payment_method_decorator.rb +6 -14
- data/app/serializers/spree/v2/storefront/payment_method_serializer_decorator.rb +0 -6
- data/app/services/vpago/acleda_mini_app/session/create.rb +99 -0
- data/app/services/vpago/payment_redirect_handler.rb +6 -6
- data/app/services/vpago/payment_url_constructor.rb +0 -1
- data/app/views/layouts/vpago_payments.html.erb +0 -1
- data/app/views/spree/admin/payments/source_views/_acleda_mini_app.html.erb +6 -0
- data/app/views/spree/admin/payments/source_views/_acleda_v2.html.erb +2 -2
- data/app/views/spree/admin/payments/source_views/_vattanac.html.erb +3 -3
- data/app/views/spree/vpago_payments/forms/spree/gateway/_acleda_mini_app.html.erb +93 -0
- data/app/views/spree/vpago_payments/forms/spree/gateway/_payway_v2.html.erb +42 -35
- data/app/views/spree/vpago_payments/forms/spree/gateway/_true_money.html.erb +15 -15
- data/config/locales/en.yml +0 -1
- data/config/locales/km.yml +0 -1
- data/config/routes.rb +7 -7
- data/lib/spree_vpago/engine.rb +1 -0
- data/lib/spree_vpago/version.rb +1 -1
- data/lib/vpago/acleda_mini_app/checkout.rb +23 -0
- data/lib/vpago/payway_v2/payment_request_updater.rb +0 -5
- data/lib/vpago/payway_v2/transaction_status.rb +0 -2
- data/lib/vpago/payway_v2/transaction_status_v2.rb +0 -2
- data/lib/vpago/true_money/base.rb +1 -1
- data/lib/vpago/true_money/transaction_status.rb +1 -1
- data/lib/vpago/vattanac/base.rb +2 -3
- data/lib/vpago/vattanac/transaction_status.rb +1 -17
- data/lib/vpago/wing_sdk/base.rb +1 -1
- data/spree_vpago.gemspec +1 -1
- metadata +12 -17
- data/app/assets/javascripts/vpago/vpago_payments/create_transaction.js +0 -35
- data/app/controllers/spree/admin/payment_acleda_v2_base_controller.rb +0 -21
- data/app/controllers/spree/admin/payment_acleda_v2_checkers_controller.rb +0 -26
- data/app/controllers/spree/admin/payment_acleda_v2_queriers_controller.rb +0 -38
- data/app/controllers/spree/admin/payment_vattanac_base_controller.rb +0 -21
- data/app/controllers/spree/admin/payment_vattanac_checkers_controller.rb +0 -26
- data/app/controllers/spree/admin/payment_vattanac_queriers_controller.rb +0 -38
- data/lib/vpago/acleda_v2/payment_request_updater.rb +0 -54
- data/lib/vpago/http_timeouts.rb +0 -6
- data/lib/vpago/payway_v2/transaction_creator.rb +0 -29
- data/lib/vpago/vattanac/payment_request_updater.rb +0 -54
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2b281c3ae420620dbd3d1da80ed2bc713c9283292484c1812cd1e9c979e6bf52
|
|
4
|
+
data.tar.gz: 70b7603d37c2c5e8f434e1ab333e622619296fd1ced75642ea9c0512a7591eb1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 718d7eb47ff0a91b7cbcd43d13bd28f4808e008bed9ebee489c913af2d18d5069b5bdc4f06cca8e57693559e96da51a7af8c6e8843e5e01952898c7853c919e1
|
|
7
|
+
data.tar.gz: dd5f68ec20858da961d36f88a488bd3906d0623baa9f88a3811bbe10957ebd93bf891d047df9b2b8123a549d6881ef8ef32e1c7674144e6dd7901c779e79ae8b
|
data/Gemfile.lock
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
spree_vpago (2.
|
|
4
|
+
spree_vpago (2.4.0.pre.pre1)
|
|
5
5
|
faraday
|
|
6
6
|
google-cloud-firestore
|
|
7
7
|
spree_api (>= 4.5)
|
|
8
8
|
spree_backend (>= 4.5)
|
|
9
9
|
spree_core (>= 4.5)
|
|
10
|
-
spree_extension
|
|
10
|
+
spree_extension
|
|
11
11
|
spree_multi_vendor (>= 2.4.1)
|
|
12
12
|
|
|
13
13
|
GEM
|
|
@@ -16,13 +16,6 @@ module Spree
|
|
|
16
16
|
flash[:error] = Spree.t('vpago.payments.payment_not_found_with_error', error: tran_status.error_message)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
redirect_to admin_order_payment_path(order_id: @payment.order.number, id: @payment.number)
|
|
20
|
-
rescue Faraday::TimeoutError, Faraday::ConnectionFailed => e
|
|
21
|
-
VpagoLogger.error(
|
|
22
|
-
label: 'Spree::Admin::PaymentPaywayQueriersController#show gateway_timeout',
|
|
23
|
-
data: { payment_number: @payment.number, error_class: e.class.name, error_message: e.message }
|
|
24
|
-
)
|
|
25
|
-
flash[:error] = Spree.t('vpago.payments.gateway_timeout')
|
|
26
19
|
redirect_to admin_order_payment_path(order_id: @payment.order.number, id: @payment.number)
|
|
27
20
|
end
|
|
28
21
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Miniapp
|
|
3
|
+
# Partner Session Initialization API (ACLEDA Mini App Integration Spec, Step 01).
|
|
4
|
+
# ACLEDA (server-to-server) POSTs { phone, first_name, last_name }; we return a
|
|
5
|
+
# session-based miniAppUrl for ACLEDA to open in the WebView.
|
|
6
|
+
class AcledasController < Spree::Api::V2::BaseController
|
|
7
|
+
# POST /miniapp/acleda
|
|
8
|
+
def create
|
|
9
|
+
result = ::Vpago::AcledaMiniApp::Session::Create.call(
|
|
10
|
+
phone: session_params[:phone],
|
|
11
|
+
first_name: session_params[:first_name],
|
|
12
|
+
last_name: session_params[:last_name]
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
if result.success?
|
|
16
|
+
render json: { message: 'SUCCESS', miniAppUrl: result.value[:mini_app_url] }
|
|
17
|
+
else
|
|
18
|
+
render json: { message: 'FAILED', error: result.error.to_s }, status: :unprocessable_entity
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def session_params
|
|
25
|
+
params.permit(:phone, :first_name, :last_name)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -23,7 +23,6 @@ module Spree
|
|
|
23
23
|
# GET
|
|
24
24
|
def processing
|
|
25
25
|
@order = @payment.order
|
|
26
|
-
return redirect_to @payment.success_url, allow_other_host: true if @order.completed?
|
|
27
26
|
|
|
28
27
|
VpagoLogger.log(label: 'Spree::VpagoPaymentsController#processing', data: vpago_log_context)
|
|
29
28
|
end
|
|
@@ -61,33 +60,6 @@ module Spree
|
|
|
61
60
|
else
|
|
62
61
|
render json: { status: :pending }, status: :ok
|
|
63
62
|
end
|
|
64
|
-
rescue Faraday::TimeoutError, Faraday::ConnectionFailed => e
|
|
65
|
-
VpagoLogger.error(
|
|
66
|
-
label: 'Spree::VpagoPaymentsController#check_transaction gateway_timeout',
|
|
67
|
-
data: vpago_log_context(error_class: e.class.name, error_message: e.message)
|
|
68
|
-
)
|
|
69
|
-
render json: { status: :pending }, status: :ok
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
# POST
|
|
73
|
-
def create_transaction
|
|
74
|
-
@payment = Vpago::PaymentFinder.new(params.permit!.to_h).find_and_verify
|
|
75
|
-
raise ActiveRecord::RecordNotFound unless @payment.present?
|
|
76
|
-
|
|
77
|
-
return render json: { error: true, message: 'unsupported' }, status: :not_implemented unless @payment.payment_method.support_create_transaction_api?
|
|
78
|
-
|
|
79
|
-
result = VpagoLogger.log(
|
|
80
|
-
label: 'Spree::VpagoPaymentsController#create_transaction',
|
|
81
|
-
data: vpago_log_context
|
|
82
|
-
) { @payment.payment_method.create_transaction(@payment, platform: params[:platform]) }
|
|
83
|
-
|
|
84
|
-
render json: result, status: :ok
|
|
85
|
-
rescue Faraday::Error, JSON::ParserError, NoMethodError => e
|
|
86
|
-
VpagoLogger.error(
|
|
87
|
-
label: 'Spree::VpagoPaymentsController#create_transaction failed',
|
|
88
|
-
data: vpago_log_context(error_class: e.class.name, error_message: e.message)
|
|
89
|
-
)
|
|
90
|
-
render json: { error: true, message: 'Failed to create transaction' }, status: :bad_gateway
|
|
91
63
|
end
|
|
92
64
|
|
|
93
65
|
# POST
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
# ACLEDA Mini App payment method.
|
|
3
|
+
#
|
|
4
|
+
# Reuses the ACLEDA V2 integration in deeplink mode: the deeplink produced by
|
|
5
|
+
# ACLEDA's openSessionV2 API is handed to the ACLEDA super-app through the
|
|
6
|
+
# `acledaJSBridge` (startPayment) instead of redirecting the page. Server-side
|
|
7
|
+
# verification reuses AcledaV2's #check_transaction (getTxnStatus).
|
|
8
|
+
class Gateway::AcledaMiniApp < Gateway::AcledaV2
|
|
9
|
+
# override: partial to render in admin / checkout form lookup
|
|
10
|
+
def method_type
|
|
11
|
+
'acleda_mini_app'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# The mini app always uses the deeplink + JS bridge, so admins don't need to
|
|
15
|
+
# set the ACLEDA V2 mode.
|
|
16
|
+
def deeplink?
|
|
17
|
+
true
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -168,12 +168,6 @@ module Spree
|
|
|
168
168
|
checker
|
|
169
169
|
end
|
|
170
170
|
|
|
171
|
-
def create_transaction(payment, options = {})
|
|
172
|
-
creator = Vpago::PaywayV2::TransactionCreator.new(payment, disable_return_deeplink: options[:platform] == 'web')
|
|
173
|
-
creator.call
|
|
174
|
-
creator.json_response
|
|
175
|
-
end
|
|
176
|
-
|
|
177
171
|
private
|
|
178
172
|
|
|
179
173
|
def cancel_pre_auth(payment)
|
|
@@ -11,12 +11,5 @@ module Spree
|
|
|
11
11
|
def auto_capture?
|
|
12
12
|
true
|
|
13
13
|
end
|
|
14
|
-
|
|
15
|
-
# override: Spree::Payment#cancel! calls payment_method.cancel(response_code, payment).
|
|
16
|
-
# Cash has no gateway to void against, so acknowledge success and let the payment
|
|
17
|
-
# transition to `void`.
|
|
18
|
-
def cancel(_response_code, _payment = nil)
|
|
19
|
-
ActiveMerchant::Billing::Response.new(true, 'Cash On: Payment has been canceled.')
|
|
20
|
-
end
|
|
21
14
|
end
|
|
22
15
|
end
|
|
@@ -24,7 +24,6 @@ module Vpago
|
|
|
24
24
|
:success_url,
|
|
25
25
|
:success_deeplink_url,
|
|
26
26
|
:check_transaction_url,
|
|
27
|
-
:create_transaction_url,
|
|
28
27
|
:process_payment_url,
|
|
29
28
|
to: :url_constructor
|
|
30
29
|
|
|
@@ -110,6 +109,10 @@ module Vpago
|
|
|
110
109
|
payment_method.type_vattanac_mini_app?
|
|
111
110
|
end
|
|
112
111
|
|
|
112
|
+
def acleda_mini_app_payment?
|
|
113
|
+
payment_method.type_acleda_mini_app?
|
|
114
|
+
end
|
|
115
|
+
|
|
113
116
|
def check_payment?
|
|
114
117
|
payment_method.type_check?
|
|
115
118
|
end
|
|
@@ -6,6 +6,7 @@ module Vpago
|
|
|
6
6
|
TYPE_ACLEDA = 'Spree::Gateway::Acleda'.freeze
|
|
7
7
|
TYPE_ACLEDA_V2 = 'Spree::Gateway::AcledaV2'.freeze
|
|
8
8
|
TYPE_ACLEDA_MOBILE = 'Spree::Gateway::AcledaMobile'.freeze
|
|
9
|
+
TYPE_ACLEDA_MINI_APP = 'Spree::Gateway::AcledaMiniApp'.freeze
|
|
9
10
|
TYPE_TRUE_MONEY = 'Spree::Gateway::TrueMoney'.freeze
|
|
10
11
|
TYPE_VATTANAC = 'Spree::Gateway::Vattanac'.freeze
|
|
11
12
|
TYPE_VATTANAC_MINI_APP = 'Spree::Gateway::VattanacMiniApp'.freeze
|
|
@@ -24,6 +25,7 @@ module Vpago
|
|
|
24
25
|
Spree::PaymentMethod::TYPE_ACLEDA,
|
|
25
26
|
Spree::PaymentMethod::TYPE_ACLEDA_V2,
|
|
26
27
|
Spree::PaymentMethod::TYPE_ACLEDA_MOBILE,
|
|
28
|
+
Spree::PaymentMethod::TYPE_ACLEDA_MINI_APP,
|
|
27
29
|
Spree::PaymentMethod::TYPE_VATTANAC,
|
|
28
30
|
Spree::PaymentMethod::TYPE_VATTANAC_MINI_APP,
|
|
29
31
|
Spree::PaymentMethod::TYPE_TRUE_MONEY,
|
|
@@ -43,12 +45,6 @@ module Vpago
|
|
|
43
45
|
respond_to?(:check_transaction)
|
|
44
46
|
end
|
|
45
47
|
|
|
46
|
-
# The payment method must implement `create_transaction(payment, options = {})`,
|
|
47
|
-
# returning a Hash suitable for `render json:` directly.
|
|
48
|
-
def support_create_transaction_api?
|
|
49
|
-
respond_to?(:create_transaction)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
48
|
# TODO: we have already implement purchase for payway_v2.
|
|
53
49
|
# make sure to implement this on other payment method as well.
|
|
54
50
|
def purchase(_amount, _source, _gateway_options = {})
|
|
@@ -86,10 +82,6 @@ module Vpago
|
|
|
86
82
|
::Vpago::Acleda::PaymentRequestUpdater
|
|
87
83
|
elsif type_acleda_mobile?
|
|
88
84
|
::Vpago::AcledaMobile::PaymentRequestUpdater
|
|
89
|
-
elsif type_acleda_v2?
|
|
90
|
-
::Vpago::AcledaV2::PaymentRequestUpdater
|
|
91
|
-
elsif type_vattanac?
|
|
92
|
-
::Vpago::Vattanac::PaymentRequestUpdater
|
|
93
85
|
end
|
|
94
86
|
end
|
|
95
87
|
|
|
@@ -105,6 +97,10 @@ module Vpago
|
|
|
105
97
|
type == Spree::PaymentMethod::TYPE_ACLEDA_V2
|
|
106
98
|
end
|
|
107
99
|
|
|
100
|
+
def type_acleda_mini_app?
|
|
101
|
+
type == Spree::PaymentMethod::TYPE_ACLEDA_MINI_APP
|
|
102
|
+
end
|
|
103
|
+
|
|
108
104
|
def type_payway?
|
|
109
105
|
type == Spree::PaymentMethod::TYPE_PAYWAY
|
|
110
106
|
end
|
|
@@ -117,10 +113,6 @@ module Vpago
|
|
|
117
113
|
type == Spree::PaymentMethod::TYPE_WINGSDK
|
|
118
114
|
end
|
|
119
115
|
|
|
120
|
-
def type_vattanac?
|
|
121
|
-
type == Spree::PaymentMethod::TYPE_VATTANAC
|
|
122
|
-
end
|
|
123
|
-
|
|
124
116
|
def type_vattanac_mini_app?
|
|
125
117
|
type == Spree::PaymentMethod::TYPE_VATTANAC_MINI_APP
|
|
126
118
|
end
|
|
@@ -14,12 +14,6 @@ module Spree
|
|
|
14
14
|
|
|
15
15
|
pref.blank? || pref[:payment_option].blank? ? payment_method.method_type : pref[:payment_option]
|
|
16
16
|
end
|
|
17
|
-
|
|
18
|
-
# Overried the payment method type to show all payment methods as one list on App.
|
|
19
|
-
# Controlled by ENV["PAYMENT_METHOD_VIEW"] = "split" | "join" (default: "join").
|
|
20
|
-
base.attribute :type do |payment_method|
|
|
21
|
-
ENV.fetch('PAYMENT_METHOD_VIEW', 'join') == 'split' ? payment_method.type : 'payment_method'
|
|
22
|
-
end
|
|
23
17
|
end
|
|
24
18
|
end
|
|
25
19
|
end
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
module Vpago
|
|
2
|
+
module AcledaMiniApp
|
|
3
|
+
module Session
|
|
4
|
+
# Partner Session Initialization (ACLEDA Mini App Integration Spec, Step 01).
|
|
5
|
+
#
|
|
6
|
+
# ACLEDA calls POST /miniapp/acleda with { phone, first_name, last_name }.
|
|
7
|
+
# We find or create the customer (tagged with the acleda_bank identity),
|
|
8
|
+
# mint a session JWT, and return a session-based miniAppUrl for ACLEDA to
|
|
9
|
+
# open in the WebView. The generic session_id OAuth grant validates the JWT
|
|
10
|
+
# when the WebView later authenticates.
|
|
11
|
+
class Create
|
|
12
|
+
prepend Spree::ServiceModule::Base
|
|
13
|
+
|
|
14
|
+
def call(phone: nil, first_name: nil, last_name: nil)
|
|
15
|
+
return failure(nil, 'phone is required') if phone.blank?
|
|
16
|
+
|
|
17
|
+
@phone = phone
|
|
18
|
+
@first_name = first_name
|
|
19
|
+
@last_name = last_name
|
|
20
|
+
|
|
21
|
+
user = find_or_create_user
|
|
22
|
+
return failure(user, 'user creation failed') if user.nil? || !user.persisted?
|
|
23
|
+
|
|
24
|
+
success(mini_app_url: mini_app_url(user))
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
attr_reader :phone, :first_name, :last_name
|
|
30
|
+
|
|
31
|
+
def find_or_create_user
|
|
32
|
+
identity = acleda_identity
|
|
33
|
+
|
|
34
|
+
# Returning customer: the ACLEDA identity already points at a user.
|
|
35
|
+
return identity.user if identity.persisted?
|
|
36
|
+
|
|
37
|
+
# New to ACLEDA: reuse a customer matched by phone, otherwise build one,
|
|
38
|
+
# then tag them with the acleda_bank identity so the lookup above hits
|
|
39
|
+
# next time.
|
|
40
|
+
user = find_existing_user || build_user
|
|
41
|
+
identity.name = full_name
|
|
42
|
+
user.user_identity_providers << identity
|
|
43
|
+
user.save
|
|
44
|
+
|
|
45
|
+
user
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def acleda_identity
|
|
49
|
+
SpreeCmCommissioner::UserIdentityProvider.acleda_bank.find_or_initialize_by(sub: phone)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def find_existing_user
|
|
53
|
+
return if intel_phone.blank?
|
|
54
|
+
|
|
55
|
+
Spree::User.by_non_tenant.find_by(intel_phone_number: intel_phone)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def build_user
|
|
59
|
+
Spree::User.new(
|
|
60
|
+
first_name: first_name,
|
|
61
|
+
last_name: last_name,
|
|
62
|
+
phone_number: phone,
|
|
63
|
+
intel_phone_number: intel_phone,
|
|
64
|
+
password: SecureRandom.base64(16),
|
|
65
|
+
confirmed_at: Time.zone.now
|
|
66
|
+
)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def mini_app_url(user)
|
|
70
|
+
# A JWT signed with the user's secure_token. Passed as `session_key` (not
|
|
71
|
+
# `session_id`) so the OAuth grant routes it to the ACLEDA authenticator,
|
|
72
|
+
# which enforces the signature.
|
|
73
|
+
session_key = SpreeCmCommissioner::UserSessionJwtToken.encode(
|
|
74
|
+
{ user_id: user.id },
|
|
75
|
+
user.reload.secure_token
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
"#{Spree::Store.default.formatted_url}/mini_app/acleda?session_key=#{session_key}&ds=#{CGI.escape(disable_services)}"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def full_name
|
|
82
|
+
[first_name, last_name].compact.join(' ').presence
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def intel_phone
|
|
86
|
+
return @intel_phone if defined?(@intel_phone)
|
|
87
|
+
|
|
88
|
+
@intel_phone = SpreeCmCommissioner::PhoneNumberParser.call(phone_number: phone).intel_phone_number
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Services to disable in the mini app storefront. Configurable per ACLEDA's
|
|
92
|
+
# requirement; defaults to none.
|
|
93
|
+
def disable_services
|
|
94
|
+
ENV.fetch('ACLEDA_MINI_APP_DISABLE_SERVICES', '')
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
@@ -50,7 +50,7 @@ module Vpago
|
|
|
50
50
|
|
|
51
51
|
def process_acleda_gateway
|
|
52
52
|
data = {
|
|
53
|
-
href: "#{ENV.fetch('
|
|
53
|
+
href: "#{ENV.fetch('DEFAULT_URL_HOST', nil)}/acleda_redirects?payment_number=#{@payment.number}"
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
@redirect_options = data
|
|
@@ -81,7 +81,7 @@ module Vpago
|
|
|
81
81
|
def process_payway_v2_card
|
|
82
82
|
## TO DO: generate redirect url
|
|
83
83
|
data = {
|
|
84
|
-
href: "#{ENV.fetch('
|
|
84
|
+
href: "#{ENV.fetch('DEFAULT_URL_HOST', nil)}/payway_v2_card_popups?payment_number=#{@payment.number}"
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
@redirect_options = data
|
|
@@ -115,7 +115,7 @@ module Vpago
|
|
|
115
115
|
end
|
|
116
116
|
|
|
117
117
|
conn.post(abapay_payment.checkout_url, gateway_params) do |request|
|
|
118
|
-
request.headers['Referer'] = ENV.fetch('
|
|
118
|
+
request.headers['Referer'] = ENV.fetch('DEFAULT_URL_HOST', nil)
|
|
119
119
|
end
|
|
120
120
|
end
|
|
121
121
|
|
|
@@ -127,7 +127,7 @@ module Vpago
|
|
|
127
127
|
def process_payway_card
|
|
128
128
|
## TO DO: generate redirect url
|
|
129
129
|
data = {
|
|
130
|
-
href: "#{ENV.fetch('
|
|
130
|
+
href: "#{ENV.fetch('DEFAULT_URL_HOST', nil)}/payway_card_popups?payment_number=#{@payment.number}"
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
@redirect_options = data
|
|
@@ -135,7 +135,7 @@ module Vpago
|
|
|
135
135
|
|
|
136
136
|
def process_wing_gateway
|
|
137
137
|
data = {
|
|
138
|
-
href: "#{ENV.fetch('
|
|
138
|
+
href: "#{ENV.fetch('DEFAULT_URL_HOST', nil)}/wing_redirects?payment_number=#{@payment.number}"
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
@redirect_options = data
|
|
@@ -169,7 +169,7 @@ module Vpago
|
|
|
169
169
|
end
|
|
170
170
|
|
|
171
171
|
@response = conn.post(abapay_payment.action_url, gateway_params) do |request|
|
|
172
|
-
request.headers['Referer'] = ENV.fetch('
|
|
172
|
+
request.headers['Referer'] = ENV.fetch('DEFAULT_URL_HOST', nil)
|
|
173
173
|
end
|
|
174
174
|
end
|
|
175
175
|
|
|
@@ -18,7 +18,6 @@ module Vpago
|
|
|
18
18
|
def success_deeplink_url = "#{app_scheme}://#{URI(base_url).host}/book/payment?number=#{order.number}&tk=#{order.token}"
|
|
19
19
|
|
|
20
20
|
def check_transaction_url = "#{base_url}/vpago_payments/check_transaction?#{query}"
|
|
21
|
-
def create_transaction_url = "#{base_url}/vpago_payments/create_transaction?#{query}"
|
|
22
21
|
def process_payment_url = "#{base_url}/vpago_payments/process_payment?#{query}"
|
|
23
22
|
|
|
24
23
|
def query
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
<%= yield :head %>
|
|
12
12
|
|
|
13
13
|
<%= javascript_include_tag "vpago/vpago_payments/check_transaction_periodically", 'data-turbo-track': 'reload' %>
|
|
14
|
-
<%= javascript_include_tag "vpago/vpago_payments/create_transaction", 'data-turbo-track': 'reload' %>
|
|
15
14
|
<%= javascript_include_tag "vpago/vpago_payments/request_process_payment", 'data-turbo-track': 'reload' %>
|
|
16
15
|
<%= javascript_include_tag "vpago/vpago_payments/user_informers/#{user_informer}", 'data-turbo-track': 'reload' %>
|
|
17
16
|
</head>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<%= render 'spree/admin/payments/source_views/vpago_payment_tmpl',
|
|
2
2
|
payment: payment,
|
|
3
|
-
check_status_url:
|
|
4
|
-
heal_payment_url:
|
|
3
|
+
check_status_url: '',
|
|
4
|
+
heal_payment_url: '',
|
|
5
5
|
manual_update_payment_url: '' %>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<%= render 'spree/admin/payments/source_views/vpago_payment_tmpl',
|
|
2
|
-
payment: payment,
|
|
3
|
-
check_status_url:
|
|
4
|
-
heal_payment_url:
|
|
2
|
+
payment: payment,
|
|
3
|
+
check_status_url: '',
|
|
4
|
+
heal_payment_url: '',
|
|
5
5
|
manual_update_payment_url: ''
|
|
6
6
|
%>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<%
|
|
2
|
+
opr_device = request.user_agent.to_s.downcase.match?(/iphone|ipad|ipod/) ? 'ios' : 'android'
|
|
3
|
+
checkout = ::Vpago::AcledaMiniApp::Checkout.new(@payment, { platform: 'app', opr_device: opr_device })
|
|
4
|
+
|
|
5
|
+
begin
|
|
6
|
+
checkout.call
|
|
7
|
+
rescue => e
|
|
8
|
+
Rails.logger.error("Acleda Mini App checkout.call failed: #{e.message}")
|
|
9
|
+
end
|
|
10
|
+
%>
|
|
11
|
+
|
|
12
|
+
<p id="unsupported-message"
|
|
13
|
+
style="margin-top: 10px; font-weight: bold; color: red; display: none;">
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<% if checkout.failed? %>
|
|
17
|
+
<script>
|
|
18
|
+
console.error("[Vpago] Acleda Mini App checkout error: <%= j checkout.error_message.to_s %>");
|
|
19
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
20
|
+
const loadingContainer = document.getElementById('vpago_loading_container');
|
|
21
|
+
if (loadingContainer) {
|
|
22
|
+
loadingContainer.textContent = "We couldn't start your payment. Please go back and try again.";
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
</script>
|
|
26
|
+
<% else %>
|
|
27
|
+
<script>
|
|
28
|
+
// ACLEDA JS bridge (unified iOS + Android). Defined before use so it is
|
|
29
|
+
// available when the native layer injects its handlers.
|
|
30
|
+
window.acledaJSBridge = window.acledaJSBridge || {
|
|
31
|
+
call: function (action, data = {}) {
|
|
32
|
+
const payload = { action, data };
|
|
33
|
+
|
|
34
|
+
// iOS WKWebView
|
|
35
|
+
if (
|
|
36
|
+
window.webkit &&
|
|
37
|
+
window.webkit.messageHandlers &&
|
|
38
|
+
window.webkit.messageHandlers.acledaIOSJSBridge
|
|
39
|
+
) {
|
|
40
|
+
window.webkit.messageHandlers.acledaIOSJSBridge.postMessage(payload);
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Android WebView
|
|
45
|
+
if (
|
|
46
|
+
window.acledaAndroidJSBridge &&
|
|
47
|
+
typeof window.acledaAndroidJSBridge.postMessage === "function"
|
|
48
|
+
) {
|
|
49
|
+
window.acledaAndroidJSBridge.postMessage(JSON.stringify(payload));
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.warn("[acledaJSBridge] Native bridge not found");
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
function showRedirectContainer(buttonLabel, onClick) {
|
|
59
|
+
const loadingContainer = document.getElementById('vpago_loading_container');
|
|
60
|
+
const redirectContainer = document.getElementById('vpago_redirect_container');
|
|
61
|
+
const redirectButton = document.getElementById('vpago_redirect_button');
|
|
62
|
+
|
|
63
|
+
redirectButton.textContent = buttonLabel;
|
|
64
|
+
redirectButton.addEventListener('click', onClick);
|
|
65
|
+
|
|
66
|
+
loadingContainer.style.display = 'none';
|
|
67
|
+
redirectContainer.style.removeProperty('display');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
71
|
+
const acledaDeeplink = "<%= raw checkout.acleda_deeplink %>";
|
|
72
|
+
const processingUrl = "<%= raw @payment.processing_url %>";
|
|
73
|
+
|
|
74
|
+
// Native -> JS after payment completes. Primary completion signal; the
|
|
75
|
+
// transaction checker polling is the fallback.
|
|
76
|
+
window.onPaymentResult = function (result) {
|
|
77
|
+
console.log("[acledaJSBridge] Payment result:", result);
|
|
78
|
+
// result.batchId, result.status = "success" | "failed" | "cancelled"
|
|
79
|
+
window.location.href = processingUrl;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const startPayment = () => window.acledaJSBridge.call("startPayment", { acleda_deeplink: acledaDeeplink });
|
|
83
|
+
|
|
84
|
+
if (startPayment()) {
|
|
85
|
+
showRedirectContainer("Continue", startPayment);
|
|
86
|
+
} else {
|
|
87
|
+
const unsupported = document.getElementById('unsupported-message');
|
|
88
|
+
unsupported.style.display = 'block';
|
|
89
|
+
unsupported.innerText = 'Unsupported environment';
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
</script>
|
|
93
|
+
<% end %>
|