Commit Graph

15 Commits

Author SHA1 Message Date
Max Radermacher
2f0bc4a690
Require a serviceId for storage service contacts 2023-02-13 12:44:45 -08:00
Max Radermacher
db2678e86b
Filter storage service contacts more consistently 2023-02-13 10:48:54 -08:00
Max Radermacher
3417fe2e20
Handle system contacts on linked devices
* Remove old migration code
* Rename some files
2023-02-01 16:18:59 -08:00
Max Radermacher
e454eea2da
Refactor, optimize, and test setContactsMaps 2023-01-13 13:56:39 -08:00
Evan Hahn
9f292a91cd Change error string for minimum donation amount
Before, the error said "Select a larger amount to donate."

Now the error says something like "The minimum amount you can donate is
$3."
2022-12-12 15:46:32 -06:00
Sasha Weiss
40e765fa4f Integrate the /v1/subscription/configuration API 2022-12-01 14:39:03 -08:00
Sasha Weiss
da63036758 Move money amounts to DonationUtilities instead of Stripe 2022-12-01 14:39:03 -08:00
Evan Hahn
890fa72c97
Donations: remove client-side maximum amount check
This should be enforced by the server.
2022-11-29 17:17:46 -06:00
Evan Hahn
0700f81817
Support 3D Secure for card donations
[3D Secure][0] is an additional authentication layer that some
credit/debit cards use. Typically, users open a browser and do some
authentication check before the transaction can proceed.

This adds 3DS support for credit/debit card donations.

If you want to try this yourself, I recommend using one of [Stripe's
test 3DS cards][1] in a staging build.

See also: [the equivalent commit in Signal Android][0].

[0]: https://stripe.com/docs/payments/3d-secure
[1]: https://stripe.com/docs/payments/3d-secure?platform=ios#three-ds-cards
[2]: d1df069669
2022-11-29 16:07:44 -06:00
Evan Hahn
4675434c6c Add FiatMoney type
This change should have no user impact.

We commonly pair a currency, like USD, and an amount, like 1.23. This
adds the `FiatMoney` struct. It's a simple struct with two fields.

After adding it, I tried to use it everywhere. (It's possible I missed a
spot.)

I think this is a useful change on its own, but it'll be nice for an
upcoming change, too.

See also: [Android's equivalent class][0].

[0]: cb65347bb3/core-util/src/main/java/org/signal/core/util/money/FiatMoney.java (L1)
2022-10-26 17:04:51 -05:00
Evan Hahn
623b1909b2
Prefer Decimal over NSDecimalNumber
This change should have no user impact.

We use `NSDecimalNumber` and `Decimal`. This tries to standardize on
`Decimal` where possible (though the former is still needed in a few
places).

Mostly a mechanical change, though a few little things changed.
2022-10-18 09:43:46 -05:00
Evan Hahn
10a78d6033
Clean up min/max checks for Stripe payments
We check whether a payment amount is too small or too large. This makes
a few changes:

- `isAmountTooLarge` was correct except for [IDR][1], which has a
  larger limit according to [Stripe's docs][0].
- Added docs for `isAmountTooSmall` and `isAmountTooLarge`.
- Updated rounding to use "normal" rounding instead of "banker's
  rounding".

[0]: https://stripe.com/docs/currencies?presentment-currency=US#minimum-and-maximum-charge-amounts
[1]: https://en.wikipedia.org/wiki/Indonesian_rupiah
2022-10-17 13:45:57 -05:00
Evan Hahn
62fe2fbcc0 Test donation "is amount too {large,small}" methods
This change should have no user impact. It just tests things.

I was working in this area and thought these were broken, so I started
writing tests. I was wrong, but I still think the tests are worth
keeping.
2022-10-14 10:11:02 -07:00
Evan Hahn
370ff654e7
Change license to AGPL
Change license to AGPL

This commit:

- Updates the `LICENSE` file

- Start every file with something like:

      // Copyright YEAR_FIRST_PUBLISHED Signal Messenger, LLC
      // SPDX-License-Identifier: AGPL-3.0-only

---

First, I removed existing license headers with this Ruby 3.1.2 script:

    require 'set'

    EXTENSIONS_TO_CHECK = Set['.h', '.hpp', '.cpp', '.m', '.mm', '.pch', '.swift']

    same = 0
    different = 0

    all_files = `git ls-files`.lines.map { |line| line.strip }
    all_files.each do |relative_path|
      if relative_path == 'Pods'
        next
      end

      unless EXTENSIONS_TO_CHECK.include? File.extname(relative_path)
        next
      end

      path = File.expand_path(relative_path)

      contents = File.read(path)
      new_contents = contents.sub(/\/\/\n\/\/  Copyright .*\n\/\/\n\n/, '')

      if contents == new_contents
        same += 1
      else
        different += 1
      end

      File.write(path, new_contents)
    end

    puts "updated #{different} file(s), left #{same} untouched"

I'm sure this script could be improved, but it worked well enough.

Then, I created `Scripts/lint/lint-license-headers` and ran it to auto-
fix a lot of files. This changed the mode of some files, but I think
that's actually desirable. For example,
`SignalServiceKit/src/Util/AppContext.m` previously had a mode of
`0755/-rwxr-xr-x`, and it's now `0644/-rw-r--r--`.

Then I fixed some stragglers and updated the precommit script.

See [a similar change in the Desktop app][0].

[0]: 8bfaf598af
2022-10-13 08:25:37 -05:00
Evan Hahn
e679707038 Fix SwiftLint shorthand_operator violations
The gist is:

```diff
-foo = foo + 1
+foo += 1
```

Most of the violations were in generated files, so I changed and re-ran the generator.

A few of these violations required implementing some new methods, which I added tests for.

See [the docs for this rule][0].

[0]: https://realm.github.io/SwiftLint/shorthand_operator.html
2022-06-07 14:51:57 +00:00