We ran into a critical problem using this module with WPP. Everything appears to be working as it should until it comes time for the recurring payment to be processed. At that point it creates the recurring order as expected but says "Error: Recurring fee 3 for product X failed."

Looking into the paypal side it would appear that the recurring payment is being setup as it should but when it comes time for it to process it was processing $0. It took a few hours for me and a paypal tech to figure out what was happening.

It appears the uc_recurring payments is submitting a "trial period" along with the rest of the information for the recurring payment. So in my case I have a recurring fee setup like this:
"When X of this product is purchased, add a fee for $29.80 charged first after 12 weeks and every 3 months after that unlimited times."
What it is submitting to paypal is more like this:
When X of this product is purchased, after the first 12 weeks provide a 12 week trial period (charge $0) and add a fee for $29.80 charged first after the trial period and every 3 months after that unlimited times.

So basically rather than starting the recurring payments after the first 12 weeks it charges $0 (which comes back to UC as an error) and then after the trial period it will begin to charge $29.80 as expected (which I don't yet know how UC will respond).

Here is what paypal said is being sent:

Profile ID: I-K4W938HE4USV created Timestamp Apr. 20, 2011 23:31:59 CDT

profilestartdate "2011-07-13T23:31:57-05:00"
profilereference "825"
trialbillingperiod "Week"
trialbillingfrequency 12
trialtotalbillingcycles 1
trialamt "0"
billingperiod "Month"
billingfrequency 3

It indicates a start date 3 months after being created and a 1 trial period of 12 weeks for $0.00 before the regular 3 month cycle begins.

I noticed that the subscription manager piece of this module has a setting for a trial period when creating a subscription; however, we have not enabled the subscription manager on this site. We are simply using normal recurring payments.

How can I fix this problem? What is causing this problem?

Thanks

Comments

univate’s picture

Priority: Critical » Normal
Issue tags: +Paypal WPP

We use the trial field since the amount that ubercart could generate on the order total may be different to the recurring amount. It sounds like everything is being setup correctly?

I can only presume that maybe the field trialtotalbillingcycles should be 0 instead of 1. But since I don't use this gateway I can't test this, you should try it out and submit a patch. Downgrading issue from critical as it doesn't effect this module directly and only related to a specific gateway which I don't support any gateways (its up to developers like yourself using specific gateway to submit code that is required for specific gateways.).

deggertsen’s picture

Thank you very much for the response.

I will look into the setting the trialtotalbillingcycles to 0 instead of 1 and give more feedback.

deggertsen’s picture

I haven't been able to figure out anything. I have posted a separate issue for hiring somebody to help with this and other problems we're having.
#1251074: Hiring to fix paypal WPP integration

deggertsen’s picture

I've hired a team to fix this issue and expect them to have a patch soon.

deggertsen’s picture

Status: Active » Needs review
StatusFileSize
new39.8 KB
new21.17 KB
new16.17 KB

I've attached 3 patches produced by the company Ebizon that I hired to fix several issues with the Paypal WPP Gateway. Please review the attached and commit if they look like they're good. I've looked over the patches and everything looks good to me, but I'm no PHP expert.

Thanks

univate’s picture

Status: Needs review » Needs work

Thanks, couple of points from looking over these briefly.

I not going to be able to accept those changes to the uc_recurring.patch as it includes paypal specific stuff - it needs to be moved to the uc_recurring_hosted module where all the other paypal stuff is.

There are alot of changes to uc_recurring_hosted and it will need to be carefully checked both paypal wps and paypal wpp still work and these changes don't break existing sites.

The paypal patch will need to be submitted to the ubercart project.

There are butch of minor coding standard issues that also need to be fixed in these patches.

Unfortunately unless your developer is willing to communicate directly here or another developer can take these and resolve all these minor issue I can't really commit (as I personally don't use Paypal myself)

aaronbauman’s picture

I'm not having any such issue with the latest version of 2.x-dev

Also it's really hard to digest these patches when there are so many unrelated changes (coding standards, unnecessary changes to comments, etc).

deggertsen’s picture

StatusFileSize
new8.34 KB
new2.38 KB

I have gone through and simplified the patches I provided above. I am in the process of testing the changes. The attached patches are based on the most recent dev version of both this module and that of ubercart. I understand that the way these patches are done may not be a viable solution as it modifies ubercart as well as uc_recurring, but I hope they will at least be one step closer to a solution. These patches should at least be decipherable, unlike those I posted above.

deggertsen’s picture

With the patches above all my recent testing has come back positive. All payments are going through and orders are being updated correctly thus far.

aaronbauman’s picture

Status: Needs work » Needs review

Ok, now that i've been through a few billing cycles, I can confirm this same issue.
I will give these patches a spin and see if that makes a difference.

Related: anyone know a good way to batch-update existing paypal recurring payment profiles to fix the problems described above?

aaronbauman’s picture

The patch in #8 disables trial payments for WPP altogether, which makes sense to me since i will never have use for a trial period, and since trial payments are explicitly disabled for Auth.net.

Maybe the confusion around this issue is the cryptic "initial charge" setting, especially with regard to how Auth.net handles it compared to WPP.
Can anyone explain why WPP creates a trial period based on "initial charge", but Auth.net does not?

For WPP, setting a value for "initial charge" seems to delay the first payment by that value.
In other words, if I want to set up monthly billing, but i set my "initial charge" to "1 month", then I will not collect the first payment for 2 months, because the "trial period" will be charged after the first month, with amount $0. On the second month, the "trial period" is complete, then the regular charges will kick in.

