How Does the Workflow Calculate Store Credit Reward Scheme for Shopify and Non-Shopify Users?

This topic was automatically generated from Slack. You can find the original thread here.

This workflow calculates store credit for Shopify as a rewards scheme for loyal customers. Non shopify users (eBay, Amazon, Discogs) receive 5% cash back to their account in hopes of moving them over to shopify directly (where we pay no % fees on sales). Regular shopify customers get 10% back and shopify customers who are subscribed to our emails get 20% back.

Trigger 1 (left) pulls in new orders via the New Order Created (Instant) trigger and trigger 2 (right) pulls in New Event Emitted (Instant) with "refunds"as the event topic.

Step 1 calculates the credit/debit based on trigger, source, line item value, discounts, store credit used in the transaction and subscription status.

Step 2 pulls the balance in case the debit is bigger than the account balance (which results in an error otherwise)

Step 3 applies the credit/debit to customer account

image.png

image.png

image.png

image.png

image.png

Nice! Any interest in publishing your workflow to the templates gallery? Find your next Pipedream workflow - Pipedream

No problem, but I think it would have to be refined to have general application (the sources/percentages are hardcoded and they’d really need to be a drop down for other users). Still send it?

Yea, could still be helpful for folks to see the general idea, and in the submission form you can define your own markdown file to describe the workflow and the steps, etc

I think realistically every workflow requires some level of tweaking / customization in order to get working for your own needs

I’ll see if GPT can bang out some dropdown menus for it, otherwise I’ll send as is.

Simplified it to just 3 dropdowns of discounts based on subscription status. Currently playing with turning it into a Shopify app (for my own learning purposes) but will upload to templates soon. Is there a better way to collect other stores authorisations than the ham fisted way I’m doing it? ie a component already?

image.png

Can you elaborate? I’m not following your question or what you’re trying to do.

Well…I’ll do my best to explain…so I “built an app” on the shopify partners site that collects store Oauth and sends it to a pipedream workflow for a HMAC test and then gets an access token which I store in my datastore. I then have the app insert a webhook notification for new orders on the client store (my own test site) that sends the store name to my pipedream workflow (detailed in original post) which I look up in the data store and use their access token to pull the order and update customer credit with the correct amount.

I feel like I’m reinventing the wheel over here (badly, no doubt) with all this Oauth check and HMAC datastore stuff and there’s probably already a component for all this?

Again, this is mainly for my own learning experience, but I’d rather not learn stuff I don’t need if there’s a component for it already,

image.png

image.png

Oh, gotcha. I believe our out of the box Shopify app lets you input an app access token, which will then let you use any of the prebuilt triggers and actions, right?

I believe Shopify lets you create custom apps using either OAuth or a static token

Shopify app component or shopify developers app component? I seem to remember one of them got shut down for accessing non-owned stores? (it was ages ago and I might have misunderstood)

Oh yea it’s called the Developer App, since yes, we had to deprecate the Pipedream official app a while back: Shopify API Integrations - Pipedream

Unfortunately their requirements for having a public OAuth app are quite strict and don’t align with how our platform works

great, that’s the one I use for my own store. I’ll play around with how to feed otherstores into it. I assume theres a way to programitically access the “selected account” basically.

You can programmatically reference the auth credentials if that’s what you mean?

But the auth that’s associated with an individual step is static. So if you want to programmatically reference a different account, your data stores approach probably makes more sense actually.

OK great, thanks. I’m just working on having the original one I build set up the webhook on client store right now. not something I’ve done before. so we’ll see where that takes me. lots of hurdles to go!

Create webhooks are working! Progress!