如何使用 Shopify Python API RecurringApplicationCharge

How to use Shopify Python API RecurringApplicationCharge

当我尝试在视图中为有效用户执行以下操作时,出现错误。如何使用 RecurringApplicationCharge?

@login_required
def confirm(request, *args, **kwargs):
    with request.user.session:
        # Tried this:
        charge = shopify.RecurringApplicationCharge.create(name="Test", test="true")
        # Tried this:
        charge = shopify.RecurringApplicationCharge.customize(name="Test", test="true")
        # Tried this:
        charge = shopify.RecurringApplicationCharge(name="Test", test="true")

我可以看到 RecurringApplicationCharge class 有一个自定义方法 load_attributes_from_response(self.put("customize", recurring_application_charge= kwargs)) 但我不确定如何处理它。

.create 给我:TypeError: create() 得到了一个意外的关键字参数 'name'

.customize 给我:绑定方法 customize() 必须使用 RecurringApplicationCharge 实例作为第一个参数调用(没有得到任何东西)

最后一个给我:recurring_application_charge(None)

我是否需要先创建使用费并将其添加为预修复选项?

看来我是通过执行以下操作创建费用的:

@login_required
def confirm(request, *args, **kwargs):
    with request.user.session:
        # Tried this:
        charge = shopify.RecurringApplicationCharge()
        charge.test = True
        charge.return_url = [... my return url ...]
        charge.price = 10.00
        charge.name = "Test name"