How to get webhook notification when subscription's payed through date has passed - braintree

I would like to allow my users to maintain access to the features unlocked via a subscription until the end of the payed-through period (even if the subscription has been canceled).
To do so I would need to update the user's permissions in my database, and the best way would be by receiving a webhook notification when the payed-through date has passed.
Is this possible? If not what would be the best approach to achieve this behavior?
Any help is greatly appreciated :)

Solved the problem.
When the user cancels the subscription, instead of calling
await gateway.subscription.cancel(subscriptionId);
simply call
await gateway.subscription.update(subscriptionId, {
numberOfBillingCycles: 1
});
this will cause the subscription to remain active until the paidThroughDate and then expire (instead of renewing) triggering the SubscriptionExpired webhook.

Related

Programatically Add Slack User

I'm running an end to end test of a bot that processes an event and creates a Slack channel based on the event, including inviting users. For the end to end test, I'd like to create a few users that I can invite to the channel, but thus far I've only found a method for inviting a user in the API. Is there no method or workaround to just create one?
It is possible to create users on your workspace by posting to the /User endpoint of the SCIM API, though you will need to be on the Business+ or Enterprise Grid plans.
More information here: https://api.slack.com/scim#post-users
It would seem the answer is "no", there is no method for programmatically adding a slack user.

How do you get information on the transaction status in braintree asynchonously?

So when I submit a braintree order for settlement, there will/can be multiple state changes until I get my money. It can settle, stay in settling, get declined, and so on.
How can I get this information without having to call their API constantly? Is there some kind of webhook for that? Because in my tests, I only get updates for disbursements, which is (if I understood it correctly) basically the last step of the whole transaction.
There are webhooks for some events, but not for specifically when a transaction changes status.
You can, however, use the Search API to create a script or cron job that checks for status changes over a period of time.
If you have additional questions about webhooks or using the API, contact Support.

Slack logon trigger

I want to create something in Slack that sends a message (starting by calling someone with '#') to a channel when specific users login. I've checked ifttt and zapier. I also checked the slack api to create something myself, but I couldn't really find anything usefull.
Anyone has any ideas?
Slack does not track user login or logoff in a traditional sense. Instead, users are always always "logged in" and available to receive messages once they have joined a team / channel.
There also is the concept of "presence", which is related, but not the same thing. User presence can change multiple times during a few minutes, e.g. if the user is on a mobile. I am guessing you would not want to send the user your message that often.
Still you can poll the presence information of a user with the API users.getPresence , which could be used to implement a script that polls this information on a regular basis and send your message. You also want to filter out presence changes below a certain duration threshold.
Keep in mind though that the rate limit for API methods is 1 per second. So depending on how many users you have in your workspace there will be a significant delay between the user becoming "present" and your script being able to send the message.
There is a workaround for that to have a google sheet as a database for the users and you can trigger by day once and timestamp it.
So the best trigger is a private message or public and you can use filter when mentioning or signin or signout it depends on the trigger word then you pass the filter since zapier won't count your zaps if you used fiter as a second step.

Specifiy Stripe subscription start date using Laravel Cashier

I'm developing an application that uses Stripe, through Laravel Cashier to handle user subscriptions. When the user account is made, It has to be manually verified (has to be done this way due to the business logic) however the subscription starts immediately. Is there a way to pause the subscription, and only start it once each account has been verified? I'm using Laravel 5.
I think something like the following could work:
Create a boolean variable in your "users" table that you could call something like "verify_subscription".
Whenever a new user account is created, set "verify_subscription" to false.
Don't send the subscription off to Stripe (which will pause the subscription) while a new user has their "verify_subscription" set to false.
I can think of two different options at this point: Either create a confirmation email that gets sent to you (instead of or in addition to the user) where when you are ready to unpause the subscription you can click on that link for that particular user which will send the subscription off to Stripe and "unpause" their subscription OR you could create a route with a form where you can look up the user who you would like to unpause and simply search for that user, submit a form that gets processed which does the same thing (unpause the user by sending the subscription off to Stripe).
Hope that gives you some ideas to work with if you haven't already solved this issue!

Google Checkout subscription: How to identify the user

We are using Google Checkout - google handled subscriptions. In our html form we are using merchant-item-id parameter to store the subscription plan id and user id, so when Google Checkout send us back the notification for the new orders (merchant-item-id is there) we know what user for what plan to charge. So far this works perfect.
But now, when a month is passed, and Google Checkout start creating the reoccurring orders, there is no merchant-item-id parameter in the notifications they send. So we don't know what user for what plan is charged.
What should we use as user identifier, so we can handle properly the subscription on our site?
Any ideas?
Btw. I know about the "buyer-id" parameter which is send with each new order notification, but that will not work for us, because it is possible that the same google buyer is paying for several of our users accounts.
I would try putting some unique info in "shopping-cart.items.item-1.merchant-private-item-data" to something unique that I can identify the subscription by.
Nikolaj

Resources