spree_vpago 2.0.5.pre.beta → 2.0.6
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/.env.example +8 -0
- data/Gemfile.lock +3 -3
- data/app/models/spree/gateway/vattanac_mini_app.rb +5 -10
- data/app/views/spree/vpago_payments/forms/spree/gateway/_vattanac_mini_app.html.erb +34 -30
- data/docs/vattanac_mini_app.md +12 -0
- data/lib/spree_vpago/version.rb +1 -1
- data/lib/vpago/vattanac_mini_app/base.rb +2 -3
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15ef60f028340ceaa61336833ec624092ed9f32447fd7adbde31345b0eadd725
|
4
|
+
data.tar.gz: fbf8efefd803b39458c5e6f10b216098f4c22a65a84e3af61ebe580c592e4b69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '089f3456f9992f1337974039c22e2d1484df07bf6c75053ebf53cb61927d53f6e16b6a086dcefababbc14d7b2ee2d4ec0ff61f08d0535cc2a6169dd80c0db53b'
|
7
|
+
data.tar.gz: d243bf13344af8e1a0c2c01ee05732c56c34761dccd25ef05cb428b0f3d6c12cf834646cb3942c6edac10fbe44318b71eb77d062578ce1b383e628f0204d968d
|
data/.env.example
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
spree_vpago (2.0.
|
4
|
+
spree_vpago (2.0.6)
|
5
5
|
faraday
|
6
6
|
google-cloud-firestore
|
7
7
|
spree_api (>= 4.5)
|
@@ -188,7 +188,7 @@ GEM
|
|
188
188
|
faraday-http-cache (2.5.0)
|
189
189
|
faraday (>= 0.8)
|
190
190
|
faraday-net_http (3.0.2)
|
191
|
-
faraday-retry (2.3.
|
191
|
+
faraday-retry (2.3.2)
|
192
192
|
faraday (~> 2.0)
|
193
193
|
ffaker (2.21.0)
|
194
194
|
ffi (1.15.5)
|
@@ -259,7 +259,7 @@ GEM
|
|
259
259
|
multi_json (~> 1.11)
|
260
260
|
os (>= 0.9, < 2.0)
|
261
261
|
signet (>= 0.16, < 2.a)
|
262
|
-
grpc (1.
|
262
|
+
grpc (1.73.0)
|
263
263
|
google-protobuf (>= 3.25, < 5.0)
|
264
264
|
googleapis-common-protos-types (~> 1.0)
|
265
265
|
hashdiff (1.1.0)
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Spree
|
2
2
|
class Gateway::VattanacMiniApp < PaymentMethod
|
3
|
+
preference :partner_code, :string
|
4
|
+
preference :refund_url, :string
|
3
5
|
|
4
6
|
def method_type
|
5
7
|
'vattanac_mini_app'
|
@@ -14,27 +16,23 @@ module Spree
|
|
14
16
|
true
|
15
17
|
end
|
16
18
|
|
17
|
-
|
18
19
|
# override
|
19
20
|
# purchase is used when pre auth disabled
|
20
21
|
def purchase(_amount, _source, gateway_options = {})
|
21
22
|
_, payment_number = gateway_options[:order_id].split('-')
|
22
23
|
payment = Spree::Payment.find_by(number: payment_number)
|
23
|
-
|
24
|
+
|
24
25
|
params = {}
|
25
26
|
|
26
27
|
params[:payment_response] = payment.transaction_response
|
27
|
-
|
28
28
|
|
29
|
-
if payment.transaction_response[
|
29
|
+
if payment.transaction_response['status'] == 'SUCCESS'
|
30
30
|
ActiveMerchant::Billing::Response.new(true, 'Payway Gateway: Purchased', params)
|
31
31
|
else
|
32
32
|
ActiveMerchant::Billing::Response.new(false, 'Payway Gateway: Purchasing Failed', params)
|
33
33
|
end
|
34
|
-
|
35
34
|
end
|
36
35
|
|
37
|
-
|
38
36
|
# override
|
39
37
|
def void(_response_code, gateway_options)
|
40
38
|
_, payment_number = gateway_options[:order_id].split('-')
|
@@ -42,7 +40,7 @@ module Spree
|
|
42
40
|
|
43
41
|
if payment.vattanac_mini_app_payment?
|
44
42
|
params = {}
|
45
|
-
success, params[:refund_response] =
|
43
|
+
success, params[:refund_response] = vattanac_mini_app_refund(payment)
|
46
44
|
|
47
45
|
if success
|
48
46
|
ActiveMerchant::Billing::Response.new(true, 'Payway Gateway: successfully canceled.', params)
|
@@ -54,14 +52,11 @@ module Spree
|
|
54
52
|
end
|
55
53
|
end
|
56
54
|
|
57
|
-
|
58
55
|
def vattanac_mini_app_refund(payment)
|
59
|
-
|
60
56
|
refund_issuer = Vpago::VattanacMiniApp::RefundIssuer.new(payment, {})
|
61
57
|
refund_issuer.call
|
62
58
|
|
63
59
|
[refund_issuer.success?, refund_issuer.response]
|
64
|
-
|
65
60
|
end
|
66
61
|
|
67
62
|
def cancel(_response_code)
|
@@ -8,13 +8,7 @@
|
|
8
8
|
display: none;">
|
9
9
|
</p>
|
10
10
|
|
11
|
-
<h1 id="status">THIS IS CURRENT STATE</h1>
|
12
|
-
<p id="reason_code"></p>
|
13
|
-
<p id="processing"></p>
|
14
|
-
<p id="reason_message"></p>
|
15
|
-
|
16
11
|
<script>
|
17
|
-
|
18
12
|
function detectMobileOS() {
|
19
13
|
const ua = navigator.userAgent || navigator.vendor || window.opera;
|
20
14
|
if (/iPad|iPhone|iPod/.test(ua) && !window.MSStream) return 'iOS';
|
@@ -44,43 +38,53 @@
|
|
44
38
|
window.listenToProcessingState({
|
45
39
|
firebaseConfigs: firebaseConfigs,
|
46
40
|
documentReferencePath: "<%= @payment.user_informer.document_reference_path %>",
|
41
|
+
|
47
42
|
onPaymentIsProcessing: function (orderState, paymentState, processing, reasonCode, reasonMessage) {
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
43
|
+
console.log("Status: Payment is processing");
|
44
|
+
console.log("Reason Code:", reasonCode);
|
45
|
+
console.log("Processing:", processing ? "Processing..." : "No more process.");
|
46
|
+
console.log("Reason Message:", reasonMessage);
|
52
47
|
},
|
48
|
+
|
53
49
|
onOrderIsProcessing: function (orderState, paymentState, processing, reasonCode, reasonMessage) {
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
50
|
+
console.log("Status: Order is processing");
|
51
|
+
console.log("Reason Code:", reasonCode);
|
52
|
+
console.log("Processing:", processing ? "Processing..." : "No more process.");
|
53
|
+
console.log("Reason Message:", reasonMessage);
|
58
54
|
},
|
55
|
+
|
59
56
|
onOrderIsCompleted: function (orderState, paymentState, processing, reasonCode, reasonMessage) {
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
57
|
+
console.log("Status: Order is completed");
|
58
|
+
console.log("Reason Code:", reasonCode);
|
59
|
+
console.log("Processing:", processing ? "Processing..." : "No more process.");
|
60
|
+
console.log("Reason Message:", reasonMessage);
|
64
61
|
},
|
62
|
+
|
65
63
|
onOrderProcessFailed: function (orderState, paymentState, processing, reasonCode, reasonMessage) {
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
64
|
+
console.log("Status: Order process failed");
|
65
|
+
console.log("Reason Code:", reasonCode);
|
66
|
+
console.log("Processing:", processing ? "Processing..." : "No more process.");
|
67
|
+
console.log("Reason Message:", reasonMessage);
|
70
68
|
},
|
69
|
+
|
71
70
|
onPaymentIsRefunded: function (orderState, paymentState, processing, reasonCode, reasonMessage) {
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
71
|
+
console.log("Status: Payment is refunded");
|
72
|
+
console.log("Reason Code:", reasonCode);
|
73
|
+
console.log("Processing:", processing ? "Processing..." : "No more process.");
|
74
|
+
console.log("Reason Message:", reasonMessage);
|
76
75
|
},
|
76
|
+
|
77
77
|
onPaymentProcessFailed: function (orderState, paymentState, processing, reasonCode, reasonMessage) {
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
78
|
+
console.log("Status: Payment process failed");
|
79
|
+
console.log("Reason Code:", reasonCode);
|
80
|
+
console.log("Processing:", processing ? "Processing..." : "No more process.");
|
81
|
+
console.log("Reason Message:", reasonMessage);
|
82
82
|
},
|
83
|
+
|
83
84
|
onCompleted: function (orderState, paymentState, processing, reasonCode, reasonMessage) {
|
85
|
+
console.log("Status: Completed — redirecting to success URL");
|
86
|
+
console.log("Reason Code:", reasonCode);
|
87
|
+
console.log("Reason Message:", reasonMessage);
|
84
88
|
let successPath = "<%= @payment.success_url %>";
|
85
89
|
window.location.href = successPath;
|
86
90
|
},
|
@@ -0,0 +1,12 @@
|
|
1
|
+
## Vattanac Mini App Payment Configuration
|
2
|
+
|
3
|
+
To configure Vattanac Mini App payment, set the following preferences on the payment method:
|
4
|
+
|
5
|
+
1. Add the **Partner Code** (`preferred_partner_code`) – this value is sent in the HTTP request header as `Partner-Code`.
|
6
|
+
2. Add the **Refund URL** (`preferred_refund_url`) – this URL is used to trigger refund API requests.
|
7
|
+
|
8
|
+
### Example:
|
9
|
+
|
10
|
+
|
11
|
+
- Partner Code: `your-partner-code`
|
12
|
+
- Refund URL: `https://your-api.com/refund`
|
data/lib/spree_vpago/version.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Vpago
|
2
2
|
module VattanacMiniApp
|
3
3
|
class Base
|
4
|
-
|
5
4
|
def initialize(payment, options = {})
|
6
5
|
@options = options
|
7
6
|
@payment = payment
|
@@ -41,11 +40,11 @@ module Vpago
|
|
41
40
|
end
|
42
41
|
|
43
42
|
def partner_code
|
44
|
-
|
43
|
+
@payment.payment_method.preferred_partner_code
|
45
44
|
end
|
46
45
|
|
47
46
|
def refund_url
|
48
|
-
|
47
|
+
@payment.payment_method.preferred_refund_url
|
49
48
|
end
|
50
49
|
end
|
51
50
|
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.
|
4
|
+
version: 2.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- You
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-06-
|
11
|
+
date: 2025-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -339,6 +339,7 @@ files:
|
|
339
339
|
- db/migrate/20241202104014_add_enable_pre_auth_to_spree_payment_method.rb
|
340
340
|
- db/migrate/20250121044614_add_transaction_response_to_spree_payments.rb
|
341
341
|
- docs/acleda.md
|
342
|
+
- docs/vattanac_mini_app.md
|
342
343
|
- gemfiles/spree_3_7.gemfile
|
343
344
|
- gemfiles/spree_4_0.gemfile
|
344
345
|
- gemfiles/spree_4_1.gemfile
|
@@ -407,9 +408,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
407
408
|
version: 3.2.0
|
408
409
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
409
410
|
requirements:
|
410
|
-
- - "
|
411
|
+
- - ">="
|
411
412
|
- !ruby/object:Gem::Version
|
412
|
-
version:
|
413
|
+
version: '0'
|
413
414
|
requirements:
|
414
415
|
- none
|
415
416
|
rubygems_version: 3.4.1
|