Getting external URL parameters into a controller in concrete 5.7
Permalink
Hi Concrete 5 community,
I have a url here i.e:
http://mywebsitename.com/payment?tx=8RX44311GG928902B&st=Comple...
I am unsure which concrete 5 7 API I have to use to get the parameters of tx and st into a controller.
Can anyone help?
Thank you.
I have a url here i.e:
http://mywebsitename.com/payment?tx=8RX44311GG928902B&st=Comple...
I am unsure which concrete 5 7 API I have to use to get the parameters of tx and st into a controller.
Can anyone help?
Thank you.
Dunno for sure. Maybe try something like
Hi Gondwanna,
How am I going to grab those parameters from a return url which is coming from an external payment gateway (i.e paypal) into a controller without refreshing the POST data when a user has filled out his details on a form?
Do I have to make a view page and write in the Request function?
Or is it better to just have the auto url route to a vanilla php file to $_GET the parameters, store it in an array and write it to a database?
Btw: Thanks again for your contact form package example, I've manage to write a few form packages of my own.
How am I going to grab those parameters from a return url which is coming from an external payment gateway (i.e paypal) into a controller without refreshing the POST data when a user has filled out his details on a form?
Do I have to make a view page and write in the Request function?
Or is it better to just have the auto url route to a vanilla php file to $_GET the parameters, store it in an array and write it to a database?
Btw: Thanks again for your contact form package example, I've manage to write a few form packages of my own.
(Saw your post on Whirlpool!)
I've never tried to do this, so I don't know what will work in your context. It seems to me that you're trying to extract the parameters in validate(), but that function won't be called when the page is reloaded after payment submission. Maybe pick a function that will definitely be called whenever the page/block is loaded.
I'm also unclear about which page (URL) you should be (or are) using. If the payment gateway is redirecting to a different page to that which holds your form, you'll want to extract the parameters on the post-payment page, rather than your form submission page.
I've never tried to do this, so I don't know what will work in your context. It seems to me that you're trying to extract the parameters in validate(), but that function won't be called when the page is reloaded after payment submission. Maybe pick a function that will definitely be called whenever the page/block is loaded.
I'm also unclear about which page (URL) you should be (or are) using. If the payment gateway is redirecting to a different page to that which holds your form, you'll want to extract the parameters on the post-payment page, rather than your form submission page.
It's a small small world after all isn't it? :)
Well sorry if the post / code didn't make sense. Its difficult to get around the Whirlcode formatting.
Ah you haven't done it? Well that's good will be something nice to add in Concrete 5.7.
In the Whirlpool post its within the function action_send($bID = false) which I am trying to extract the parameters from, I should think if anyone copied and paste the code from Whirlpool into a PHP IDE it might help.
Due to some circumstances and a row fought in Whirlpool between two posters I have to change some naming conventions as not to reveal the identity of the client that has asked me for help.
As for the redirect URL settings the payment gateway is set to the form submission page 'atm' and if you say that I have to pick a function called which means I have to use a or a and in what order should I put if after the condition?
If the return url is rerouted to another page how could I achive this within a package ?
Do I need a new controller for this ? Just A view?
Sorry My PHP is limited at the moment and concrete 5.7 docs are little help.
Well sorry if the post / code didn't make sense. Its difficult to get around the Whirlcode formatting.
Ah you haven't done it? Well that's good will be something nice to add in Concrete 5.7.
In the Whirlpool post its within the function action_send($bID = false) which I am trying to extract the parameters from, I should think if anyone copied and paste the code from Whirlpool into a PHP IDE it might help.
Due to some circumstances and a row fought in Whirlpool between two posters I have to change some naming conventions as not to reveal the identity of the client that has asked me for help.
As for the redirect URL settings the payment gateway is set to the form submission page 'atm' and if you say that I have to pick a function called which means I have to use a
$_SERVER['REQUEST_URI']
if(isset($_GET['page']))
if($paymentType == "Paypal")
If the return url is rerouted to another page how could I achive this within a package ?
Do I need a new controller for this ? Just A view?
Sorry My PHP is limited at the moment and concrete 5.7 docs are little help.
I still feel that looking for the response parameters in action_send() may be premature. You need to check the parameters AFTER the payment server has redirected your site to its response page, rather than beforehand.
When developing for c5, I don't worry about packages. Just get it working by plonking stuff in /application. When you're ready to publish, package it. The only problem with this is if you're doing something that can't be packaged, but I doubt that's the case here.
When developing for c5, I don't worry about packages. Just get it working by plonking stuff in /application. When you're ready to publish, package it. The only problem with this is if you're doing something that can't be packaged, but I doubt that's the case here.
Well the $query = array() along the paypal parameters are just after the
condition.
I did this as the user has to select a payment type from the form as the $paymentType variable is holding the input select value of the form in view.php.
The query parameters which will be passed to paypal is as thus:
So if you're saying this part here is premature what do you suggest should I do to correct this and I'm not aiming to have it structured rather have this thing working.
if($paymentType == "Paypal")
I did this as the user has to select a payment type from the form as the $paymentType variable is holding the input select value of the form in view.php.
The query parameters which will be passed to paypal is as thus:
if($paymentType == "Paypal"){ $query = array(); $query['cmd'] = 'donations'; $query['email'] = $this->post('dEmail'.$bUID); $query['business'] = 'xxx-xxx@email.com'; $query['first_name'] = $this->post('dFirstName'.$bUID); $query['last_name'] = $this->post('dLastName'.$bUID); $query['address1'] = $this->post('dAddress1'.$bUID); $query['address2'] = $this->post('dAddress2'.$bUID); $query['H_PhoneNumber'] = $this->post('dPhone'.$bUID); $query['city'] = $this->post('dSuburb'.$bUID); $query['state'] = $this->post('dState'.$bUID); $query['zip'] = $this->post('dPostcode'.$bUID); $query['item_name'] = 'Donation to XXX Org)'; $query['item_number'] = '1';
Viewing 15 lines of 34 lines. View entire code block.
So if you're saying this part here is premature what do you suggest should I do to correct this and I'm not aiming to have it structured rather have this thing working.
My understanding is that acts like a goto statement. Any of your code after it in that page won't be executed. Put some debugging thing after it to test this theory.
Does a different page from your site get loaded after the payment has been processed? My guess is that it should be, called from the payment processor's server. If so, that's where you need to capture the returned parameters.
$this->redirect
Does a different page from your site get loaded after the payment has been processed? My guess is that it should be, called from the payment processor's server. If so, that's where you need to capture the returned parameters.
It currently does not go to a different page when the payment is processed.
If I were to get the return url to a new page how am I going to get the POST data with the user details from the form the submission page into the new page?
If I were to get the return url to a new page how am I going to get the POST data with the user details from the form the submission page into the new page?
What page loads as a result of your redirect statement?
Its the submisson form page itself as setup on the paypal dashbord in my accounts -> profile -> selling tools -> website preferences.
When the donation page loads the Request method doesn't work as the condition is not cleared.
So I guess it needs to go to a new page with a PHP process script on it.
When the donation page loads the Request method doesn't work as the
if ($paymentType == "Paypal")
So I guess it needs to go to a new page with a PHP process script on it.
That would be one way, and probably the way I'd do it because it provides a better user experience: you can say 'thanks' instead of 'pay again'. That's how may email forms react.
However, you should also be able to do it when the original form page is reloaded, but you'll have to extract your URL parameters in a function that executes whenever the page is reloaded. submit() is not such a function.
However, you should also be able to do it when the original form page is reloaded, but you'll have to extract your URL parameters in a function that executes whenever the page is reloaded. submit() is not such a function.
Alright, which is the best function you would suggest?
if I want to retain all the form attributes from the $this->post('fieldname'.bUID), how am I going to get all of these to a new page after the paypal redirect?
if I want to retain all the form attributes from the $this->post('fieldname'.bUID), how am I going to get all of these to a new page after the paypal redirect?
Can you do it in view.php?
Before going too far, verify that the form values (or variables) are retained across page loads. You'll probably need to store them in the database at some stage, so their persistence may not be a problem. However, you'll need to ensure that success/failure responses from the payment server are matched to your form data.
Before going too far, verify that the form values (or variables) are retained across page loads. You'll probably need to store them in the database at some stage, so their persistence may not be a problem. However, you'll need to ensure that success/failure responses from the payment server are matched to your form data.
Okay, I'll move the $if paymentType statement to the view.php and have another function to capture the parameters from the return url once the payment is complete.
I'll reply once I'm done.
Thanks again.
I'll reply once I'm done.
Thanks again.
Another unsolicited question/suggestion: do you have some sort of debugging process? If not, I think this could help a lot. It would allow you to inspect the flow of control, so you can see what's being executed and what's not. You can also inspect variables.
You can do this crudely by displaying or logging within your c5 code. Alternatively, you can use a development environment, such as Visual Studio Code.
You can do this crudely by displaying or logging within your c5 code. Alternatively, you can use a development environment, such as Visual Studio Code.
Well I'm currently using IntelliJ as a development environment and as for debugging I've enabled concrete5's debugger mode on the dashboard.
The debugging I do well is mostly on browser inspection tools and console as well as virtual machines as I my experience is leaning towards front-end development.
Is there any other methods for debugging in Concrete 5 besides echo $variable as this doesn't seem much use in controllers?
The debugging I do well is mostly on browser inspection tools and console as well as virtual machines as I my experience is leaning towards front-end development.
Is there any other methods for debugging in Concrete 5 besides echo $variable as this doesn't seem much use in controllers?
I second the suggestion to look into Visual Studio Code. Add xdebug to your server (It may already be installed.) and you can step through the PHP and inspect objects and variables. Very helpful. You'll need to add a couple free PHP extensions to VSCode. Google Visual Studio Code and xdebug. There are some blog posts and videos that tell how to set it up.
I'm sorry but just just 'no' for Visual Studio Code.
InteliiJ wins out for its intellisense and this is how I got through the annoying Angular 1.x and its supporting libraries.
The only thing good about visual studio is having a project in Typescript and if a developer is moving to Angular 2 to while intelliJ has a host of supporting libraries and plugins for quite a number of language platforms and a good Intellisense even though Visual Studio Code is free its lacking features especially for node.js.
InteliiJ wins out for its intellisense and this is how I got through the annoying Angular 1.x and its supporting libraries.
The only thing good about visual studio is having a project in Typescript and if a developer is moving to Angular 2 to while intelliJ has a host of supporting libraries and plugins for quite a number of language platforms and a good Intellisense even though Visual Studio Code is free its lacking features especially for node.js.
IntelliJ will be fine, and better than Code. I only use Code because it's cheaper.
Check out the IntelliJ doco/help re breakpoints, and variable inspection/watches.
I suspect c5's debugging setting won't help you much, but there's little harm in using it during development.
echo()ing variables is a good approach. If you can't see what's being echoed (due to page layout or other pages being loaded), you might be able to use c5's \Log::addEntry(...) to write lines to the log that you can access in your site's dashboard. (The latter function has been deprecated, but I don't know what's replacing it.)
Check out the IntelliJ doco/help re breakpoints, and variable inspection/watches.
I suspect c5's debugging setting won't help you much, but there's little harm in using it during development.
echo()ing variables is a good approach. If you can't see what's being echoed (due to page layout or other pages being loaded), you might be able to use c5's \Log::addEntry(...) to write lines to the log that you can access in your site's dashboard. (The latter function has been deprecated, but I don't know what's replacing it.)
Alright will try it out and get the xdebug installed.
Thanks all.
Thanks all.
I second the suggestion to look into Visual Studio Code. Add xdebug to your server (It may already be installed.) and you can step through the PHP and inspect objects and variables. Very helpful. You'll need to add a couple free PHP extensions to VSCode. Google Visual Studio Code and xdebug. There are some blog posts and videos that tell how to set it up.
I second the suggestion to look into Visual Studio Code. Add xdebug to your server (It may already be installed.) and you can step through the PHP and inspect objects and variables. Very helpful. You'll need to add a couple free PHP extensions to VSCode. Google Visual Studio Code and xdebug. There are some blog posts and videos that tell how to set it up.