Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In app fiat donation / subscription (apple pay) #1422

Closed
15 tasks done
alltheseas opened this issue Aug 1, 2023 · 28 comments
Closed
15 tasks done

In app fiat donation / subscription (apple pay) #1422

alltheseas opened this issue Aug 1, 2023 · 28 comments
Assignees
Labels
purple Damus purple membership
Milestone

Comments

@alltheseas
Copy link
Collaborator

alltheseas commented Aug 1, 2023

user story

As a Damus user who appreciates the devs, I would like a way to donate to Damus in fiat, so that I can support the devs and help contribute to Damus maintenance & development costs.

acceptance criteria

  1. Damus user can "subscribe" to Damus via fiat apple pay mechanism
  2. Damus user can send a one time donation to Damus via fiat apple pay mechanism
  3. Damus user can see their subscription status
  4. Damus user can unsubscribe from Damus purple
  5. Damus user receives star ⭐️ upon subscription
  6. There is annual subscription option
  7. Show user that apple takes X%/Y$ of each in app apple pay donation Delegated to Polish Damus Purple support #1814
  8. Connect in-app purchase with server registration
  9. There should be a "welcome" or "thank you" screen

12. [x] Optimize views to look good on all devices/screens
13. [x] Mention that first 1,000 annual subscribers will receive "Nº 1", "Nº 2" subscriber numbers
14. [x] Implement restoring the purchase, and syncing on different devices under the same App Store account
15. [x] Polish subscription mechanism so that it registers with the server immediately after subscribing (without having to restart the app)
Delegated to #1814

  1. Implement secure receipt transmission with cryptographic signatures
  2. Implement secure receipt verification with the Apple server (Daniel: I might get blocked on this, requires some kind of private key)
  3. Implement receipt verification mechanisms for both Sandbox and production environments
  4. Test flow on a sandbox (and do all necessary configs to make it happen)
  5. Test and address any missing details on other flows such as cancellation and refunds
  6. Wrap up work on ticket and make sure it is hidden behind a developer setting so that an average user does not have access to it while we work on it.

how might we/questions

  1. Should Damus send a receipt via DM to the subscriber?

commentary

