Creating Shopify webhook using pipeline

10 views
Skip to first unread message

Saswat Ray

unread,
Oct 30, 2019, 7:09:18 AM10/30/19
to django...@googlegroups.com
Hi Guys,

I need to create one webhook in shopify(order/product) but using pipeline function.I did the app authentication and got the access taken.

In settings.py i added this

SOCIAL_AUTH_SHOPIFY_WEBHOOK_PIPELINE = (
    'social_core.pipeline.social_auth.social_uid',
    'social_core.pipeline.social_auth.auth_allowed',
    'apps.integrations.pipelines.shopify_webhook_order_create',
    'social_core.pipeline.social_auth.social_user',
    'social_core.pipeline.social_auth.associate_user',
    'social_core.pipeline.social_auth.load_extra_data',
    'social_core.pipeline.user.user_details',
)

I wanted to do something like this inside "shopify_webhook_order_create"
    def register_webhook():
        headers = {
            "X-Shopify-Access-Token": session.get("access_token"),
            "Content-Type": "application/json"
        }

        payload = {
            "webhook": {
                "topic": "draft_orders/create",
                "address": "https://{0}/webhook".format(HOST),
                "format": "json"
            }
        }
        response = requests.post("https://" + session.get("shop")
                                 + "/admin/webhooks.json",
                                 data=json.dumps(payload), headers=headers)

        if response.status_code == 201:

            return render_template('register_webhook.html',
                                   webhook_response=json.loads(response.text))
        else:
            return Response(response="{0} - {1}".format(response.status_code,
                                                        response.text), status=200)


but pipeline is having some specific format like below :

"def slack_webhook_social_user(backend, uid, user=None, *args, **kwargs):
    provider = backend.name
    social = backend.strategy.storage.user.get_social_auth(provider, uid)
    if social and not user:
        user = social.user
    return {'social': social,
            'user': user,
            'is_new': user is None,
            'new_association': social is None}"



My Question is how can i create webhook using pipeline function.

Thanks,
Saswat


Reply all
Reply to author
Forward
0 new messages