Mailchimp + Firebase - subscribe to newsletter - firebase

I am using Mailchimp and Firebase to send automated emails.
I have installed the extension and it using Firebase Console, but for Contact Status option I chose 'Pending'.
The thing is, I dont want every user that creates an account to be subscribed to the audiance, I want it to be 'Subscribed' just if he subscribes to the newsletter (it should happen on a click event on a button). I have also set up an automated email in Mailchimp (that is triggered immediately after subscribed contacts join your audience).
Do you know how can I achieve this? I don't have any written code yet, because I don't know where to begin with this.

Related

Stripe callback for successful payment from redirectToCheckout

Currently have a web app hosted on github pages.
I want to use firebase functions + stripe to handle payments.
I have most things set up and now am calling the method stripe.redirectToCheckout({ sessionId })
However, on a successful payment, I want to update the database but I don't see an option add a callback. It only redirects me to a success/failure page. Im thinking of maybe redirecting back to the webapp but with some queryParams. Then check if query param is there on page load, update DB. But that seems incorrect and people could just then navigate to the specific URL to be added into the database.
How do I achieve what I am trying to do?
You should ideally use Stripe Webhooks. You can create a HTTP function and specify it's URL for the webhook from Stripe Dashboard. So whenever an event (e.g. checkout session completed or failed) triggers the webhook, it'll send the event details to your Cloud Function and there you can update the database as required. There is no client side involved in this so risk is negligible.
Also checkout the Firebase Stripe Extension that might do most of the work for you.

Firebase or firebase+paypal paid only accounts

I'm trying to set up user accounts for my website which are paid only. I don't want a user to have an option to create an account without having already paid. How would I go about this?
Example:
google pay button with a click subscribe simultaneously adding them on a subscription and creating their account (not sure how I would do this integration)
Paypal subscribe button which then takes them to a page where they can sign up after they pay (not sure how I would get their paypal subscription information though on that response if they don't choose to sign up)
I did find paypal subscriptions that generate usernames and passwords (https://developer.paypal.com/docs/paypal-payments-standard/integration-guide/user-names-passwords/), however I dont know how I would correlate this with my firebase users.
I'd prefer a solution where after they subscribe they are automatically added to google firebase with an email and password (or temp password) and their paypal ID.
Use firebase functions and require they initiate a subscription with paypal buttons and onApprove of the paypal buttons, send an API call to your google function to add them to the database and send the sign up email.

Google Forms PayPal Express Integration

I am doing work for a non profit with 0 budget for IT. They need to allow users to enter information on a Google Form and then collect payment. I have done a lot of research on the topic and currently appears you can only add a hyperlink on the Google Forms to link to PayPal. However, I was wondering if there was some way to link the PayPal Express Checkout javascript(https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/add-paypal-button/) into the Google Form so it calls back with a transaction id and status. Then I would be able to somehow insert those values into the Google Form. Any thoughts on how to integrate would be helpful. I am a developer but not familiar with Google Forms.
I recently wrestled with this exact question and ended up building a G Suite addon to make this easier for others. Coincidentally I also do volunteer IT for a small nonprofit and we wanted to use PayPal with our signup form (there's pricing for the addon but just ping me if you're a small nonprofit).
Here's what I learned while building it:
There's no way for Apps Script to modify the form once it's shown to the user, or to use Apps Script to respond to user input
There's no way to redirect the user automatically to PayPal after a form is submitted
That means if you want to send someone to PayPal, you've got to use an ordinary link. You can do this within the form by adding the URL to a question description, or you can add the URL to the text shown once someone has submitted the form. For PayPal, you've got two options for this kind of link:
PayPal buttons
Express checkout
PayPal buttons are a static link managed by PayPal. They don't require any coding - just go here and create a button. Then you need to get the raw text link for the button, which PayPal calls the "email" version. You can insert that into your form directly and tell users to access it. The one problem is there's no real way to get the transaction ID. You could try correlating the form submit time with the payment time, or the payer email with the form submit email. It's possible that neither of them will match up and you'll have to do it manually.
Express checkout requires you to dynamically create a new link for each payment by calling the PayPal API. That means your link needs to open a page that then generates an express checkout URL and redirects the user to it. You can do this using a web app in Google Apps Script using a doGet() trigger, or you can create your backend on your server in any language.
If you can run your own server somewhere, I recommend that (plenty of PaaS services have a free tier). It's much easier to test and debug things when you aren't using Apps Script. I used the PayPal Node SDK which works great despite being unmaintained. (Express checkout is "deprecated" by PayPal, but I'll bet it's not going away anytime soon). Their example will get you most of the way there. When the user arrives, generate a payment link and redirect them. When they finish they'll return to your server, and you can display whatever you want. For example, you can ask them to copy the transaction ID and paste it into your form.
Finally, when your form is submitted an onSubmit() trigger can be set up. There are actually two kinds of onSubmit() triggers for forms - one for the form itself, and a second for the spreadsheet linked to the form. You can register a trigger to do extra processing (e.g. look up the transaction ID), but you can't modify the response in the trigger. You can however modify the spreadsheet where the trigger gets sent, which for most cases is equivalent. For example, you could add a column to the spreadsheet with a link to the PayPal transaction based on the transaction code.

Firebase Cloud Functions: Send Email via Authentication System

Firebase Authentication has a built in email service. Is it possible to fire an auth based email via Cloud Functions (admin js sdk)?
Seems like I should be able to trigger an email from noreply#my-domain.com with a custom oob code which I could then use to drive my (client-side) application.
My use case would be, when a new order .collection("orders").doc(uid) has its stage field updated/changed to 'submitted' I would like to notify a user via email that a new order is submitted. Maybe even use the oob code to mark as 'processed'?
...just trying to avoid using a 3rd party email service altogether.
you can use MailChimp to do what you are asking, since like Miles says, you will need to do a workaround in order to fix this.
I have been using MailChimp my self to send emails to each user registered in my app , i have setup a couple of emails in mailchimp and i just add to the list all the users that register to my app, so the first message will be the welcome message, then after 2 days another email and so on, you can trigger an email whenever you want, since the doc is not that clear i have made a tutorial on how to integrate it with Android.
you can find that tutorial HERE , the only thing is that is in spanish, sorry.
The idea is simple, just get your users email throught FirebaseAuth , pass that email to the mailchimp query , and then setup an email from the mailchimp website
Unfortunately, their API does not appear to support emailing users in your project. However, they have sample code for cloudfunctions to email users you can easily tweak for your needs: https://github.com/firebase/functions-samples/tree/master/quickstarts/email-users

How to add "subscribe button" in facebook messenger bot?

I need to add a button (subscription ) in my messenger bot through which users can subscribe. and after that bot will automatically send latest post to the users at the specific time.
I was going through documentation but i am unable to find any proper documentation for it.
Can anybody please help regarding that?
Facebook don't provide a mechanism to manage subscriptions. It's up to you as a developer to choose how to implement this - for example using a button with a payload to confirm that the user wants to opt in.
You could perhaps put an Opt Out option in your persistent menu and listen for the relevant payload and unsubscribe the user.
Facebook have published some documentation about this, explaining how they expect subscription messaging to be triggered:
Person sends a message to a business or clicks on a call to action button within Messenger to request subscription messaging
Person requests subscription messaging from a business via a Send to Messenger plugin
Person signs up for SMS alerts
See the full page of documentation at https://developers.facebook.com/docs/messenger-platform/policy-overview#messaging_types for more details on their expectation

Resources