Commit Graph

60 Commits

Author SHA1 Message Date
Evan Hahn
f5556d1857
Use durable job for sending badge gifts
Previously, sending a gift badge was not a durable operation, which
meant that crashes/failures could cause users to have their payment
methods charged without actually sending the badge.

Now, the flow is split up into two steps: non-durable parts before the
charge is attempted, and durable parts afterward.

The high-level flow is:

1. Prepare the payment, which involves a couple of repeatable network
   requests.
2. Enqueue a job with the prepared payment, that:
   1. Charges the payment method (idempotently)
   2. Requests a receipt credential (idempotently)
   3. Enqueues a gift message, and optionally a text message
3. When the job completes, open the conversation in the UI.
2022-07-01 17:10:31 -05:00
Max Radermacher
f7f66d6436
Add support for redeeming gift badges 2022-07-01 14:07:24 -07:00
Max Radermacher
807ea6e034
Simplify …BadgeIds.contains(_:)
There’s no need to use `allCases` -- we can accomplish the same thing
using the automatically-provided `init(rawValue:)` initializer.
2022-06-28 17:15:14 -07:00
Evan Hahn
f4714b1a83 Basic support for sending gift badges
If you've got the `giftBadgeSending` flag enabled, you can now send gift
badges to anyone who has the capability.

This commit doesn't complete the feature, though. It is missing:

- Proper durability and error handling (to be addressed separately)
- Saving of receipts
- A few other cleanups
2022-06-22 15:50:51 +00:00
Max Radermacher
c0a85b888b
Add rendering support for Gift Badges
Co-authored-by: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com>
2022-06-22 08:05:25 -07:00
Evan Hahn
a1eb9e3042 Clean up boostCreatePaymentIntent()
This makes a few small changes to `OWSRequestFactory.boostCreatePaymentIntent()`:

- Adds tests
- Rewrites the function in Swift

I made sure I could do a boost (in staging) in the simulator.
2022-06-21 17:33:28 +00:00
Max Radermacher
05ed931b10 Convert boost/gift badge constants to an enum 2022-06-09 15:01:22 -07:00
Evan Hahn
d2836235af Show additional details for subscription charge failures
In c5bdf6c094, we started to show errors
when a subscription failed to renew because of a charge failure.

Now, we show additional text depending on what the charge failure was.
For example, if you had an invalid card number, we show a special string
for that.
2022-05-25 18:17:53 +00:00
Evan Hahn
baddc85564 Add first gift badge screen
This adds the first screen for badge gifting. It lets you see the gift
badge, pick the currency, and advance to the next screen.

It also adds a skeleton for the next screen, so there's somewhere to
advance to, but that screen is unfinished.

All of this is behind disabled flags, so this should have no user
impact.
2022-05-19 14:07:23 +00:00
Evan Hahn
29c0ddf60e Fix violations of SwiftLint's attributes rule
_I recommend reviewing this with whitespace changes disabled._

Most of these were `@objc` being on the same line, which I fixed with [a
silly script][1]—probably could've used `sed` if I were wiser. The rest
were manual fixes.

See [the SwiftLint documentation for this rule][0].

[0]: https://realm.github.io/SwiftLint/attributes.html
[1]: https://gist.github.com/EvanHahn-Signal/d353c93fa269c82b96baca0a1086521f
2022-05-14 09:07:42 -05:00
Evan Hahn
57ea808a3c Simplify Subscription constructor
This is a followup to c5bdf6c094.
2022-05-13 14:08:32 -05:00
Evan Hahn
8721d4e2a5 Skeleton "choose gift badge" screen
It doesn't do anything yet, but an image and some text is there.

This is all behind a feature flag, so this should have no user impact.
2022-05-13 13:25:36 -05:00
Evan Hahn
c5bdf6c094 Improve subscription charge error UI
Currently, when your subscription expires due a charge failure, we
incorrectly tell you that it's due to inactivity. This fixes that, by
telling you about the charge failure.

This is a bit difficult to test on its own, so I:

- Faked out the smallest pieces I could in an effort to test states
  manually
- Created `BadgeErrorSheetState` which is pretty thoroughly tested
2022-05-12 18:28:14 -05:00
Max Radermacher
34767e8beb Increase accepted receipt credential time to 90d
Per IOS-2387.
2022-05-03 10:20:10 -05:00
Max Radermacher
88a28c3457 Fix typos: Reciept → Receipt 2022-04-29 12:14:09 -07:00
Evan Hahn
67ea0d0516 Fix some trivial compiler warnings
This fixes 10 of our Xcode warnings:

- `MessageReactionPicker.swift` was declaring a variable and not using
  it, leading to "Immutable value 'emoji' was never used". I simply
  removed it.
- `Stripe.swift` had a bunch of unnecessary `public`s, which caused
  "'public' modifier is redundant for static property declared in a
  public extension".
- `SubscriptionManager.swift` had an unnecessary `try`, causing "No
  calls to throwing functions occur within 'try' expression".
