Closed (fixed)
Project:
Payment
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
14 Dec 2011 at 01:01 UTC
Updated:
18 Sep 2014 at 11:15 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
xanoPayment Form already provides a way to manually add payments. In most cases, however, this is not very useful, because there is no way to establish a link with an order, for instance. Implementing modules will probably have to provide their own payment add pages, but we can try to make Payment Form's form as reusable as possible.
Comment #2
xanoThis patch uses the field integration from #1511086: Make payments fieldable to update the payment edit page to a versatile add/edit page and makes Payment Form use this instead of a completely custom form.
Comment #3
xanoThere is no page, just a reusable form.
Comment #4
xanoAdded and committed to 7.x-1.x-dev.
Comment #6
chaby commentedHi,
i tried to integrate this form into a custom form (form selling subscriptions using subs module). I based my work on the existing paymentform module.
I think i couldn't simply use drupal_get_form('payment_form', $payment) and merge it with the custom form as it will execute all constructors/process handlers on form...(form id, token, and so on). Furthermore and despite further attempts, process elements are executed at least twice (??), which of course result in some differents kinds of errors (payment object are reset after first process, also first executed works great but not the second which BTW didn't have to be executed... !).
That why i have tried to do it without using form api (indeed, very ugly...) but by simply get the form array from the form id function constructor (payment_form()).
I used this returned form as a children element in the custom form (wrapper into fieldset) and set proper validate/submit handler (payment_form_validate/submit) to its in addition to custom validate/submit handlers.
If we dont have to use payment_method element (only one method available), everything seems to works fine. (For e.g, i used ajax too to create further line items by selecting some existing products (subs) and total order is ok).
But if we have further payment method, also payment_method element is displayed in form. It used ajax to rebuild something when selecting a payment method (dont know what, i have no time yet to looking for).
As a result, validate and submit handler are executed on this element through ajax process. And in the validate handler of this element, there is a $form_state['rebuild'] = TRUE which have the effect of bypassing submit form handlers in my use case...
In fact, when we switch from method payment, form is flag as to be rebuild. And when we submit the form, we bypass submit handlers in drupal_process_form() as form is flag to be rebuild via ajax (but validate handlers are executed).
By comment this rebuild in payment method validate, it seems to work fine.
But what i can't understand is that regarding to the module paymentform, if i used this field and have further payment method, form is flag to be rebuild too but after submit the form, it's like it didn't have been stored in cache and also default value to rebuild is set to false. Which will of course let's api execute submit handlers properly...
This isn't a bug as i don't know if i used the good way for that and i have maybe made some errors or don't understanding somethings... But i want to know if somebody has the same trouble ? And how to do it properly ?
Also why this validate element handler need to rebuild the form ?
And mostly, a particular way to integrate payment_form into a custom form ? Some advices are welcome !
thanks you for reply
Comment #7
xanoHi @chaby!
1) Calling drupal_get_form() from within a form that was called using drupal_get_form() can cause unexpected side-effects, as the system was never designed to work this way. In some situations it might work, but that really depends on the situation and it will never work perfectly.
2) Please take a look at #1606628: Make the payment form embeddable, which tries to make the payment form usable within other forms. It is not ready yet, but if you take a look at the patch, you can see what approach is being taken and whether that will work for you.
3) I understand why you posted your problem in this issue, but please do not reopen issues that have been closed for a while, unless your problem and the issue's are identical. In this particular case, please follow the issue I linked to above and once the patch works, you can test it and confirm whether it does what you are looking for or not :)
Comment #8
xanoComment #9
sumaiyajaved commentedThis feature exists but when I click on "Add payment" nothing happens. Can anyone help?
Comment #10
xanoPlease don't re-open existing issues, but open a new one and include step-by-step instructions to reproduce the problem on a clean Drupal installation.