Page MenuHomekolab.org

Wallet charge: top-ups and notifications
ClosedPublic

Authored by machniak on May 6 2020, 1:14 PM.

Details

Reviewers
vanmeeuwen
Group Reviewers
Restricted Project
Commits
rKc4f6f1b8b280: Wallet charge: top-ups and notifications
Summary

UI additions:

Diff Detail

Repository
rK kolab
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

machniak requested review of this revision.May 6 2020, 1:14 PM
machniak created this revision.
machniak updated this revision to Diff 3307.May 26 2020, 1:30 PM
  • Add some payment notification jobs/emails
  • More on auto-top-ups and disabling mandates
  • Added tests for two jobs
  • Tests for Mollie wallet top-ups
  • Rename templates
  • Fix parse error
  • Stripe: Webhook fixes, more tests
  • Add todo
machniak edited the summary of this revision. (Show Details)May 26 2020, 1:32 PM
machniak edited the summary of this revision. (Show Details)
machniak added a subscriber: Restricted Project.
machniak planned changes to this revision.May 27 2020, 11:52 AM
machniak updated this revision to Diff 3358.May 27 2020, 3:14 PM
  • More webhook tests, send notifications for recurring payments only
  • Disable auto-payment mandate on failed payment
  • Add payment success/failure notification emails with tests
  • Payment mandate disabled notification
  • Fix typos
  • Small improvements
  • Improve wording
machniak planned changes to this revision.May 27 2020, 3:15 PM
machniak edited the summary of this revision. (Show Details)
machniak updated this revision to Diff 3430.May 28 2020, 12:57 PM
  • Add some payment notification jobs/emails
  • More on auto-top-ups and disabling mandates
  • Added tests for two jobs
  • Tests for Mollie wallet top-ups
  • Rename templates
  • Fix parse error
  • Stripe: Webhook fixes, more tests
  • Add todo
  • More webhook tests, send notifications for recurring payments only
  • Disable auto-payment mandate on failed payment
  • Add payment success/failure notification emails with tests
  • Payment mandate disabled notification
  • Fix typos
  • Small improvements
  • Improve wording
  • Add fakeRender() for all templates
machniak planned changes to this revision.May 28 2020, 12:58 PM
machniak updated this revision to Diff 3466.May 29 2020, 4:29 PM
  • Update transaction log with payment description
  • Add wallet:mandate command to view/enable/disable auto-payment
  • Disabled mandate handling, test and fixed some flaky tests
machniak edited the summary of this revision. (Show Details)May 29 2020, 4:30 PM
machniak retitled this revision from WIP: Wallet charge: top-ups and notifications to Wallet charge: top-ups and notifications.

I set up auto-payment for CHF 50 for john@kolab.org using https://kanarip.dev.kolab.io/ and the mollie provider, clicking through the mollie interface with status 'paid', but the balance remained -9,99 after I executed a wallet:charge.

Am I missing something?

vanmeeuwen requested changes to this revision.Jun 2 2020, 11:44 AM
vanmeeuwen added inline comments.
src/tests/Unit/Mail/PaymentSuccessTest.php
42

This should be 'The auto-payment'.

Why not, here too, use:

$this->assertTrue(strpos($html, \trans('mail.paymentsuccess-subject', ['site' => $appName])) > 0);

?

