I get this error when submitting donations:

warning: Missing argument 2 for pay::form(), called in pay/includes/handlers/pay_form.inc on line 122 and defined in pay/includes/handlers/pay.inc on line 253.

Problem is this:

// pay_form.inc, line 122. We don’t have the $form variable available, only the form state.
$form[$pay_method->pmid] = $pay_method->form($form_state);

// pay.inc line 253. Requires both $form and $form_state <em>by reference</em>.
function form(&$form, &$form_state) {

It could ostensibly be fixed by doing something like this:

// pay_form.inc, line 122. Make a fake $form variable.
// We can’t just pass an empty array to the form method, since it expects a reference.
$form = array();
$form[$pay_method->pmid] = $pay_method->form($form, $form_state);

But that might not work particularly well if the form function expects to use the contents of $form.

CommentFileSizeAuthor
#5 pay.907518_01.patch811 bytessgabe

Comments

jerdavis’s picture

Status: Needs review » Postponed (maintainer needs more info)

Hi Mikl,

I haven't seen this error myself yet, can you provide any further information on the configuration you're working with? What payment method are you using and how is it configured? How is your donation form configured? Screenshots may also be helpful.

Thanks!

Jeremiah

mikl’s picture

Version: 6.x-1.0-alpha4 » 6.x-1.0-alpha5
Status: Postponed (maintainer needs more info) » Needs work

Hi Jeremiah,

The problem is that pay::form(&$form, &$form_state) takes two parameters, but in pay_form.inc, it is called as $pay_method->form($form_state);.

This might not be an issue if you override pay_form::pay_method_form() in your implementation, but it is still a bug, as $form_state is passed where the form data would usually be.

The reason I found this was that I was trying to implement PayEx support for Pay API, ie. defining PayEx as a payment method. My efforts in that regard has mostly stalled due to #904544: Fatal Error: pay.transaction.inc is missing, so if you could please commit the missing file soon, I would probably be able to dig into this more.

allie micka’s picture

I can confirm what's happening. I'm not sure how mikl is triggering it because I haven't seen it either, but the lines he is citing, ~122, illustrate what's going on.

When I first wrote pay, the form() method was returning a form, kinda like how a CCK widget, webform component, hook_user, etc. might work. But that was inflexible because your form handler might want to use an email/amount/etc. field from elsewhere in the form. Thus, I rewrote things so that pay::form() gets $form and $form_state by reference, and does not return anything.

pay_form::form() extends pay::form(). These methods are both operating by reference and everything works out great. However, the code mikl is pointing to expects pay_method::form() to function the "old way", and however he is using it is breaking things.

Since this is working "properly" elsewhere, a workaround is to do what other handlers are doing to avoid running into this. However the correct solution is to fix pay_method so that it behaves consistently by using referenced values of $form and $form_state.

This seems tricky because we're expecting to embed multiple, possibly-conflicting pay_method formlets. But it's entirely possible I'm overthinking things. In fact, it might be nice if the payment methods wound up sharing certain details, such as billing address, but maintained their own fields for specific backend details.

sgabe’s picture

I tried PayPal with Webform Pay and I got this error.

sgabe’s picture

StatusFileSize
new811 bytes

I ended up with this.

skadu’s picture

Hello all, first off, great idea for the module, I am however unfortunately receiving this same error. I am currently trying to implement this in conjunction with the Webform Pay module using the Credit Card payment type. If I switch to Authorize.net I do not receive this error. The modules involved with this are all updated to the correct versions. I attempted to apply the patch provided by sgabe, I added the three new lines to the pay_method_direct.inc file so it now reads:

class pay_method_direct extends pay_method {
// added the following three lines in a patch attempt
function form() {
parent::form($form, $form_state);
}
function settings_form(&$form, &$form_state) {
parent::settings_form($form, $form_state);
$group = $this->handler();

// Eliminate the 'authorized' option from the settings.
unset($form[$group]['pay_form_activity']['#options']['authorize']);
}
}

With these changes and all caches flushed I am still receiving the same error for the Credit Card payment type. Is there any other information you guys may need from me to help get this issue resolved? Thanks in advance.

sgabe’s picture

Note that I used Webform Pay with a custom payment method which extends the pay_method_direct class. I don't know Credit Card payment type, is that a direct method? I don't think so... Could you provide a link to it's project page?

skadu’s picture

I added the Credit Card payment method within the Payment Configuration section, the correct title would have been "Custom Payment" but I renamed it to credit card, apologies for the confusion. It, along with Authorize.net where the two types of payments available when I installed the module. Authorize.net was available because I also installed the authorize.net payment(http://drupal.org/project/authorizenet). In the payment settings area it says the handler is a custom payment, that should be used for "Manual payment entry, for COD payments, pledges, or manually incrementing a total." which is what I was hoping to accomplish using this module. I am thinking now this means I am supposed to write a custom payment method, such as you say you have done. I guess I had assumed it was an option built into the Pay module.

Thanks for the quick response. I really appreciate it.

allie micka’s picture

Status: Needs work » Fixed

I just committed a change. If people could have a look and make sure the error has gone away where they were seeing it, I'd really appreciate that!

IMPORTANT - see http://drupal.org/cvs?commit=455452 for details on possible API breakage if you're working on a pay_method module that implements form() for some reason.

WillHall’s picture

Error Persists - Clean installation of a6.

NM, Just one of those days.

sgabe’s picture

I can confirm this as a fix. However Webform Pay needs to be updated.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

drupalsteve’s picture

Status: Closed (fixed) » Active

I'm using Pay 6.x-1.0 and Donate 6.x-1.0-alpha2 on a Drupal 6.20 installation.

I'm seeing a similar error as above:

warning: Missing argument 2 for pay_form::pay_method_form(), called in [redacted]/sites/all/modules/donate/includes/donate.inc on line 199 and defined in [redacted]/sites/all/modules/pay/includes/handlers/pay_form.inc on line 146.

I'm using a Sandbox PayPal Payments integration.

darrellduane’s picture

There is a thread with more details in the Donate module's issue queue:
http://drupal.org/node/1092328

kevinquillen’s picture

Issue still persists.

allie micka’s picture