Skip to content

Commit d423e66

Browse files
committed
feat(subscription-hydration): also store instalments and sale_gross values
1 parent 1ded858 commit d423e66

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

lib/subscription-hydration.js

+2
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,13 @@ class SubscriptionHydration {
152152
email: subscription.user_email,
153153
event_time: subscription.signup_date,
154154
initial_payment: '1',
155+
instalments: '1',
155156
marketing_consent: subscription.marketing_consent,
156157
next_bill_date: subscription.next_payment?.date || '',
157158
next_payment_amount: subscription.next_payment?.amount || '',
158159
passthrough: JSON.stringify({ '_pi': { ids: idsFromCustomData } }),
159160
payment_method: subscription.payment_information.payment_method,
161+
sale_gross: payment.amount,
160162
quantity: subscription.quantity,
161163
receipt_url: payment.receipt_url,
162164
status: subscription.state,

test-e2e/spec/hydration.spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ test('hydrates the initial payment too', async ({ page }) => {
134134
expect(payment.email).toEqual(result.order.customer.email)
135135
expect(new Date(payment.event_time).getTime()).toBeGreaterThanOrEqual(new Date(new Date().getTime() - 1000 * 60 * 60 * 2).getTime())
136136
expect(payment.initial_payment).toEqual('1')
137+
expect(payment.instalments).toEqual('1')
137138
expect(new Date(payment.next_bill_date).getTime()).toBeGreaterThan(new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 28).getTime())
138139
expect(payment.passthrough).toContain(apiClientId)
139140
expect(parseFloat(payment.next_payment_amount)).toEqual(parseFloat(result.order.total))
@@ -148,6 +149,7 @@ test('hydrates the initial payment too', async ({ page }) => {
148149
const urlWithoutHash = url.substring(0, indexOfSecondHyphen) + url.substring(indexOfSlashAfterHypen)
149150
expect(urlWithoutHash).toEqual(result.order.receipt_url)
150151
}
152+
expect(payment.sale_gross).toEqual(result.order.total)
151153
expect(payment.status).toEqual('active')
152154
expect(payment.subscription_id).toEqual(result.order.subscription_id)
153155
expect(payment.subscription_plan_id).toEqual(result.order.product_id)

0 commit comments

Comments
 (0)