At first Damus purple does not need to add additional features (see purple #659 ). Additional features can be added over time.
Subscribe with bitcoin #1755

related

Damus Purple #659

@alltheseas
Copy link
Collaborator Author

Recommended immediately post, or alongside nostrdb update @jb55

@alltheseas
Copy link
Collaborator Author

@jb55 advised preference is to stick with sats, and not take fiat.

@alltheseas alltheseas closed this as not planned Won't fix, can't repro, duplicate, stale Nov 21, 2023
@alltheseas alltheseas added the wontfix This will not be worked on label Nov 21, 2023
@jb55
Copy link
Collaborator

jb55 commented Nov 21, 2023 via email

@jb55
Copy link
Collaborator

jb55 commented Nov 21, 2023

damus is not only for bitcoiners

@jb55 jb55 reopened this Nov 21, 2023
@alltheseas alltheseas removed the wontfix This will not be worked on label Nov 21, 2023
@alltheseas
Copy link
Collaborator Author

Ok. I must have misunderstood.

@alltheseas alltheseas removed the banned label Nov 21, 2023
@alltheseas alltheseas changed the title Fiat subscription (apple pay) In app fiat subscription (apple pay) Nov 21, 2023
@alltheseas
Copy link
Collaborator Author

prompt #1756

@alltheseas
Copy link
Collaborator Author

signal subscribe example

image

signal one-time example
image

@alltheseas alltheseas changed the title In app fiat subscription (apple pay) In app fiat donation / subscription (apple pay) Nov 24, 2023
@alltheseas alltheseas assigned danieldaquino and unassigned jb55 Nov 27, 2023
@danieldaquino
Copy link
Contributor

I started working on this feature! I will start with the overall screens and other items of the acceptance criteria, study Apple's in-app mechanism, and then integrate the payment mechanism at the end.

@jb55
Copy link
Collaborator

jb55 commented Dec 1, 2023 via email

@jb55
Copy link
Collaborator

jb55 commented Dec 1, 2023 via email

@danieldaquino
Copy link
Contributor

danieldaquino commented Dec 2, 2023

Thank you @jb55, this was definitely very helpful!

I am building this feature on top of @jb55's previous work on this, and I have done the following changes so far:

  1. Updated the copywriting to be more accurate to what we are planning to deliver with Purple on the short term
  2. Changed the design to increase consistency with Rob's designs
  3. I am working on getting the star badge applied to users who subscribe to it, and although I have some code drafted up, it does not seem to be working yet, so still some work to be done.

Here is how it currently looks like:

Screenshot 2023-12-02 at 02 30 22 copy

@jb55, @robagreda, @alltheseas, please feel free to provide any suggestions on the design if it can be improved!

I updated the acceptance criteria on the top to mark things I believe are ready. On top of that, a few other thoughts of things we might want to address (on this or on a separate ticket):

  • Creating a website page for Damus Purple with an FAQ (where we can, for example, hint that they will be able to pay for Damus Purple in sats). Maybe we can also add a small roadmap of what they can expect in terms of upcoming premium features?
  • Create a nice warm confirmation "thank you" view (maybe with some special effect), to add an extra moment of delight for people who just subscribed. We need to make sure we make them happy/surprised when they subscribe.

@alltheseas
Copy link
Collaborator Author

@danieldaquino mention that first 1,000 annual subscribers will receive a #1, #2 subscriber number

@danieldaquino
Copy link
Contributor

@alltheseas, from today's standup, can I go ahead and make the following modifications to the acceptance criteria?

  1. Remove "Damus user receives star ⭐️ upon subscription"
  2. Add "Connect in-app purchase with server registration"

@alltheseas
Copy link
Collaborator Author

@alltheseas, from today's standup, can I go ahead and make the following modifications to the acceptance criteria?

  1. Remove "Damus user receives star ⭐️ upon subscription"
  2. Add "Connect in-app purchase with server registration"

Yes to 2.

I apologize for missing this - can you remind me why are we removing 1.?

@danieldaquino
Copy link
Contributor

I think it is because anyone can technically "hack" this and add a star to their profile?

Perhaps I misunderstood. @jb55, can you please clarify what the expectation is regarding the ⭐️ on users' profiles?

@alltheseas
Copy link
Collaborator Author

can you please clarify what the expectation is regarding the ⭐️ on users' profiles?

I think @jb55 mentioned that the reason why we need server registration, is precisely for this reason - that anyone technical enough can add a ⭐, whereas a registration on a server specifically checks if the user has paid for Damus, and grants ⭐ as a reward.

@danieldaquino
Copy link
Contributor

I think @jb55 mentioned that the reason why we need server registration, is precisely for this reason - that anyone technical enough can add a ⭐, whereas a registration on a server specifically checks if the user has paid for Damus, and grants ⭐ as a reward.

That makes sense. @jb55, in order to check whether or not users have the star icon, do you prefer to:

  1. consult directly with the Damus server, or
  2. have the Damus server issue the "⭐" using NIP-58 badges?

I imagine (2) is better, but I would like to double-check if that's what you are looking for.

@jb55
Copy link
Collaborator

jb55 commented Dec 4, 2023 via email

@jb55
Copy link
Collaborator

jb55 commented Dec 4, 2023 via email

@danieldaquino
Copy link
Contributor

Badges aren't the right approach here, since they don't expire. I also
want our stars to be much smarter over time. It's not a static one time
thing. We can customize the look of profiles and stars based on
registration status and maybe even how long they have been a continuous
subscriber, like streak rewards.

Sounds good, I will make the app consult with the server through the REST API as it is simple and reliable (at least until or if we find a better approach later on)

@danieldaquino danieldaquino moved this to In Progress 🏗️ in Damus Roadmap 🛣️ Dec 5, 2023
@danieldaquino
Copy link
Contributor

Created a welcome screen to be displayed when the user successfully purchases the subscription:

Screen.Recording.2023-12-04.at.17.35.58.mov

I tried to compose the view and the animation in a way that plays with purple and Damus colors, stars (since that's the badge symbol they get on their profile) and a bit of suspense-building by delaying the rest of the content.

@jb55, @alltheseas, @robagreda please let me know if this looks good, or if you have any suggestions. I will keep working on the rest of the ticket in the meantime. Thanks!

@alltheseas
Copy link
Collaborator Author

🤩

@danieldaquino
Copy link
Contributor

Just made one other quick improvement to the animation: Added a bit of an animation effect to the background stars for a more immersive feeling

This is the latest:

Screen.Recording.2023-12-04.at.18.12.37.mov

@jb55
Copy link
Collaborator

jb55 commented Dec 5, 2023 via email

@danieldaquino
Copy link
Contributor

that looks awesome, what did you use for this?

Thanks!

This is pure SwiftUI, using various animation modifiers for each item.

The star background was made using Pixelmator Pro, and the mesh gradient background was pulled from Rob's Figma designs

@danieldaquino
Copy link
Contributor

Updates on this project for today and Wednesday

  1. Improved the infrastructure around the server code and automated testing to speed up development (Testing manually at this early stage proved to be difficult and unreliable)
  2. Created essential API endpoints for account management (creation, verification, etc)
  3. Created an API endpoint for receiving and verifying App Store receipts.
    • For local testing I have to mock the behaviour
    • I have researched and drafted some logic for the real secure receipt verification with Apple, but I haven't completed or tested it yet
  4. Created the logic for checking the user status and displaying the star on the profile
  5. Created the logic for collecting and sending over the App Store receipts to the server.
  6. Created a Sandbox account for testing, and studied more about the App Store Sandbox environment

What we have working so far

Overall, this is the flow that we have working on a local test environment:

  1. User goes to the Purple page (95% nicely designed, a few quirks)
  2. User chooses a subscription option
  3. User confirms the simulated purchase with Apple
  4. User is shown the welcome message
  5. Device communicates with the API server and registers the user by sending the receipt.
    • Note: Receipt verification in this example is bogus, it just accepts any receipt for now
  6. User gets a star on their profile, and if they were to call the translation API route, it would allow them to translate. (i.e. they are registered on the server)

Code changes so far:

Next steps

  1. Implement npub authentication for all account-related actions
  2. Get this flow working with a Sandbox Apple ID account for better and more realistic testing
  3. Get it working with a real App Store receipt verification (I might need @jb55's help for some of the configuration required for this)
  4. Figure out remaining quirks and edge cases before shipping the feature

I have updated the acceptance criteria. Some items that I have added could potentially be delegated to separate tickets.

@jb55, @alltheseas, there are a lot of things going on in this ticket, but hopefully this message provides a good overview of where we are! Please let me know if there are any questions or suggestions regarding any of this.

Thanks!
Daniel

@danieldaquino
Copy link
Contributor

Updated the acceptance criteria and delegated various items to separate smaller tickets and more narrowly-scoped tickets to help us better manage this feature: https://github.com/damus-io/damus/milestone/11

@jb55, @alltheseas, please feel free to add/edit/remove stuff from that milestone as needed!

I will wrap up this ticket, send the patch very soon, and start working on other tickets in that milestone (Starting with #1809)

danieldaquino added a commit to danieldaquino/damus that referenced this issue Dec 12, 2023
This commit includes various code changes necessary to get a basic proof of concept of the feature working.

This is NOT a full working feature yet, only a preliminary prototype/PoC. It includes:
- [X] Basic Storekit configuration
- [X] Basic purchase mechanism
- [X] Basic layout and copywriting
- [X] Basic design
- [X] Manage button (To help user cancel their subscription)
- [X] Thank you confirmation + special welcome view
- [X] Star badge on profile (by checking the Damus Purple API)
- [X] Connection to Damus purple API for fetching account info, registering for an account and sending over the App Store receipt data

The feature sits behind a feature flag which is OFF by default (it can be turned ON via Settings --> Developer settings --> Enable experimental Purple API and restarting the app)

Testing
---------

PASS

Device: iPhone 15 Pro simulator
iOS: 17.0.1
Damus: This commit
damus-api: 59ce44a92cff1c1aaed9886f9befbd5f1053821d
Server: Ubuntu 22.04 (VM)
Setup:
1. On the server, delete the `mdb` database files to start from scratch
2. In iOS, reinstall the app if necessary to make sure there are no in-app purchases
3. Enable subscriptions support via developer settings with localhost test mode and restart app
4. Start server with mock parameters (Run `npm run dev`)

Steps:
1. Open top bar and click on "Purple"
2. Purple screen should appear and show both benefits and the purchase options. PASS
3. Click on "monthly". An Apple screen to confirm purchase should appear. PASS
4. Welcome screen with animation should appear. PASS
5. Click continue and restart app (Due to known issue tracked at damus-io#1814)
6. Post something
7. Gold star should appear beside your name
8. Look at the server logs. There should be some requests to create the account (POST), to send the receipt (POST), and to get account status

Closes: damus-io#1422
danieldaquino added a commit to danieldaquino/damus that referenced this issue Dec 12, 2023
This commit includes various code changes necessary to get a basic proof of concept of the feature working.

This is NOT a full working feature yet, only a preliminary prototype/PoC. It includes:
- [X] Basic Storekit configuration
- [X] Basic purchase mechanism
- [X] Basic layout and copywriting
- [X] Basic design
- [X] Manage button (To help user cancel their subscription)
- [X] Thank you confirmation + special welcome view
- [X] Star badge on profile (by checking the Damus Purple API)
- [X] Connection to Damus purple API for fetching account info, registering for an account and sending over the App Store receipt data

The feature sits behind a feature flag which is OFF by default (it can be turned ON via Settings --> Developer settings --> Enable experimental Purple API and restarting the app)

Testing
---------

PASS

Device: iPhone 15 Pro simulator
iOS: 17.0.1
Damus: This commit
damus-api: 59ce44a92cff1c1aaed9886f9befbd5f1053821d
Server: Ubuntu 22.04 (VM)
Setup:
1. On the server, delete the `mdb` database files to start from scratch
2. In iOS, reinstall the app if necessary to make sure there are no in-app purchases
3. Enable subscriptions support via developer settings with localhost test mode and restart app
4. Start server with mock parameters (Run `npm run dev`)

Steps:
1. Open top bar and click on "Purple"
2. Purple screen should appear and show both benefits and the purchase options. PASS
3. Click on "monthly". An Apple screen to confirm purchase should appear. PASS
4. Welcome screen with animation should appear. PASS
5. Click continue and restart app (Due to known issue tracked at damus-io#1814)
6. Post something
7. Gold star should appear beside your name
8. Look at the server logs. There should be some requests to create the account (POST), to send the receipt (POST), and to get account status
9. Go to purple view. There should be some information about the subscription, as well as a "manage" button. PASS
10. Click on "manage" button. An iOS sheet should appear allow the user to unsubscribe or manage their subscription to Damus Purple.

Feature flag testing
--------------------

PASS

Preconditions: Continue from above test
Steps:
1. Disable Damus Purple experiment support on developer settings. Restart the app.
2. Check your post. There should be no star beside your profile name. PASS
3. Check side menu. There should be no "Damus Purple" option. PASS
4. Check server logs. There should be no new requests being done to the server. PASS

Closes: damus-io#1422
@danieldaquino
Copy link
Contributor

Sent patches!

@danieldaquino danieldaquino moved this from In Progress 🏗️ to In Review 🕵️ in Damus Roadmap 🛣️ Dec 16, 2023
jb55 pushed a commit that referenced this issue Dec 16, 2023
This commit includes various code changes necessary to get a basic proof of concept of the feature working.

This is NOT a full working feature yet, only a preliminary prototype/PoC. It includes:
- [X] Basic Storekit configuration
- [X] Basic purchase mechanism
- [X] Basic layout and copywriting
- [X] Basic design
- [X] Manage button (To help user cancel their subscription)
- [X] Thank you confirmation + special welcome view
- [X] Star badge on profile (by checking the Damus Purple API)
- [X] Connection to Damus purple API for fetching account info, registering for an account and sending over the App Store receipt data

The feature sits behind a feature flag which is OFF by default (it can be turned ON via Settings --> Developer settings --> Enable experimental Purple API and restarting the app)

Testing
---------

PASS

Device: iPhone 15 Pro simulator
iOS: 17.0.1
Damus: This commit
damus-api: 59ce44a92cff1c1aaed9886f9befbd5f1053821d
Server: Ubuntu 22.04 (VM)
Setup:
1. On the server, delete the `mdb` database files to start from scratch
2. In iOS, reinstall the app if necessary to make sure there are no in-app purchases
3. Enable subscriptions support via developer settings with localhost test mode and restart app
4. Start server with mock parameters (Run `npm run dev`)

Steps:
1. Open top bar and click on "Purple"
2. Purple screen should appear and show both benefits and the purchase options. PASS
3. Click on "monthly". An Apple screen to confirm purchase should appear. PASS
4. Welcome screen with animation should appear. PASS
5. Click continue and restart app (Due to known issue tracked at #1814)
6. Post something
7. Gold star should appear beside your name
8. Look at the server logs. There should be some requests to create the account (POST), to send the receipt (POST), and to get account status
9. Go to purple view. There should be some information about the subscription, as well as a "manage" button. PASS
10. Click on "manage" button. An iOS sheet should appear allow the user to unsubscribe or manage their subscription to Damus Purple.

Feature flag testing
--------------------

PASS

Preconditions: Continue from above test
Steps:
1. Disable Damus Purple experiment support on developer settings. Restart the app.
2. Check your post. There should be no star beside your profile name. PASS
3. Check side menu. There should be no "Damus Purple" option. PASS
4. Check server logs. There should be no new requests being done to the server. PASS

Closes: #1422
@jb55 jb55 closed this as completed in 4703ed8 Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
purple Damus purple membership
Projects
Archived in project
Development

No branches or pull requests

3 participants