@quenty/receiptprocessing 1.6.0 → 1.6.1-canary.411.a43e0f9.0
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.
- package/CHANGELOG.md +11 -0
- package/package.json +9 -8
- package/src/Server/ReceiptProcessingService.lua +54 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.6.1-canary.411.a43e0f9.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/receiptprocessing@1.6.0...@quenty/receiptprocessing@1.6.1-canary.411.a43e0f9.0) (2023-09-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Process and report products properly ([75bf0e9](https://github.com/Quenty/NevermoreEngine/commit/75bf0e94f3e03e6369aad9dc22b532a24f30a5d4))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [1.6.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/receiptprocessing@1.5.0...@quenty/receiptprocessing@1.6.0) (2023-08-23)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/receiptprocessing
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/receiptprocessing",
|
|
3
|
-
"version": "1.6.0",
|
|
3
|
+
"version": "1.6.1-canary.411.a43e0f9.0",
|
|
4
4
|
"description": "Centralize receipt processing within games since this is a constrained resource.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,15 +25,16 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/enumutils": "
|
|
29
|
-
"@quenty/loader": "
|
|
30
|
-
"@quenty/maid": "
|
|
31
|
-
"@quenty/promise": "
|
|
32
|
-
"@quenty/
|
|
33
|
-
"@quenty/
|
|
28
|
+
"@quenty/enumutils": "3.1.0",
|
|
29
|
+
"@quenty/loader": "6.3.0",
|
|
30
|
+
"@quenty/maid": "2.6.0",
|
|
31
|
+
"@quenty/promise": "6.8.0",
|
|
32
|
+
"@quenty/rx": "7.15.1-canary.411.a43e0f9.0",
|
|
33
|
+
"@quenty/servicebag": "6.9.0",
|
|
34
|
+
"@quenty/signal": "2.4.0"
|
|
34
35
|
},
|
|
35
36
|
"publishConfig": {
|
|
36
37
|
"access": "public"
|
|
37
38
|
},
|
|
38
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "a43e0f99169bd624fbb8ec2c81e61ca7ff0dce08"
|
|
39
40
|
}
|
|
@@ -12,6 +12,8 @@ local Promise = require("Promise")
|
|
|
12
12
|
local EnumUtils = require("EnumUtils")
|
|
13
13
|
local Signal = require("Signal")
|
|
14
14
|
local Maid = require("Maid")
|
|
15
|
+
local ObservableSubscriptionTable = require("ObservableSubscriptionTable")
|
|
16
|
+
local ValueObject = require("ValueObject")
|
|
15
17
|
|
|
16
18
|
local ReceiptProcessingService = {}
|
|
17
19
|
ReceiptProcessingService.ServiceName = "ReceiptProcessingService"
|
|
@@ -21,11 +23,11 @@ function ReceiptProcessingService:Init(serviceBag)
|
|
|
21
23
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
22
24
|
self._maid = Maid.new()
|
|
23
25
|
|
|
24
|
-
self.ReceiptCreated = Signal.new() -- :Fire(receiptInfo)
|
|
25
|
-
self._maid:
|
|
26
|
+
self.ReceiptCreated = self._maid:Add(Signal.new()) -- :Fire(receiptInfo)
|
|
27
|
+
self.ReceiptProcessed = self._maid:Add(Signal.new()) -- :Fire(receiptInfo, productPurchaseDecision)
|
|
26
28
|
|
|
27
|
-
self.
|
|
28
|
-
self._maid:
|
|
29
|
+
self._receiptProcessedForUserId = self._maid:Add(ObservableSubscriptionTable.new()) -- :Fire(receiptInfo, productPurchaseDecision)
|
|
30
|
+
self._defaultDecision = self._maid:Add(ValueObject.new(Enum.ProductPurchaseDecision.PurchaseGranted, "EnumItem"))
|
|
29
31
|
|
|
30
32
|
self._processors = {}
|
|
31
33
|
end
|
|
@@ -36,6 +38,39 @@ function ReceiptProcessingService:Start()
|
|
|
36
38
|
end
|
|
37
39
|
end
|
|
38
40
|
|
|
41
|
+
--[=[
|
|
42
|
+
Sets the default purchase decision in case you want more control
|
|
43
|
+
@param productPurchaseDecision ProductPurchaseDecision
|
|
44
|
+
]=]
|
|
45
|
+
function ReceiptProcessingService:SetDefaultPurchaseDecision(productPurchaseDecision)
|
|
46
|
+
assert(EnumUtils.isOfType(Enum.ProductPurchaseDecision, productPurchaseDecision), "Bad productPurchaseDecision")
|
|
47
|
+
|
|
48
|
+
self._defaultDecision.Value = productPurchaseDecision
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
--[=[
|
|
52
|
+
Observes receipt by player
|
|
53
|
+
|
|
54
|
+
@param player Player
|
|
55
|
+
@return Observable<ReceiptInfo>
|
|
56
|
+
]=]
|
|
57
|
+
function ReceiptProcessingService:ObserveReceiptProcessedForPlayer(player)
|
|
58
|
+
assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
|
|
59
|
+
|
|
60
|
+
return self:ObserveReceiptProcessedForUserId(player.UserId)
|
|
61
|
+
end
|
|
62
|
+
--[=[
|
|
63
|
+
Observes receipt by userId
|
|
64
|
+
|
|
65
|
+
@param userId number
|
|
66
|
+
@return Observable<ReceiptInfo>
|
|
67
|
+
]=]
|
|
68
|
+
function ReceiptProcessingService:ObserveReceiptProcessedForUserId(userId)
|
|
69
|
+
assert(type(userId) == "number", "Bad userId")
|
|
70
|
+
|
|
71
|
+
return self._receiptProcessedForUserId:Observe(userId)
|
|
72
|
+
end
|
|
73
|
+
|
|
39
74
|
--[=[
|
|
40
75
|
Registers a new receipt processor. This works exactly like a normal receipt processor except it will also
|
|
41
76
|
take a Promise as a result (of which an error).
|
|
@@ -98,7 +133,7 @@ function ReceiptProcessingService:_handleProcessReceiptAsync(receiptInfo)
|
|
|
98
133
|
end
|
|
99
134
|
|
|
100
135
|
if EnumUtils.isOfType(Enum.ProductPurchaseDecision, result) then
|
|
101
|
-
self
|
|
136
|
+
self:_fireProcessed(receiptInfo, result)
|
|
102
137
|
return result
|
|
103
138
|
elseif result == nil then
|
|
104
139
|
continue
|
|
@@ -108,8 +143,20 @@ function ReceiptProcessingService:_handleProcessReceiptAsync(receiptInfo)
|
|
|
108
143
|
end
|
|
109
144
|
|
|
110
145
|
-- Retry in the future
|
|
111
|
-
self
|
|
112
|
-
return
|
|
146
|
+
self:_fireProcessed(receiptInfo, self._defaultDecision.Value)
|
|
147
|
+
return self._defaultDecision.Value
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
function ReceiptProcessingService:_fireProcessed(receiptInfo, productPurchaseDecision)
|
|
151
|
+
assert(EnumUtils.isOfType(Enum.ProductPurchaseDecision, productPurchaseDecision), "Bad productPurchaseDecision")
|
|
152
|
+
|
|
153
|
+
self.ReceiptProcessed:Fire(receiptInfo, productPurchaseDecision)
|
|
154
|
+
|
|
155
|
+
if type(receiptInfo.PlayerId) == "number" then
|
|
156
|
+
self._receiptProcessedForUserId:Fire(receiptInfo.PlayerId, receiptInfo, productPurchaseDecision)
|
|
157
|
+
else
|
|
158
|
+
warn("[ReceiptProcessingService._fireProcessed] - No receiptInfo.PlayerId")
|
|
159
|
+
end
|
|
113
160
|
end
|
|
114
161
|
|
|
115
162
|
function ReceiptProcessingService:Destroy()
|