This revision now requires changes to proceed.Jun 2 2020, 11:44 AM
[2020-06-02 09:52:50] local.DEBUG: C: POST https://kanarip.dev.kolab.io/api/v4/payments/mandate [5.8M]: 6.7196 sec.  
[2020-06-02 09:52:50] local.DEBUG: [SQL] select * from `users` where `id` = ? and `users`.`deleted_at` is null limit 1 [3502450530]  
[2020-06-02 09:52:50] local.DEBUG: [SQL] select * from `wallets` where `wallets`.`user_id` = ? and `wallets`.`user_id` is not null [3502450530]  
[2020-06-02 09:52:50] local.DEBUG: [SQL] select * from `wallet_settings` where `wallet_settings`.`wallet_id` = ? and `wallet_settings`.`wallet_id` is not null and (`key` = ?) limit 1 [a68f5ac9-1425-4691-9cf1-eb0947c0c657, mandate_amount]  
[2020-06-02 09:52:50] local.DEBUG: [SQL] select * from `wallet_settings` where `wallet_settings`.`wallet_id` = ? and `wallet_settings`.`wallet_id` is not null and (`key` = ?) limit 1 [a68f5ac9-1425-4691-9cf1-eb0947c0c657, mandate_balance]  
[2020-06-02 09:52:50] local.DEBUG: [SQL] select * from `wallet_settings` where `wallet_settings`.`wallet_id` = ? and `wallet_settings`.`wallet_id` is not null [a68f5ac9-1425-4691-9cf1-eb0947c0c657]  
[2020-06-02 09:52:51] local.DEBUG: [SQL] select * from `wallet_settings` where `wallet_settings`.`wallet_id` = ? and `wallet_settings`.`wallet_id` is not null and (`key` = ?) limit 1 [a68f5ac9-1425-4691-9cf1-eb0947c0c657, mollie_mandate_id]  
[2020-06-02 09:52:51] local.DEBUG: [SQL] update `wallet_settings` set `value` = ?, `wallet_settings`.`updated_at` = ? where `id` = ? [mdt_QHSWvmRxxF, 2020-06-02 09:52:51, 4]  
[2020-06-02 09:52:51] local.DEBUG: [SQL] select * from `wallet_settings` where `wallet_settings`.`wallet_id` = ? and `wallet_settings`.`wallet_id` is not null [a68f5ac9-1425-4691-9cf1-eb0947c0c657]  
[2020-06-02 09:52:51] local.DEBUG: C: POST https://kanarip.dev.kolab.io/api/v4/payments/mandate [5.7M]: 0.7062 sec.  
[2020-06-02 09:53:09] local.DEBUG: [SQL] select * from `payments` where `payments`.`id` = ? limit 1 [tr_nr4hDVveMc]  
[2020-06-02 09:53:09] local.DEBUG: C: POST https://kanarip.dev.kolab.io/api/webhooks/payment/mollie [5M]: 0.0141 sec.  
[2020-06-02 09:53:09] local.DEBUG: C: GET https://kanarip.dev.kolab.io/wallet [4.4M]: 0.0398 sec.  
[2020-06-02 09:53:14] local.DEBUG: [SQL] select * from `users` where `id` = ? and `users`.`deleted_at` is null limit 1 [3502450530]  
[2020-06-02 09:53:14] local.DEBUG: [SQL] select * from `user_settings` where `user_settings`.`user_id` = ? and `user_settings`.`user_id` is not null and `key` in (?, ?, ?, ?, ?, ?, ?, ?) [3502450530, billing_address, country, currency, external_email, first_name, last_name, organization, phone]  
[2020-06-02 09:53:14] local.DEBUG: [SQL] select * from `user_aliases` where `user_aliases`.`user_id` = ? and `user_aliases`.`user_id` is not null [3502450530]  
[2020-06-02 09:53:14] local.DEBUG: [SQL] select * from `domains` where `namespace` = ? and `domains`.`deleted_at` is null limit 1 [kolab.org]  
[2020-06-02 09:53:14] local.DEBUG: [SQL] select * from `wallets` where `wallets`.`user_id` = ? and `wallets`.`user_id` is not null [3502450530]  
[2020-06-02 09:53:14] local.DEBUG: [SQL] select `wallets`.*, `user_accounts`.`user_id` as `pivot_user_id`, `user_accounts`.`wallet_id` as `pivot_wallet_id` from `wallets` inner join `user_accounts` on `wallets`.`id` = `user_accounts`.`wallet_id` where `user_accounts`.`user_id` = ? [3502450530]  
[2020-06-02 09:53:14] local.DEBUG: [SQL] select * from `entitlements` where `entitlements`.`entitleable_id` = ? and `entitlements`.`entitleable_id` is not null and `entitlements`.`entitleable_type` = ? and `entitlements`.`deleted_at` is null limit 1 [3502450530, App\User]  
[2020-06-02 09:53:14] local.DEBUG: [SQL] select * from `wallets` where `wallets`.`id` = ? limit 1 [a68f5ac9-1425-4691-9cf1-eb0947c0c657]  
[2020-06-02 09:53:14] local.DEBUG: C: GET https://kanarip.dev.kolab.io/api/auth/info [5.2M]: 0.0176 sec.  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `wallets` []  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `entitlements` where `entitlements`.`wallet_id` = ? and `entitlements`.`wallet_id` is not null and `entitlements`.`deleted_at` is null [130ee29b-3be0-4765-a3c1-e3eff405fb72]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `entitlements` where `entitlements`.`wallet_id` = ? and `entitlements`.`wallet_id` is not null and `entitlements`.`deleted_at` is null [2bfe7b05-a3b5-4d0b-8d0b-b6ad6ab2c2a6]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `entitlements` where `entitlements`.`wallet_id` = ? and `entitlements`.`wallet_id` is not null and `entitlements`.`deleted_at` is null [58d0e908-4e97-4bd2-a560-60abebb8396c]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `entitlements` where `entitlements`.`wallet_id` = ? and `entitlements`.`wallet_id` is not null and `entitlements`.`deleted_at` is null [6af7868e-d2e7-4292-b7d0-fa48daa7c8c8]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `entitlements` where `entitlements`.`wallet_id` = ? and `entitlements`.`wallet_id` is not null and `entitlements`.`deleted_at` is null [6e0d02fc-ab3e-41fd-aca9-1dca549b8468]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `entitlements` where `entitlements`.`wallet_id` = ? and `entitlements`.`wallet_id` is not null and `entitlements`.`deleted_at` is null [70ff3911-5969-45fa-a7d5-a135098fb74f]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `entitlements` where `entitlements`.`wallet_id` = ? and `entitlements`.`wallet_id` is not null and `entitlements`.`deleted_at` is null [756d00f3-2e21-454b-ad80-c5c4124446e5]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `entitlements` where `entitlements`.`wallet_id` = ? and `entitlements`.`wallet_id` is not null and `entitlements`.`deleted_at` is null [7a65bd5e-54ad-44e0-a311-8e2369778a8f]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `entitlements` where `entitlements`.`wallet_id` = ? and `entitlements`.`wallet_id` is not null and `entitlements`.`deleted_at` is null [9569982c-a092-4260-ba52-29050c70f878]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `entitlements` where `entitlements`.`wallet_id` = ? and `entitlements`.`wallet_id` is not null and `entitlements`.`deleted_at` is null [a68f5ac9-1425-4691-9cf1-eb0947c0c657]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `entitlements` where `id` in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [04a2562c-fcdc-4e62-b31c-fa82ed2ec6bc, 1626ec3e-10d9-4c01-9ddb-511bfb937dbf, 29ee7a84-cbd3-4878-a771-9ccb36685cfb, 37658d29-1433-4b57-880b-e0ba1d6672dc, 4526d709-81ec-4795-b5a6-e3db8a7bb724, 4736d839-a797-43fb-ac07-5ba07321a439, 4827c232-75ef-4791-9b43-c42f3580a10f, 495437a4-5c1d-4b7b-ad57-93dc7bb785ca, 4f9936df-c36b-4f7d-8d2c-39b49d1f996d, 703a9067-c22a-4981-947d-1bec9fbb0e4a, 81b1741f-cd7b-4b28-a009-2e97127caada, 81bcef55-6a1d-41dc-a85b-d901e60a9f1b, 832b65d6-9cdd-4fd5-a53f-afb15dccd86b, 90fa6408-40e3-4737-9cd5-bae201b3ee7e, 927a7128-89cb-40de-875f-d116c9f6a8f8, b12c478a-594e-4da9-8757-212a86fed750, b26e1d74-e098-4696-8a2b-82ff20eabf0b, ea603f31-093a-453e-9ddf-9f5dcf9acd41]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] update `entitlements` set `entitlements`.`updated_at` = ? where `id` = ? [2020-06-02 09:52:13, 37658d29-1433-4b57-880b-e0ba1d6672dc]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] update `entitlements` set `entitlements`.`updated_at` = ? where `id` = ? [2020-06-02 09:52:13, 4736d839-a797-43fb-ac07-5ba07321a439]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `transactions` where `transactions`.`id` = ? limit 1 [1202e276-a798-4c9a-b595-46442d94cad7]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] insert into `transactions` (`user_email`, `object_id`, `object_type`, `type`, `amount`, `id`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?, ?, ?) [, 4736d839-a797-43fb-ac07-5ba07321a439, App\Entitlement, billed, 555, 1202e276-a798-4c9a-b595-46442d94cad7, 2020-06-02 09:53:28, 2020-06-02 09:53:28]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] update `entitlements` set `entitlements`.`updated_at` = ? where `id` = ? [2020-06-02 09:52:13, 4827c232-75ef-4791-9b43-c42f3580a10f]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] update `entitlements` set `entitlements`.`updated_at` = ? where `id` = ? [2020-06-02 09:52:13, 495437a4-5c1d-4b7b-ad57-93dc7bb785ca]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `transactions` where `transactions`.`id` = ? limit 1 [8e8ab001-f5fd-49f9-8397-f9936daa9991]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] insert into `transactions` (`user_email`, `object_id`, `object_type`, `type`, `amount`, `id`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?, ?, ?) [, 495437a4-5c1d-4b7b-ad57-93dc7bb785ca, App\Entitlement, billed, 444, 8e8ab001-f5fd-49f9-8397-f9936daa9991, 2020-06-02 09:53:28, 2020-06-02 09:53:28]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] update `wallets` set `balance` = ? where `id` = ? [-999, a68f5ac9-1425-4691-9cf1-eb0947c0c657]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `transactions` where `transactions`.`id` = ? limit 1 [734b2767-0c46-4f1d-ba80-707b92f557ff]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] insert into `transactions` (`user_email`, `object_id`, `object_type`, `type`, `amount`, `id`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?, ?, ?) [, a68f5ac9-1425-4691-9cf1-eb0947c0c657, App\Wallet, debit, 999, 734b2767-0c46-4f1d-ba80-707b92f557ff, 2020-06-02 09:53:28, 2020-06-02 09:53:28]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] update `transactions` set `transaction_id` = ?, `transactions`.`updated_at` = ? where `id` in (?, ?) [734b2767-0c46-4f1d-ba80-707b92f557ff, 2020-06-02 09:53:28, 1202e276-a798-4c9a-b595-46442d94cad7, 8e8ab001-f5fd-49f9-8397-f9936daa9991]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `users` where `users`.`id` = ? and `users`.`deleted_at` is null limit 1 [3502450530]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `entitlements` where `entitlements`.`wallet_id` = ? and `entitlements`.`wallet_id` is not null and `entitlements`.`deleted_at` is null [b9b92209-a329-4a40-8460-021617425287]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `entitlements` where `entitlements`.`wallet_id` = ? and `entitlements`.`wallet_id` is not null and `entitlements`.`deleted_at` is null [ccc43a57-a5d8-42c3-b120-43049da9ddff]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `entitlements` where `entitlements`.`wallet_id` = ? and `entitlements`.`wallet_id` is not null and `entitlements`.`deleted_at` is null [cfba5a16-934e-450b-ab75-a6748b99754a]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `entitlements` where `entitlements`.`wallet_id` = ? and `entitlements`.`wallet_id` is not null and `entitlements`.`deleted_at` is null [ede1a4a0-4e18-4758-8f72-57337c23bd1d]  
[2020-06-02 09:53:28] local.DEBUG: [SQL] select * from `entitlements` where `entitlements`.`wallet_id` = ? and `entitlements`.`wallet_id` is not null and `entitlements`.`deleted_at` is null [fb248b72-bf60-4db3-9a0d-348962e3e0ac]  
[2020-06-02 09:53:39] local.DEBUG: C: GET https://kanarip.dev.kolab.io/wallet [4.4M]: 0.0905 sec.  
[2020-06-02 09:53:44] local.DEBUG: [SQL] select * from `users` where `id` = ? and `users`.`deleted_at` is null limit 1 [3502450530]  
[2020-06-02 09:53:44] local.DEBUG: [SQL] select * from `user_settings` where `user_settings`.`user_id` = ? and `user_settings`.`user_id` is not null and `key` in (?, ?, ?, ?, ?, ?, ?, ?) [3502450530, billing_address, country, currency, external_email, first_name, last_name, organization, phone]  
[2020-06-02 09:53:44] local.DEBUG: [SQL] select * from `user_aliases` where `user_aliases`.`user_id` = ? and `user_aliases`.`user_id` is not null [3502450530]  
[2020-06-02 09:53:44] local.DEBUG: [SQL] select * from `domains` where `namespace` = ? and `domains`.`deleted_at` is null limit 1 [kolab.org]  
[2020-06-02 09:53:44] local.DEBUG: [SQL] select * from `wallets` where `wallets`.`user_id` = ? and `wallets`.`user_id` is not null [3502450530]  
[2020-06-02 09:53:44] local.DEBUG: [SQL] select `wallets`.*, `user_accounts`.`user_id` as `pivot_user_id`, `user_accounts`.`wallet_id` as `pivot_wallet_id` from `wallets` inner join `user_accounts` on `wallets`.`id` = `user_accounts`.`wallet_id` where `user_accounts`.`user_id` = ? [3502450530]  
[2020-06-02 09:53:44] local.DEBUG: [SQL] select * from `entitlements` where `entitlements`.`entitleable_id` = ? and `entitlements`.`entitleable_id` is not null and `entitlements`.`entitleable_type` = ? and `entitlements`.`deleted_at` is null limit 1 [3502450530, App\User]  
[2020-06-02 09:53:44] local.DEBUG: [SQL] select * from `wallets` where `wallets`.`id` = ? limit 1 [a68f5ac9-1425-4691-9cf1-eb0947c0c657]  
[2020-06-02 09:53:44] local.DEBUG: C: GET https://kanarip.dev.kolab.io/api/auth/info [5.2M]: 0.0189 sec.
machniak updated this revision to Diff 3478.Jun 3 2020, 9:37 AM
  • Fix Stripe auto-payment charge
  • Fix Mollie auto-payment
  • Add more tests
machniak added inline comments.Jun 3 2020, 9:41 AM
src/tests/Unit/Mail/PaymentSuccessTest.php
42

We could use trans() here. However, what if the localization is broken? Also, some labels might contain characters that are converted to html entities (or nl2br) which would make a difference. So, I'd keep it this way.

vanmeeuwen requested changes to this revision.Jun 3 2020, 10:54 AM
vanmeeuwen added inline comments.
src/app/Providers/Payment/Mollie.php
251

Typo.

This revision now requires changes to proceed.Jun 3 2020, 10:54 AM
machniak updated this revision to Diff 3484.Jun 3 2020, 12:14 PM
  • Fix typo
vanmeeuwen accepted this revision.Jun 3 2020, 12:18 PM
This revision is now accepted and ready to land.Jun 3 2020, 12:18 PM
This revision was automatically updated to reflect the committed changes.