coler-j
coler-j

Reputation: 2119

How to use Shopify Python API RecurringApplicationCharge

When I try to do the following in a view for a valid user, I get an error. How do I use the 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")

I can see that the RecurringApplicationCharge class has a method customize which does load_attributes_from_response(self.put("customize", recurring_application_charge= kwargs)) but I am not sure what to do with this.

.create gives me: TypeError: create() got an unexpected keyword argument 'name'

.customize gives me: bound method customize() must be called with RecurringApplicationCharge instance as first argument (got nothing instead)

the last gives me: recurring_application_charge(None)

Do I need to create a usage charge first and add it as pre-fix options?

Upvotes: 1

Views: 547

Answers (1)

coler-j
coler-j

Reputation: 2119

It looks like I create the charge by doing the following:

@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"

Upvotes: 3

Related Questions