Zapier 通过代码创建条纹退款

问题描述

我一直在尝试通过 Zapier 的代码在 Stripe 中创建退款,使用以下答案中的 python 代码Is is possible to create a Stripe refund action in Zapier?

当我尝试在 Zapier 中测试步骤时,我收到“ModuleNotFoundError: no module named 'stripe'”。

我的代码如下所示:

import stripe
stripe.api_key = "myAPIkey"

stripe.refund.create(
  charge = input_data["charge"],)

我错过了什么?

解决方法

https://zapier.com/help/create/code-webhooks/use-python-code-in-zaps

您不能要求外部库或安装通常称为“pip 模块”的库。 Code 应用中仅提供标准 Python 库和请求,并且请求已包含在命名空间中。

(免责声明,我从未使用过 Zapier,但是)据我所知,这意味着您不能使用像 Stripe 的官方 Python 库这样的库(您的错误消息是它现已安装)。

相反,您需要通过使用 requests 库将 https://stripe.com/docs/api/curl#create_refund 直接转换为对 Stripe 的 REST API 的调用来进行此调用。请记住,您需要为 an API key 提供它(Making an API call in Python with an API that requires a bearer token)