Hi,
Hoping someone can shed some light.
I'm currently developing a payment module for Suncorp Bank Virtual POS.
It's a requirement that only certain data is sent to their server + a hash must be created based on the form data so I need to modify the data before it is submitted to their server.
Is there anyway to manipulate the data after the payment form is submitted and before it get's sent to the 3rd Party Server (Suncorp)?
Looks like the process goes:
CALLBACK_commerce_payment_method_redirect_form
which submits directly to the payment server then upon return from the 3rd Party Payment server:
CALLBACK_commerce_payment_method_redirect_form_validate gets called.
At the moment I modify the data by submitting to a custom menu item then use drupal_goto to send the data as get variables to the payment server, however CALLBACK_commerce_payment_method_redirect_form_validate is not getting called on return.
Surely you must be able to manipulate user submitted data on the server side before sending to a hosted payment provider?
Any advice appreciated.
Comments
It depends, often modules
It depends, often modules will provide an _alter() hook for you to alter data before something happens to it. Look inside the functions for a call to
drupal_alter('some_key', $some_variable), this will be a call tohook_some_key_alter($some_variable), and you can modify your data there. If you can't find anything, you should open a ticket in the module issue queue, and request this hook to be added to the module.Contact me to contract me for D7 -> D10/11 migrations.
Workaround
Thanks or your reply, unfortunatly I'm a bit pushed for time so had to do a work around solution.
Other's out there may find it useful, however I've looked at serveral hosted payment solution modules and they all seem to post the data directly to the payment provider. Which is OK if the payment provider doesn't mind receiving drupal fields such as form_build_id, form_id and form_token.
I had to remove those fields, then create a form where the form keys are ordered alphabetically. (a requirement of Suncorp).
Then hash the data on the server side and add the hash to the submit button value. Rename the submit button to vpc_SecureHash.
Then a nasty css hack to remove the submit button value as this is the hashed data (must be the LAST value submitted to Suncorp, yay)
This is by no means a work of art, in fact a bit of a hack/workaround, I'd love to hear a better solution if someone can provide it.
Just want to modify the data server side however then submit to the payment gateway however drupal_goto seems to stop the form validation and submit flow.