Skip to content

Commit

Permalink
feat(subscription-hydration): also store instalments and sale_gross v…
Browse files Browse the repository at this point in the history
…alues
  • Loading branch information
stfsy committed Jan 17, 2023
1 parent 1ded858 commit d423e66
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/subscription-hydration.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,13 @@ class SubscriptionHydration {
email: subscription.user_email,
event_time: subscription.signup_date,
initial_payment: '1',
instalments: '1',
marketing_consent: subscription.marketing_consent,
next_bill_date: subscription.next_payment?.date || '',
next_payment_amount: subscription.next_payment?.amount || '',
passthrough: JSON.stringify({ '_pi': { ids: idsFromCustomData } }),
payment_method: subscription.payment_information.payment_method,
sale_gross: payment.amount,
quantity: subscription.quantity,
receipt_url: payment.receipt_url,
status: subscription.state,
Expand Down
2 changes: 2 additions & 0 deletions test-e2e/spec/hydration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ test('hydrates the initial payment too', async ({ page }) => {
expect(payment.email).toEqual(result.order.customer.email)
expect(new Date(payment.event_time).getTime()).toBeGreaterThanOrEqual(new Date(new Date().getTime() - 1000 * 60 * 60 * 2).getTime())
expect(payment.initial_payment).toEqual('1')
expect(payment.instalments).toEqual('1')
expect(new Date(payment.next_bill_date).getTime()).toBeGreaterThan(new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 28).getTime())
expect(payment.passthrough).toContain(apiClientId)
expect(parseFloat(payment.next_payment_amount)).toEqual(parseFloat(result.order.total))
Expand All @@ -148,6 +149,7 @@ test('hydrates the initial payment too', async ({ page }) => {
const urlWithoutHash = url.substring(0, indexOfSecondHyphen) + url.substring(indexOfSlashAfterHypen)
expect(urlWithoutHash).toEqual(result.order.receipt_url)
}
expect(payment.sale_gross).toEqual(result.order.total)
expect(payment.status).toEqual('active')
expect(payment.subscription_id).toEqual(result.order.subscription_id)
expect(payment.subscription_plan_id).toEqual(result.order.product_id)
Expand Down

0 comments on commit d423e66

Please sign in to comment.