Fabien O'Carroll
d11a0db726
Refactored some private methods for stripe
...
no-issue
This is to expose a clearer contract with the outside world
2019-10-09 10:46:55 +07:00
Fabien O'Carroll
dd566b3d29
Added support for custome success/cancel urls
...
no-issue
This will allow clients to customise where they are redirecting to after
the stripe checkout session is exited.
2019-10-03 17:22:29 +07:00
Fabien O'Carroll
af25cfb619
Added interval, currency and last4 to stripe data
...
no-issue
This is attached to each "stripe item" belonging to a member
2019-10-02 18:19:39 +07:00
Fabien O'Carroll
3861bf253c
Added options to stripe retrieve request
...
no-issue
This will allow us to expand sub objects when talking to stripe
2019-10-02 18:19:39 +07:00
Fabien O'Carroll
018471c07c
Fixed usage of updateMember to use id correctly
...
no-issue
2019-10-02 15:15:20 +07:00
Fabien O'Carroll
071a54be7d
Called cancelAllSubscriptions when destroying member
...
no-issue
2019-10-02 15:05:12 +07:00
Fabien O'Carroll
6fe46a79f3
Added cancelAllSubscriptions method
...
no-issue
This gets all subscriptions, filters out ones which have already been
cancelled and cancels the rest
2019-10-02 15:05:12 +07:00
Fabien O'Carroll
18aeed905a
Refactored getActiveSubscriptions to getSubscriptions
...
no-issue
2019-10-02 15:05:12 +07:00
Fabien O'Carroll
561493bfb2
Added debugs and improved getCustomer handling
...
no-issue
This adds more debugs so we can follow what's happening and also adds
better handing for failures when getting a customer from stripe
2019-10-02 13:47:37 +07:00
Fabien O'Carroll
1c3e563ad7
Improved logging for members-api
...
no-issue
This allows the logger to be passed in, and configures stripe to have access to it
2019-10-02 13:47:37 +07:00
Fabien O'Carroll
80f1155590
Ensured we do not create multiple webhooks on boot
...
no-issue
This updates the initialisation logic to fetch all webhooks (we use
limit: 100, and there are currently a max of 16 webhooks in stripe) and
find one with the corrct url. Once found, delete that webhook. We then
attempt to create a new one, and log out any errors (this is to allow
for local development, creating a webhook with a local url is expected
to fail)
2019-10-02 13:47:37 +07:00
Fabien O'Carroll
48cb8d14da
Wrapped getCustomer in try catch
...
no-issue
This protects against live/test mode poisoned databases
2019-10-02 13:47:37 +07:00
Fabien O'Carroll
d1b29fd0b7
Added list and update stripe requests
...
no-issue
These will be used for listing and updating webhooks on configuration
2019-10-02 13:47:37 +07:00
Fabien O'Carroll
0b5a70dcf4
Added default options param for users#create
...
no-issue
This allows create to have an optional second parameter, so that it
doesn't error when called with just data.
2019-10-01 17:42:22 +07:00
Fabien O'Carroll
8422a2f28d
Fixed signature for listMembers call
...
no-issue
2019-10-01 11:02:54 +07:00
Fabien O'Carroll
530390124b
Added flag to create member for sending email
...
no-issue
This allows us to give more functionality to consumers, with a smaller
API (rather than exposing the methods for sending a magic-link email)
2019-09-26 17:11:17 +07:00
Fabien O'Carroll
f7630ec05b
Updated createCheckoutSession to work w/o member
...
no-issue
This will allow us to do a payment first flow, in which a payment is
taken, before creating a member
2019-09-25 16:53:08 +07:00
Fabien O'Carroll
0527304376
Updated stripe to setAppInfo and apiVersion
...
no-issue
2019-09-25 11:35:58 +07:00
Fabien O'Carroll
6722d3bc8a
Ensured member is not linked to customer twice
...
no-issue
Edge case but easy to solve - so we dun it
2019-09-25 11:20:02 +07:00
Fabien O'Carroll
ed4dfd8d54
Updated users module to use getActiveSubscriptions
...
no-issue
This offloads some stripe specific logic into the stripe module
2019-09-25 11:20:02 +07:00
Fabien O'Carroll
314fd6a540
Added method for getting active subscriptions
...
no-issue
2019-09-25 11:20:02 +07:00
Fabien O'Carroll
a92d5f064b
Added method for getting stripe customer for member
...
no-issue
This finds the first active customer that is linked to the member, and
created and links a new customer if a viable one does not exist.
2019-09-25 11:20:02 +07:00
Fabien O'Carroll
69abbc6fa2
Added method for linking customer to member
...
no-issue
Uses the metadata storage passed into stripe
2019-09-25 11:20:02 +07:00
Fabien O'Carroll
9beb496bd1
Passed in metadata getter/setter to stripe
...
no-issue
This will be used to store information such as customer id
2019-09-25 11:20:02 +07:00
Fabien O'Carroll
644fd71d4f
Removed unused getPublicConfig method from stripe
...
no-issue
Don't use it you lose it!
2019-09-25 11:20:02 +07:00
Fabien O'Carroll
373f67a117
Added getCustomer method to stripe
...
no-issue
This uses the stripeRequests module directly since the customers api was
removed.
2019-09-25 11:20:02 +07:00
Fabien O'Carroll
2849c647d6
Added parseWebhook method to stripe
...
no-issue
This uses the webhook secret and stripe module to validate the signature
and parse the body into an object
2019-09-25 11:20:02 +07:00
Fabien O'Carroll
343fcecfff
Updated stripe to create webhook on boot configure
...
no-issue
This will allow us to a) have an endpoint to receive webhooks and b) get
hold of the webhook secret to validate the signature.
2019-09-25 11:20:02 +07:00
Fabien O'Carroll
4dc42709c3
Removed superfluous stripe api modules
...
no-issue
This removes the subscription api as we are using stripe checkout to
generate those
This removes the customers api as we no longer need the deterministic
api for it
2019-09-25 11:20:02 +07:00
Fabien O'Carroll
216ab072b4
Refactored users module to wrap all methods
...
no-issue
This also adds initial support for `update` user - which is not used
2019-09-25 11:20:02 +07:00
Fabien O'Carroll
4ead495b45
Ensured that destroying member removes stripe customer
...
no-issue
This also mean sthe subscription will be cancelled
2019-09-06 14:30:27 +08:00
Fabien O'Carroll
ec3948287f
Added subscription data when fetching member
2019-09-06 14:30:27 +08:00
Fabien O'Carroll
61561a5af6
Added stripe payments module
2019-09-06 14:30:27 +08:00
Fabien O'Carroll
7376a333c2
Removed lib/subscriptions
...
no-issue
This is no longer used
2019-09-06 14:30:27 +08:00
Fabien O'Carroll
1c5ba6056a
Removed lib/cookies
...
no-issue
This is no longer used
2019-09-06 14:30:27 +08:00
Fabien O'Carroll
8bfcc37ad4
Removed lib/util
...
no-issue
This is no longer used
2019-09-06 14:30:27 +08:00
Fabien O'Carroll
af6c897a14
Updated members-api to use magic-link
...
no-issue
This removes a *lot* of funtionality, stripping the members-api module
to *only* handle the magic link signin flow.
2019-09-03 15:35:04 +08:00
Fabien O'Carroll
1fb969ad36
Refactored to improve logging and error handling
...
* Installed stripe@7.4.0
refs #38
We were relying on stripe being installed in Ghost, this moves the dep
to the correct package.
* Created exponentialBackoff wrapper for stripe api
refs #38
https://stripe.com/docs/testing#rate-limits The stripe docs suggest to
use exponential backoff when recieving a rate limit error. This wrapper
will wrap stripe api calls, and retry them after 1s,2s,4s,8s,16s until
eventually failing. This gives a total of 5 retries over 31s.
* Added wrappers around the stripe api calls
refs #38
* Ensured all calls to stripe api go via exp backoff
refs #38
* Scaffolding out the error handling for stripe api
* Forwarding all errors
* Refactored stripe api into modules
* Ensured the ready promise object is not replaced
* Added logging setup
- Sets up common logger structure with custom logger passed through
* Ensure logger is kept in module state
* Renamed updateLogger to setLogger
* Removed `logger` param and exposed setLogger method
* Ensured different ids used for test mode
* Ensure setLogger works for prototype methods
* Removed reconfigureSettings method
* Updated payment processer service to keep static ready promise
* Added eventemitter to member api instance to handle errors
* Moved logging of errors to http level
2019-07-17 18:20:13 +08:00
Fabien O'Carroll
7ec3f61e71
Refactored directory structure
...
no-issue
This is to better fit the index.js, lib model
2019-05-07 17:35:17 +02:00