Python and Recurring Application Charge API problem

Solved
Kevin_Sahin
Shopify Partner
3 0 0

Hi, 

 

I am currently trying to use the Recurring Application Charges API.

 

I am following the guide. I managed to create a charge and to be redirected to the merchant page where he has to accept or deny the charge.

 

Once I accept the charge, the return_route is called with the charge_id passed to this route. Thing is, I can't do anything with this id.

 

When I call the 

https://{current_user.shopify_shop}/admin/recurring_application_charges/{application_charge_id}/activate.json

endpoint to have information about this particular charge_id all I get is this response:

 {'errors': 'Not Found'}

Has anyone an idea about what's going on? By reading the forum I found some people talking about using the same session to do both requests but that does not fix it. 

Thanks in advance.

0 Likes
Alex
Shopify Staff
Shopify Staff
1555 81 293

This is an accepted solution.

Hey Kevin,

 

I can't presently replicate this issue, My flow is as follows using  shopify_python_api:

 

1. Instantiate session

2. Activate session

3. Instantiate RecurringApplicationCharge object, assign attributes

4. Save charge object, redirect to confirmation_url

5. After charge is activated, I get the charge object by the ID (either when I save it for later from the creation response or I take the charge_id query parameter on the return_url)

6. Activate the charge

 

No 404s throughout the above, so unsure what might be going wrong for you. I was using ShopifyAPI version 4.0.0 and Python 2.7.10. Pseudocode:

 

import shopify

token   = "whatever your access token is"
session = shopify.Session("your-shop.myshopify.com", token)

shopify.ShopifyResource.activate_session(session)

rac = shopify.RecurringApplicationCharge()

rac.name          = "Test charge"
rac.price         = 10.00
rac.return_url    = "https://domain.com/activate_charge"
rac.capped_amount = 100.00
rac.terms         = "Foobarbaz"

if rac.save():
    print rac.attributes

# After confirmation...

rac = shopify.RecurringApplicationCharge.find(3925606422)
rac.activate()

print rac.attributes

 

Cheers.

0 Likes
Kevin_Sahin
Shopify Partner
3 0 0

Thank you very much I was finally able to make it work with the Shopify Phyton API.

 

I was previously making the request from scratch.

 

0 Likes
Sinamin
New Member
1 0 0

Im having a hard time understanding the confirmation part and how to test it. I've been using Postman for testing, but can't seem to get recurring payments to work using your method. 

 

Im using Python 3.8 with Shopify api 2020-10 and Lambda. 

0 Likes