If the user hasn't accepted the charge yet, or canceled it, how to redirect them from my embedded app to the "Approve fees" page again?

Highlighted
New Member
1 0 0

Hi,
I am pretty new to Shopify development, so please bear with me. And thank you for help in advance!

I am creating an app with a RecurringApplicationCharge, and I have two situations where I have almost the same problem.

1. Say, the user has installed the app, but didn't accept the charge yet - they're on the "Approve fees" page. Then, in a separate tab, they go to the "Apps" page and select my app from the list.

In this case, I would like to redirect them to the "Approve fees" page.

I am trying to do it directly from my backend endpoint - the very first one hit by the app, the one I specified in the "App URL" field when I set up the app as an app developer.

However, my app is an embedded app and is opening in a frame in the Shopify store. So the redirect (from the frame to another whole Shopify page) doesn't work, and I see a broken page and this error in the browser console:

Refused to display 'https://xxx.myshopify.com/admin/charges/zzz/request_recurring_application_charge?...' in a frame because it set 'X-Frame-Options' to 'deny'.

How should I redirect the user correctly to the "Approve fees" page?

 

2. Say, the user has reviewed the "Approve fees" page and canceled the charge.

What Shopify seems to do automatically, is to redirect the user to the "Apps" page. Now, the link on the "Apps" page seems the only entry point to the app.

Am I right? Is this really the only entrypoint, or is there a way for the user to go back to the "Approve fees" page?

And, of course, I still have the same problem: the "Approve fees" page doesn't want to be open within the frame. Which brings me to the first question again: how do I redirect from my embedded app to the page where the user can accept charges?

 

Thanks!

0 Likes
Tourist
10 0 1

Hii

You will got the status info in the confirmation_url.

Let me explain again.

When user comes to charge screen. Either they accept it or decline it.

after that they are redirecred to link (confirmation_url set by you).

On that function you need to print all post and get array i'm sure you will got the information there.

Php code look like this

$rurl = 'xyz.com/welcom_app';
$d=array('application_charge'=>array('name'=>'yourapp','price'=>'50','return_url'=>$rurl,'test'=>true));

$response = $this->shopify->call('POST',"/admin/application_charges.json", $d,$s,$t);

redirect($response['confirmation_url']);


then on welcome_app function try to print all requested data

print_r($_REQUEST);

 

 

Let me know if you have any other queries

 

 

Thanks

gddeveloper
0 Likes