deptagency / algomart

Algorand NFT Storefront platform
https://demo.algomart.dev/
MIT License
181 stars 79 forks source link

Sending notification to the user when a transfer is complete #104

Open dallashuggins opened 2 years ago

dallashuggins commented 2 years ago

Overview

We need to send a user an email notification that the transfer was complete upon successful transfer to the Circle wallet address.

dallashuggins commented 2 years ago

At this time, we can send a notification to a user when the transfer is considered paid, letting them know it's available for transfer. However, since we are minting collectibles which are owned, they will be notified in their account sooner than this to tell them their transfer is ready, but will receive the email once paid. If we add a claimed by column for packs, then we could consider them an owner only after their payment has settled (see #169).

dallashuggins commented 2 years ago

Current functionality in #156 - Initially I added the following snippet to the updatePaymentStatuses method where the status is checked if it's Paid. I took this out, because users will still be able to transfer the assets before the payment has been settled, so it could add confusion. If the payment status was paid during the time of payment (common with transfers of crypto), the user wouldn't receive an email (unless the status came back pending). For cards, payments will have a status of confirmed for ~3 days, but the user will be able to transfer the pack still, but will receive an email when paid. This is confusing to the user since they already transferred the asset. This could be useful for wires however. I added an email for paymentSuccess but keeping out sending the notification until we're utilizing claimed by.

        // Create purchase success notification to be sent to user
        const packWithBase = await this.packs.getPackById(payment.packId)
        if (packWithBase) {
          await this.notifications.createNotification(
            {
              type: NotificationType.PaymentSuccess,
              userAccountId: payment.payerId,
              variables: {
                packTitle: packWithBase.title,
              },
            },
            trx
          )
        }