@@ -15,6 +15,7 @@ const subscriptionInfo = new SubscriptionInfo('api_client', { hookStorage: paddl
15
15
const storage = require ( '../../lib/firestore/nested-firestore-resource' ) ( { documentPath : 'api_client' , resourceName : 'api_clients' } )
16
16
17
17
const { expect } = require ( 'chai' )
18
+ const { customData } = require ( '../../lib/client' )
18
19
19
20
describe ( 'PaddleIntegration' , ( ) => {
20
21
@@ -28,7 +29,7 @@ describe('PaddleIntegration', () => {
28
29
29
30
describe ( '.addSubscription' , ( ) => {
30
31
it ( 'creates an aactive subscription' , async ( ) => {
31
- const createPayload = Object . assign ( { } , subscriptionCreated , { passthrough : JSON . stringify ( { ids } ) } )
32
+ const createPayload = Object . assign ( { } , subscriptionCreated , { passthrough : JSON . stringify ( customData ( ids ) ) } )
32
33
33
34
await paddleIntegration . addSubscriptionCreatedStatus ( createPayload )
34
35
const { subscription : sub } = await storage . get ( ids )
@@ -38,7 +39,7 @@ describe('PaddleIntegration', () => {
38
39
it ( 'stores subscription related info' , async ( ) => {
39
40
const createPayload = Object . assign ( { } , subscriptionCreated ,
40
41
{
41
- subscription_id : uuid ( ) , passthrough : JSON . stringify ( { ids } )
42
+ subscription_id : uuid ( ) , passthrough : JSON . stringify ( customData ( ids ) )
42
43
}
43
44
)
44
45
await paddleIntegration . addSubscriptionCreatedStatus ( createPayload )
@@ -80,14 +81,14 @@ describe('PaddleIntegration', () => {
80
81
81
82
const createPayload = Object . assign ( { } , subscriptionCreated ,
82
83
{
83
- subscription_id : subscriptionId , passthrough : JSON . stringify ( { ids } )
84
+ subscription_id : subscriptionId , passthrough : JSON . stringify ( customData ( ids ) )
84
85
}
85
86
)
86
87
await paddleIntegration . addSubscriptionCreatedStatus ( createPayload )
87
88
88
89
const updatePayload = Object . assign ( { } , subscriptionUpdated ,
89
90
{
90
- subscription_id : subscriptionId , passthrough : JSON . stringify ( { ids } )
91
+ subscription_id : subscriptionId , passthrough : JSON . stringify ( customData ( ids ) )
91
92
}
92
93
)
93
94
await paddleIntegration . addSubscriptionUpdatedStatus ( updatePayload )
@@ -168,15 +169,15 @@ describe('PaddleIntegration', () => {
168
169
169
170
const createPayload = Object . assign ( { } , subscriptionCreated ,
170
171
{
171
- subscription_id : subscriptionId , passthrough : JSON . stringify ( { ids } )
172
+ subscription_id : subscriptionId , passthrough : JSON . stringify ( customData ( ids ) )
172
173
}
173
174
)
174
175
await paddleIntegration . addSubscriptionCreatedStatus ( createPayload )
175
176
176
177
const payload = Object . assign ( { } , subscriptionCancelled ,
177
178
{
178
179
subscription_id : subscriptionId ,
179
- passthrough : JSON . stringify ( { ids } ) ,
180
+ passthrough : JSON . stringify ( customData ( ids ) ) ,
180
181
cancellation_effective_date : new Date ( new Date ( ) . getTime ( ) - 1000 ) . toISOString ( )
181
182
}
182
183
)
@@ -191,15 +192,15 @@ describe('PaddleIntegration', () => {
191
192
192
193
const createPayload = Object . assign ( { } , subscriptionCreated ,
193
194
{
194
- subscription_id : subscriptionId , passthrough : JSON . stringify ( { ids } )
195
+ subscription_id : subscriptionId , passthrough : JSON . stringify ( customData ( ids ) )
195
196
}
196
197
)
197
198
await paddleIntegration . addSubscriptionCreatedStatus ( createPayload )
198
199
199
200
const cancelPayload = Object . assign ( { } , subscriptionCancelled ,
200
201
{
201
202
subscription_id : subscriptionId ,
202
- passthrough : JSON . stringify ( { ids } ) ,
203
+ passthrough : JSON . stringify ( customData ( ids ) ) ,
203
204
cancellation_effective_date : new Date ( new Date ( ) . getTime ( ) - 1000 ) . toISOString ( )
204
205
}
205
206
)
@@ -233,7 +234,7 @@ describe('PaddleIntegration', () => {
233
234
const subscriptionId = uuid ( )
234
235
const createPayload = Object . assign ( { } , subscriptionCreated , {
235
236
subscription_id : subscriptionId ,
236
- passthrough : JSON . stringify ( { ids } ) ,
237
+ passthrough : JSON . stringify ( customData ( ids ) ) ,
237
238
} )
238
239
await paddleIntegration . addSubscriptionCreatedStatus ( createPayload )
239
240
@@ -242,7 +243,7 @@ describe('PaddleIntegration', () => {
242
243
243
244
const paymentPayload = Object . assign ( { } , paymentSucceded , {
244
245
subscription_id : subscriptionId ,
245
- passthrough : JSON . stringify ( { ids } ) ,
246
+ passthrough : JSON . stringify ( customData ( ids ) ) ,
246
247
} )
247
248
await paddleIntegration . addSuccessfulPayment ( paymentPayload ) ;
248
249
@@ -259,13 +260,13 @@ describe('PaddleIntegration', () => {
259
260
const subscriptionId = uuid ( )
260
261
const createPayload = Object . assign ( { } , subscriptionCreated , {
261
262
subscription_id : subscriptionId ,
262
- passthrough : JSON . stringify ( { ids } ) ,
263
+ passthrough : JSON . stringify ( customData ( ids ) ) ,
263
264
} )
264
265
await paddleIntegration . addSubscriptionCreatedStatus ( createPayload )
265
266
266
267
const paymentPayload = Object . assign ( { } , paymentRefunded , {
267
268
subscription_id : subscriptionId ,
268
- passthrough : JSON . stringify ( { ids } ) ,
269
+ passthrough : JSON . stringify ( customData ( ids ) ) ,
269
270
} )
270
271
await paddleIntegration . addRefundedPayment ( paymentPayload )
271
272
@@ -283,13 +284,13 @@ describe('PaddleIntegration', () => {
283
284
const subscriptionId = uuid ( )
284
285
const createPayload = Object . assign ( { } , subscriptionCreated , {
285
286
subscription_id : subscriptionId ,
286
- passthrough : JSON . stringify ( { ids } ) ,
287
+ passthrough : JSON . stringify ( customData ( ids ) ) ,
287
288
} )
288
289
await paddleIntegration . addSubscriptionCreatedStatus ( createPayload )
289
290
290
291
const paymentPayload = Object . assign ( { } , paymentFailed , {
291
292
subscription_id : subscriptionId ,
292
- passthrough : JSON . stringify ( { ids } ) ,
293
+ passthrough : JSON . stringify ( customData ( ids ) ) ,
293
294
} )
294
295
await paddleIntegration . addFailedPayment ( paymentPayload )
295
296
0 commit comments