@quenty/receiptprocessing 7.18.0 → 7.18.1
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 +10 -10
- package/src/Server/ReceiptProcessingService.lua +28 -12
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
|
+
## [7.18.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/receiptprocessing@7.18.0...@quenty/receiptprocessing@7.18.1) (2025-04-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [7.18.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/receiptprocessing@7.17.2...@quenty/receiptprocessing@7.18.0) (2025-04-02)
|
|
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": "7.18.
|
|
3
|
+
"version": "7.18.1",
|
|
4
4
|
"description": "Centralize receipt processing within games since this is a constrained resource.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/enumutils": "^3.4.
|
|
29
|
-
"@quenty/loader": "^10.8.
|
|
30
|
-
"@quenty/maid": "^3.4.
|
|
31
|
-
"@quenty/promise": "^10.10.
|
|
32
|
-
"@quenty/rx": "^13.17.
|
|
33
|
-
"@quenty/servicebag": "^11.11.
|
|
34
|
-
"@quenty/signal": "^7.10.
|
|
35
|
-
"@quenty/valueobject": "^13.17.
|
|
28
|
+
"@quenty/enumutils": "^3.4.1",
|
|
29
|
+
"@quenty/loader": "^10.8.1",
|
|
30
|
+
"@quenty/maid": "^3.4.1",
|
|
31
|
+
"@quenty/promise": "^10.10.2",
|
|
32
|
+
"@quenty/rx": "^13.17.1",
|
|
33
|
+
"@quenty/servicebag": "^11.11.2",
|
|
34
|
+
"@quenty/signal": "^7.10.1",
|
|
35
|
+
"@quenty/valueobject": "^13.17.1"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "78c3ac0ab08dd18085b6e6e6e4f745e76ed99f68"
|
|
41
41
|
}
|
|
@@ -9,17 +9,29 @@ local require = require(script.Parent.loader).load(script)
|
|
|
9
9
|
local MarketplaceService = game:GetService("MarketplaceService")
|
|
10
10
|
local RunService = game:GetService("RunService")
|
|
11
11
|
|
|
12
|
-
local Promise = require("Promise")
|
|
13
12
|
local EnumUtils = require("EnumUtils")
|
|
14
|
-
local Signal = require("Signal")
|
|
15
13
|
local Maid = require("Maid")
|
|
16
14
|
local ObservableSubscriptionTable = require("ObservableSubscriptionTable")
|
|
15
|
+
local Promise = require("Promise")
|
|
16
|
+
local Signal = require("Signal")
|
|
17
17
|
local ValueObject = require("ValueObject")
|
|
18
|
+
local _ServiceBag = require("ServiceBag")
|
|
19
|
+
local _Observable = require("Observable")
|
|
20
|
+
|
|
21
|
+
export type ReceiptInfo = {
|
|
22
|
+
PurchaseId: number,
|
|
23
|
+
PlayerId: number,
|
|
24
|
+
ProductId: number,
|
|
25
|
+
PlaceIdWherePurchased: number,
|
|
26
|
+
CurrencySpent: number,
|
|
27
|
+
CurrencyType: Enum.CurrencyType,
|
|
28
|
+
ProductPurchaseChannel: Enum.ProductPurchaseChannel,
|
|
29
|
+
}
|
|
18
30
|
|
|
19
31
|
local ReceiptProcessingService = {}
|
|
20
32
|
ReceiptProcessingService.ServiceName = "ReceiptProcessingService"
|
|
21
33
|
|
|
22
|
-
function ReceiptProcessingService:Init(serviceBag)
|
|
34
|
+
function ReceiptProcessingService:Init(serviceBag: _ServiceBag.ServiceBag)
|
|
23
35
|
assert(not self._serviceBag, "Already initialized")
|
|
24
36
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
25
37
|
self._maid = Maid.new()
|
|
@@ -45,7 +57,7 @@ end
|
|
|
45
57
|
Sets the default purchase decision in case you want more control
|
|
46
58
|
@param productPurchaseDecision ProductPurchaseDecision
|
|
47
59
|
]=]
|
|
48
|
-
function ReceiptProcessingService:SetDefaultPurchaseDecision(productPurchaseDecision)
|
|
60
|
+
function ReceiptProcessingService:SetDefaultPurchaseDecision(productPurchaseDecision: Enum.ProductPurchaseDecision)
|
|
49
61
|
assert(EnumUtils.isOfType(Enum.ProductPurchaseDecision, productPurchaseDecision), "Bad productPurchaseDecision")
|
|
50
62
|
|
|
51
63
|
self._defaultDecision.Value = productPurchaseDecision
|
|
@@ -57,7 +69,7 @@ end
|
|
|
57
69
|
@param player Player
|
|
58
70
|
@return Observable<ReceiptInfo>
|
|
59
71
|
]=]
|
|
60
|
-
function ReceiptProcessingService:ObserveReceiptProcessedForPlayer(player: Player)
|
|
72
|
+
function ReceiptProcessingService:ObserveReceiptProcessedForPlayer(player: Player): _Observable.Observable<ReceiptInfo>
|
|
61
73
|
assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
|
|
62
74
|
|
|
63
75
|
return self:ObserveReceiptProcessedForUserId(player.UserId)
|
|
@@ -68,20 +80,24 @@ end
|
|
|
68
80
|
@param userId number
|
|
69
81
|
@return Observable<ReceiptInfo>
|
|
70
82
|
]=]
|
|
71
|
-
function ReceiptProcessingService:ObserveReceiptProcessedForUserId(userId: number)
|
|
83
|
+
function ReceiptProcessingService:ObserveReceiptProcessedForUserId(userId: number): _Observable.Observable<ReceiptInfo>
|
|
72
84
|
assert(type(userId) == "number", "Bad userId")
|
|
73
85
|
|
|
74
86
|
return self._receiptProcessedForUserId:Observe(userId)
|
|
75
87
|
end
|
|
76
88
|
|
|
89
|
+
export type ReceiptProcessor = (
|
|
90
|
+
receiptInfo: ReceiptInfo
|
|
91
|
+
) -> Enum.ProductPurchaseDecision? | Promise.Promise<Enum.ProductPurchaseDecision?>
|
|
92
|
+
|
|
77
93
|
--[=[
|
|
78
94
|
Registers a new receipt processor. This works exactly like a normal receipt processor except it will also
|
|
79
95
|
take a Promise as a result (of which an error).
|
|
80
96
|
|
|
81
97
|
@param processor (receiptInfo) -> ProductPurchaseDecision | Promise<ProductPurchaseDecision> | nil
|
|
82
|
-
@param priority number
|
|
98
|
+
@param priority number?
|
|
83
99
|
]=]
|
|
84
|
-
function ReceiptProcessingService:RegisterReceiptProcessor(processor, priority)
|
|
100
|
+
function ReceiptProcessingService:RegisterReceiptProcessor(processor: ReceiptProcessor, priority: number?): () -> ()
|
|
85
101
|
assert(self._processors, "Not initialized")
|
|
86
102
|
assert(type(processor) == "function", "Bad processor")
|
|
87
103
|
priority = priority or 0
|
|
@@ -107,12 +123,12 @@ function ReceiptProcessingService:RegisterReceiptProcessor(processor, priority)
|
|
|
107
123
|
return function()
|
|
108
124
|
local index = table.find(self._handles, data)
|
|
109
125
|
if index then
|
|
110
|
-
table.remove(self._handles,
|
|
126
|
+
table.remove(self._handles, index)
|
|
111
127
|
end
|
|
112
128
|
end
|
|
113
129
|
end
|
|
114
130
|
|
|
115
|
-
function ReceiptProcessingService:_handleProcessReceiptAsync(receiptInfo)
|
|
131
|
+
function ReceiptProcessingService:_handleProcessReceiptAsync(receiptInfo: ReceiptInfo): Enum.ProductPurchaseDecision
|
|
116
132
|
if not self._processors then
|
|
117
133
|
warn(
|
|
118
134
|
"[ReceiptProcessingService._handleProcessReceiptAsync] - We're leaking memory. Receipt processing service is already cleaned up."
|
|
@@ -123,7 +139,7 @@ function ReceiptProcessingService:_handleProcessReceiptAsync(receiptInfo)
|
|
|
123
139
|
self.ReceiptCreated:Fire(receiptInfo)
|
|
124
140
|
|
|
125
141
|
-- Chain of command this thing
|
|
126
|
-
for _, data in
|
|
142
|
+
for _, data in self._processors do
|
|
127
143
|
local result = data.processor(receiptInfo)
|
|
128
144
|
|
|
129
145
|
-- Unpack pro
|
|
@@ -164,7 +180,7 @@ function ReceiptProcessingService:_handleProcessReceiptAsync(receiptInfo)
|
|
|
164
180
|
return self._defaultDecision.Value
|
|
165
181
|
end
|
|
166
182
|
|
|
167
|
-
function ReceiptProcessingService:_fireProcessed(receiptInfo, productPurchaseDecision)
|
|
183
|
+
function ReceiptProcessingService:_fireProcessed(receiptInfo: ReceiptInfo, productPurchaseDecision: Enum.ProductPurchaseDecision)
|
|
168
184
|
assert(EnumUtils.isOfType(Enum.ProductPurchaseDecision, productPurchaseDecision), "Bad productPurchaseDecision")
|
|
169
185
|
|
|
170
186
|
self.ReceiptProcessed:Fire(receiptInfo, productPurchaseDecision)
|