- `CallService.swift:696` was calling a function and not using its
  result, so I annotated that function with `@discardableResult`.
- `MobileCoinAPI+Configuration.swift` declared a variable with `var`
  that should've used `let`.

Nothing major here, but wanted to find ones that were easy to fix.
2022-04-19 09:28:15 -05:00
Evan Hahn
8b072620a6 Add "Donation Receipts" view 2022-04-11 16:21:12 -05:00
Nora Trapp
05313c3725 Update to LibSignalClient v0.15.0 2022-03-24 11:55:45 -07:00
Dimitris Apostolou
62724cf0be Fix typos 2022-03-18 11:31:06 -07:00
Martin Böttcher
8f9be31ba3 replaced NSLocalizedStringFromAppBundle with OWSLocalizedString 2022-03-08 10:17:25 +01:00
Martin Böttcher
c0adfbfb32 NSLocalizedString is replaced by NSLocalizedStringFromAppBundle (reading strings from the bundle of the main app) for all source files called by an app extension and the localizable files are removed for the app extension targets. 2022-03-07 13:29:06 +01:00
Martin Böttcher
c4f967ef46
removed checks testing for iOS12.0 or newer (#4030) 2022-02-25 17:39:12 +01:00
Evan Hahn
0ffba32ba3 Cancel subscription when deleting account 2022-02-24 16:51:09 -06:00
Nora Trapp
aeaf5d86d6 Don't show subscription megaphone again until your subscription has been expired for at least 2 weeks 2022-02-11 13:09:20 -08:00
Nora Trapp
a2f51dc4a3 Cleanup old feature flags 2022-01-24 10:53:55 -08:00
Nora Trapp
db115606e3 Remove ZKGroup 2022-01-03 12:00:19 -08:00
Nora Trapp
c81dfcdb0d Stripe uses american spelling of 'canceled' 2022-01-03 10:55:49 -08:00
Nora Trapp
877b9ced6e Fix forced unwraps in SubscriptionManager 2022-01-03 10:28:44 -08:00
Nora Trapp
f2c09045ca Sync additional badge info with storage service 2021-12-17 14:07:40 -08:00
Nora Trapp
8da582715f Fix badge expiry 2021-12-17 14:04:42 -08:00
Eugene Bistolas
4f1b8b6002 [Badging] Expiry state incorrectly forward carried 2021-12-17 14:01:02 -08:00
Eugene Bistolas
349479d328 [Badging] Last expiring badge is not invalidated when expected 2021-12-17 14:00:56 -08:00
Eugene Bistolas
7682ad23f6 [Badging] Subscription badge expiry UI 2021-12-17 13:59:38 -08:00
Eugene Bistolas
5dd35ae9f8 [Badging] Signal devices when subscription status changes 2021-12-17 13:58:47 -08:00
Eugene Bistolas
93a59cb0f2 [Badging] Determine if user has current subscription via cached data 2021-12-17 13:58:39 -08:00
Eugene Bistolas
07610dbe96 [Badging] Ensure client does not reredeem badge receipts unnecessairly 2021-11-29 11:35:29 -10:00
Nora Trapp
0c8e6a087b Add support for donations with Maestro cards 2021-11-29 11:35:17 -10:00
Eugene Bistolas
b41cbca9e8 [Badging] Cancel and re-initiate subscription if level is upgraded under payment failure 2021-11-29 11:34:57 -10:00
Eugene Bistolas
aadf5c137d [Badging] Remove receipt emails from subscription/boosts 2021-11-23 14:47:25 -10:00
Eugene Bistolas
a9a30e4959 [Badging] redemption failure feedback 2021-11-23 11:32:48 -10:00
Eugene Bistolas
7d4310cd36 [Badging] Better handling of durable job HTTP failures 2021-11-23 11:23:41 -10:00
Eugene Bistolas
a3e625e0a8 [Badging] Handle incomplete state from Stripe per server spec 2021-11-23 09:51:47 -10:00
Eugene Bistolas
8a2dfcb09e [Badging] Handle receipt redemption 402 errors, set key if user cancels subscription 2021-11-22 13:53:45 -10:00
Nora Trapp
14fedf2450 Make boost redemption retryable 2021-11-18 13:29:30 -08:00
Nora Trapp
18a7ad8b2c Fix badge visibility on acquisition 2021-11-17 16:05:58 -08:00
Eugene Bistolas
64801e3167 [Badging] Allow subscription and boost flows if Apple Pay is supported in region 2021-11-17 13:23:00 -10:00
Nora Trapp
edc89c3db1 Store badge receipt credential presentation on the durable job 2021-11-17 15:14:03 -08:00
Eugene Bistolas
a3662309c8 [Badging] Boost durable receipt redemption + apple pay cancellation, plus polish 2021-11-17 09:29:02 -10:00
Nora Trapp
faba7621b3 Include the donor's email address for receipt purposes in the billing information 2021-11-16 15:39:39 -08:00
Nora Trapp
db692be18d Hook up badge visibility on thanks sheet 2021-11-16 11:40:40 -08:00