0.6.5 • Published 4 years ago

@tutorbook/payments v0.6.5

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

Tutorbook Payments

Tutorbook PWA (Progressive Web App) sub-package that manages client-side payment operations (primarily for tutors to manage their business(es)).

Payment Flow

We use Stripe Connect to process all of the payments on Tutorbook. Paid tutors setup their accounts as follows:

  1. Paid tutors are prompted by a dashboard card to setup a Stripe Connect payouts account. A link is generated using our unique Stripe Client ID that sends the user to https://connect.stripe.com to complete their account setup. Upon completion, they are sent back to our return URI (usually https://tutorbook.app/app) with their auth token included as a query param (e.g. https://tutorbook.app/app/home?token=ABCDEFG).
  2. That token is then sent to our server via an HTTPS GET request that triggers the creation of a Firestore document containing that new Stripe Account's information. Our server then sends an accountURL (where the tutor can view and manage their payout settings) back to the client.

Once the paid tutor has finished setting up their account, they can then receive paid lesson requests as follows:

  1. Pupils create paid requests via a PCI-compliant Stripe Element (included in the StripeRequestDialog in @tutorbook/dialogs) that returns a payment method token which is sent to the server in the newRequest data REST API request.
  2. The server's data cloud function then creates a sentPayment Firestore document which triggers the processAuthPayment cloud function.
  3. The processAuthPayment cloud function:
    • Adds a payment method to the Stripe Customer using the token generated by the Stripe Element.
    • Ensures that the payment.from user has a valid stripeCustomer document and the payment.to user has a valid stripeAccount document.
    • Authorizes payment from the Stripe Customer to the Stripe Connect Account while deducting a 10% fee.
    • Creates authPayment documents in both user's authPayments subcollections and one document (that contains the Stripe Payment object) in the stripeCustomer authPayments subcollection.
    • Deletes the original sentPayment document.
    • Note: If anything errors, the function deletes the requestOut, requestIn, and sentPayment documents and sends an email to the fromUser asking for a valid form of payment.

After the tutoring lesson, tutors are able to request payments from their pupils by creating pastAppointment documents:

  1. The tutor clicks a FAB on the ViewApptDialog (included in @tutorbook/dialogs) indicating that they are ready to "Request Payment".
  2. Clicking that button creates a requestedPayment document (via the data REST API) that asks the pupil to confirm the lesson occurred (via a dialog created in @tutorbook/listener).
  3. Once payment approval has been granted by the pupil (which leads to the creation of approvedPayment documents), our server's processPayment cloud function captures the correct amount from the original authorizedPayment.
  4. Capturing the payment leads to the creation of pastPayment documents which triggers another function to increase the tutor's balance (in their Firestore profile document) to match their Stripe Account balance.

Tutors then receive payouts from Stripe (that trigger a webhook that lowers their account balance in their Firestore profile document) on a daily basis.

0.6.5

4 years ago

0.6.4

4 years ago

0.6.3

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.8

4 years ago

0.5.6

4 years ago

0.5.6-alpha.0

4 years ago

0.5.6-alpha.1

4 years ago

0.5.7

4 years ago

0.5.5

4 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.5.1-alpha.0

4 years ago

0.5.0-alpha.0

4 years ago

0.4.10

4 years ago

0.4.9

4 years ago

0.4.8

4 years ago

0.4.7

4 years ago

0.4.6

4 years ago

0.4.5

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.14

4 years ago

0.2.13

4 years ago

0.2.12

4 years ago

0.2.11

4 years ago

0.2.10

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago