1

I'm trying to connect a custom payment module for opencart. Now I have a form that sends all the info collected from the user to a URL something like...

<form action="https://www.mywebsite.com/paymentProcessor.php" type="post">

<input type="text" name="userName">
<input type="password" name="pass">
<input type="text" name="Amount">

<input type="submit" name="submit" value="Confirm">

</form>

Now paymentProcessor.php checks all information provided and returns "YES" or "NO" if the transaction was successful or not respectively then it sends that information back to the callback function in opencart. Now here is the problem , How does paymentProcessor.php send the information to the callback function? What code do i need to include on paymentProcessor.php to set the variable and how does the callback function receive the variables. Any solution in json or anything else will be highly appreciated. thx

BenMorel
  • 34,448
  • 50
  • 182
  • 322
  • Usually there is normal request from `paymentProcessor` back to Your `callback` by sending back all the sent information (for You to check that they were not edited - if yes, the payment is not valid) + the information about the payment itself... This request could be done using `cURL`, `file_get_content`, `fsock_open` or other streaming. `file_get_content` is the easiest way while `cURL` gives You plenty of control over the request. And usually the whole requests (both ways) are encoded using secret key so that they cannot be read/modified... – shadyyx Oct 14 '13 at 09:58
  • Thanks a bunch @shadyyx . U r a life saver. I managed to use file_get_contents() and it works like a charm. thx – Tabula Emmanuel Oct 15 '13 at 07:28
  • OK, I'll post my comment as an answer so that You can accept it and mark the question as answered... But I recommend using `cURL` - though a little more lines are needed to do a request but You have more control over it. – shadyyx Oct 15 '13 at 07:42
  • NOTED. I'll try and read more about curl. thx – Tabula Emmanuel Oct 20 '13 at 14:43

1 Answers1

0

Usually there is normal request from paymentProcessor back to Your callback by sending back all the sent information (for You to check that they were not edited - if yes, the payment is not valid) + the information about the payment itself...

This request could be done using cURL, file_get_contents, fsock_open or other streaming. file_get_contents is the easiest way while cURL gives You plenty of control over the request. And usually the whole requests (both ways) are encoded using secret key so that they cannot be read/modified...

I recommend using cURL for better control over the request though using file_get_contents You can do almost the same using stream headers (PHP doc + example)...

Community
  • 1
  • 1
shadyyx
  • 15,825
  • 6
  • 60
  • 95