For Auth.net, the "initial charge" option is ignored altogether.
Note the lines 'trialOccurrences' => '0' and 'trialAmount' => 0
from uc_recurring_hosted_authorizenet_arb_process():

  // Build the data array for the request.
  $data = array(
    'refId' => substr($order->order_id .'-'. time(), 0, 20),
    'subscription' => array(
      'name' => substr(t('Order @order_id', array('@order_id' => $order->order_id)), 0, 50),
      'paymentSchedule' => array(
        'interval' => array(
          'length' => $length,
          'unit' => $unit,
        ),
        'startDate' => date('Y-m-d', $fee->next_charge),
        'totalOccurrences' => $fee->remaining_intervals == -1 ? 9999 : $fee->remaining_intervals,
        'trialOccurrences' => '0',
      ),
      'amount' => round($fee->fee_amount, 2),
      'trialAmount' => 0,
// ...

Is this an intentional discrepancy between the two payment gateway processing callbacks? If so, why?
Univate, if you can't answer these questions, maybe you can call someone's attention to this issue who understands the paypal processes more thoroughly, because we certainly do not.

RachelNY’s picture

Did you guys have any success in getting this resolved?

Thanks,
Rachel

deggertsen’s picture

As far as I know, the patches I provided above do resolve the problem. Probably not the cleanest solution, but I think it works. Until we can get a few others and a maintainer to look at this it will probably remain that way. See if the above patches fix the problem for you and then report back here.

srahul07’s picture

I am also facing the same issue with WPP.

My Requirements:
On purchasing a product, the amount of $X should be charged. Then the Initial recurring Charge should be $Y after 30 days, and the regular interval must be 2 months with the same amount as that of initial recurring amount.

So, I have purchased a product on 1May, the initial recurring should be on 31 May and second recurring payment should be 30 July.

Issue:
But, when I checked into the Paypal, I see that the Order is placed on 1 May with valid amount as above. Then after 30 days, i.e. 31 May the initial recurring executed with $0.00, and the next payment date is 30 June.

The Paypal order shows Payment activity as follows:

Payment Type: Initial Payment
Amount due: $0.00 USD
Amount Received: $0.00 USD
Payment Type: Trial Period
Payment Cycle: Every 30 days
Total cycles: 1
Cycles remaining: 0
Amount due per cycle: $0.00 USD
Amount Received: $0.00 USD
Payment type: Regular Recurring Payment
Payment cycle: Every 2 Months
Total cycles: Indefinite
Cycles remaining: Indefinite
Amount due per cycle: $Y USD
Amount received: $0.00 USD

Payment summary: 
Total received: $0.00 USD

Last payment activity:
Payment Type: Schedule Payment
Date: May 31, 2012
Amount received: $0.00 USD
Payment status: success

I guess mine is the same problem as described by deggertsen, I will try the patches provided in comment #8 by deggertsen.

Is there any permanent solution for this?
Also, how can I update the original order in paypal as it shows trial period for 30 Days.

srahul07’s picture

I tried the patches provided in comment #8.

The

uc_recurring_hosted.module

file patch is giving me error as

Patch file contains multiple patches. you can not apply them to a single file.

and uc_paypal.module gives local file content empty with respect to the lines present in patch file, also reference module file is having line number different than that of the patch file reference line numbers.

srahul07’s picture

Priority: Normal » Critical
Status: Needs review » Active

I got the issue.

The

uc_recurring_hosted

module's

uc_recurring_hosted.module

file line number 662 has list($trial_length, $trial_unit) = explode(' ', $fee->initial_charge);

And line number 795 - 800 are:

if ($trial_length > 1) {
    $nvp_request['TRIALBILLINGPERIOD'] = $trial_unit;
    $nvp_request['TRIALBILLINGFREQUENCY'] = $trial_length;
    $nvp_request['TRIALTOTALBILLINGCYCLES'] = 1;
    $nvp_request['TRIALAMT'] = 0;
  }

This says that $trial_length will be the the integer part of initial_charge. So, if initial_charge is set to 1 day OR 1month OR 1 week, the $trial_length = 1

In if condition, it will bypass the trial period setting variables since $trial_length = 1

In my case, the initial_charge = 30 days

So, the $trial_length = 30

Hence it is setting the trial variables.

Can you please let me know the significance of the if condition on line number 795? Also, I guess there should be a flag for setting trial period like the one present for authorize.net

FYI: Have marked this as a critical since this bug is against the functionality. There should be some setting like we have for authorize.net for trial period, may be some flag.

bonnie1968’s picture

Has anyone had problems with paypal not interpreting the trial period correctly? I have a subscription for $39.99 for 3 months and then it is to charge $9.99/month after the 3 month period. Paypal interpreted it as charge $9.99 after 6 months (which I don't get). So every month I am getting an error processing those recurring payments. I set up the product features correctly so I don't know what it could be. Monthly recurring subscriptions are processing fine. Any help would be appreciated. Thanks

niklaz’s picture

Has anyone tried to set $nvp_request['TRIALAMT'] = round($fee->fee_amount, 2); instead to 0?

I have similar issue. If I don't set initial charge to some period and leave it to 0, then I get charged once more, right after original purchase. However, if I do set initial charge to some period, I don't receive IPN since it charges amount of 0 - thus doesn't charge.
So I thought it should be ok to change the code as above.