Simple Machines Community Forum

SMF Development => Bug Reports => Fixed or Bogus Bugs => Topic started by: Looking on December 14, 2015, 02:42:36 PM

Title: Paid Subscriptions Bug?
Post by: Looking on December 14, 2015, 02:42:36 PM
SMF 2.0.11 - I will like to believe I'm doing something wrong but a number of tests show:

1. In sandbox mode it shows payment made in Paypal but does not update the group in SMF
2. If you have recurring subscriptions checked then Paypal cannot read the payment in sandbox mode and shows a red screen with red writing that they are experiencing problems.

Even when doing a live test the same occurs. Payment made properly but no update on SMF's end for the group.
Title: Re: Paid Subscriptions Bug?
Post by: Kindred on December 14, 2015, 04:29:31 PM
Did you check the post 2 below yours?

http://www.simplemachines.org/community/index.php?topic=541821.0


Paypal apparently changed something without telling anyone.
(this is why we HATE having third party integrations in the core product)
Title: Re: Paid Subscriptions Bug?
Post by: Looking on December 14, 2015, 04:59:54 PM
Thank you much Kindred, I did not see that other thread.

I applied the change and in sandbox it fixes point 1. but not point 2.

Also, for point 1. it only sets it to "payment pending" rather than change the group so in a way point 1 is not solved yet.
Title: Re: Paid Subscriptions Bug?
Post by: Sir Osis of Liver on December 14, 2015, 07:58:10 PM
The hex code bug does not affect subscription activation, it works normally but returns subscriber to board index instead of subscription confirmation page.  Sandbox does not always duplicate live subscription.  Set up a test sub for $0.10/1 day, and see if you still have the problem.

Edit:  Sandbox payment works for me in 2.0.11 with recurring payment enabled.
Title: Re: Paid Subscriptions Bug?
Post by: Looking on December 14, 2015, 09:58:00 PM
Tried it live and the subscription was added, I got an Email about the payment but SMF shows nothing about it under Admin. Group does not change.
Title: Re: Paid Subscriptions Bug?
Post by: Sir Osis of Liver on December 15, 2015, 02:05:48 PM
Not clear on what you're getting. 

  'Subscription was added' - do you mean to PayPal account?
  'Email about the payment ' - from PayPal?
  'Group does not change' - is admin seeing a pending payment, or nothing at all?  Anything in error log?  Does subscription work with recurring disabled?

Title: Re: Paid Subscriptions Bug?
Post by: Looking on December 16, 2015, 06:08:37 AM
Let me answer by asking this question if you don't mind, just to make sure I understand the system: When someone subscribes is it coded so that the group changes automatically or is it that Admin has to manually login and change the date? If so, why does the end date start at 2005 rather than the number of days indicated?
Title: Re: Paid Subscriptions Bug?
Post by: Kindred on December 16, 2015, 07:47:59 AM
I believe that the 2005 end date indicates a failure of your system to receive the correct information from PayPal

Which -- since we can confirm that it works properly for us -- suggests some difference in configuration on your side
Title: Re: Paid Subscriptions Bug?
Post by: Looking on December 16, 2015, 07:51:38 AM
What is usually the general failure? I did the code edit. Everything in configuration is straightforward, what might I be missing?
Title: Re: Paid Subscriptions Bug?
Post by: Sir Osis of Liver on December 16, 2015, 12:18:45 PM
2005 is default setting for unactivated subscription.  Are you logging an error?  If you can pm admin access, will take a look tonight.  Replace any files you edited with clean originals.
Title: Re: Paid Subscriptions Bug?
Post by: Looking on December 16, 2015, 08:27:22 PM
Question: When someone pays for the first time are they supposed to automatically have their membership change or does Admin have to go to Admin and activate it?
Title: Re: Paid Subscriptions Bug?
Post by: Kindred on December 16, 2015, 08:36:36 PM
as on this site -- the system automatically updates their membergroup based on the returned confirmation of the subscription payment
Title: Re: Paid Subscriptions Bug?
Post by: Sir Osis of Liver on December 16, 2015, 10:19:01 PM
Not clear on what you're getting. 

  'Subscription was added' - do you mean to PayPal account?
  'Email about the payment ' - from PayPal?
  'Group does not change' - is admin seeing a pending payment, or nothing at all?  Anything in error log?  Does subscription work with recurring disabled?
Title: Re: Paid Subscriptions Bug?
Post by: Looking on December 17, 2015, 06:51:04 AM
I am not getting any errors.

In test mode the subscriber sees this after subscribing:

"Thank you for your payment. Once the transaction has been verified the subscription will be activated."

Admin gets no Email notification. I have to go in Admin and change the 2005 date and save.
Title: Re: Paid Subscriptions Bug?
Post by: Sir Osis of Liver on December 17, 2015, 02:19:27 PM
Your forum is either not receiving PayPal IPN, or isn't processing it.  Some mods and a few hosts block the IPNs, but that doesn't happen often.  There are several glitches that will cause subscription activation to fail without error.  Upload the attached files (save your originals) and try another subscription.  subscriptions.php is modified to dump the IPN post data into error log if it's received.  Subscriptions-PayPal.php contains additional error handling that's not in the official version.
Title: Re: Paid Subscriptions Bug?
Post by: Looking on December 18, 2015, 01:52:47 PM
Thank you for your continued time.

Uploaded your files and by Email I got:

Quote
The following error occurred when processing a paid subscription
---------------------------------------------------------------
Unknown Paid Subscriptions transaction type.

No errors in the logs. I had to do this with the checkbox unchecked for reoccurring subscriptions as Paypal will not process.

After payment and returning to the site I get payment pending.

Also, i noticed that if I delete a user from a subscription I still get the subscription payments. Is that how it is until they do it via their Paypal?
Title: Re: Paid Subscriptions Bug?
Post by: Kindred on December 18, 2015, 02:27:47 PM
yes -- the USER must remove the recurring charge from their own paypal settings
Title: Re: Paid Subscriptions Bug?
Post by: Looking on December 18, 2015, 02:51:20 PM
Thanks, I will have to code in something for that to be explicit or it can cause problems with refunds / denials.
Title: Re: Paid Subscriptions Bug?
Post by: Sir Osis of Liver on December 18, 2015, 09:14:12 PM
Quote
The following error occurred when processing a paid subscription
---------------------------------------------------------------
Unknown Paid Subscriptions transaction type.

No errors in the logs.

That's odd, it should have logged the error and not sent the email.


Quote
I had to do this with the checkbox unchecked for reoccurring subscriptions as Paypal will not process.

Are you using a personal PayPal account?   Recurring payments are only allowed in business or premium accounts.

Contact PayPal merchant support (ppmts@paypal.com), ask them if IPNs posted to the forum from your account are being blocked.
Title: Re: Paid Subscriptions Bug?
Post by: Looking on December 23, 2015, 07:07:36 AM
Sorry for the delay in responding, I was waiting on Paypal. Their response is there is no block and the IPN was sent out successfully with a 200 response code from the server.

Yes, I have a premier account although with their new interface I do not see it explicitly stated. Maybe I need business?

I am going to set this up on another site to see if I get a different response.
Title: Re: Paid Subscriptions Bug?
Post by: Sir Osis of Liver on December 23, 2015, 12:29:14 PM
PayPal allows recurring payments (they call it subcriptions) in business and premier accounts.  If you do a subscription with recurring disabled, you'll go to the PP personal account payment interface.  With recurring enabled, you'll go to the business interface.  If you have the wrong type of account, PayPal will display an error message that you're not authorized to do recurring payments.

Can you set up a clean test install on same account as your production site and give me admin access?
Title: Re: Paid Subscriptions Bug?
Post by: Looking on December 23, 2015, 02:33:35 PM
Maybe I have it blocked in my Paypal account, will check later, but first I need to work this on another site to see if it is unique to me. I will return and report. Thanks.
Title: Re: Paid Subscriptions Bug?
Post by: Sir Osis of Liver on December 23, 2015, 07:52:26 PM
You can't block IPNs in your PayPal account.  Subscriptions-PayPal.php sends a notify_url (link to your forum's subscriptions.php) which overrides IPN settings.
Title: Re: Paid Subscriptions Bug?
Post by: Looking on March 30, 2016, 08:39:27 PM
I am working on another site. The bug fix of "&" over ";" fixes the urlencode problem and everything works fine, however I noticed that if you check "recurring payment" then on the return Paypal sends back an "Auth=......" code rather than "profile;u=1111;area=subscriptions;sub_id=1;done" so nothing is registered. Is this happening to anyone else?
Title: Re: Paid Subscriptions Bug?
Post by: Sir Osis of Liver on March 30, 2016, 09:49:57 PM
The semicolon problem does not affect subscription activation, subscription is successful but returns user to main index instead of confirmation page.  If subscription is failing, that's a different problem altogether.  Are you getting a paid subs error in your log?  Are you running the Subscriptions-PayPal.php I posted here (http://www.simplemachines.org/community/index.php?topic=541980.msg3852293#msg3852293)?  Where are you seeing the Auth= code?

Title: Re: Paid Subscriptions Bug?
Post by: Looking on April 01, 2016, 07:03:35 PM
Thanks for your reply. Sorry for the delayed reply.

I am seeing the Auth code in the return URL from PayPal for example:
/index.php?auth=A2.uSamhLI95WqNLKPY0i581N9NQ23wHfqpbyFgr-qex6pVdmSN29PQnhPNUelAArHkjew&form_charset=UTF-8

I did not use your edits. Just checking logs it says: "Undefined index: action"

Also, what happens if the subscriber does not hit the return to site button after payment does that mean SMF will not be able to record and Admin will have to manually enter the subscription based on an Email from Paypal? If so, is the Member ID sent as part of the info under notes?
Title: Re: Paid Subscriptions Bug?
Post by: Sir Osis of Liver on April 01, 2016, 09:46:26 PM

I am seeing the Auth code in the return URL from PayPal for example:
/index.php?auth=A2.uSamhLI95WqNLKPY0i581N9NQ23wHfqpbyFgr-qex6pVdmSN29PQnhPNUelAArHkjew&form_charset=UTF-8

Haven't a clue what that is, PayPal is changing the return url.  The correct url is put together in Profile-Actions.php -

Code: [Select]

$fields = $gateways[$id]->fetchGatewayFields($context['sub']['id'] . '+' . $memID, $context['sub'], $context['value'], $period, $scripturl . '?action=profile&u=' . $memID . '&area=subscriptions&sub_id=' . $context['sub']['id'] . '&done');


and is posted to Paypal with the other transaction data by Subscriptions-PayPal.php -

Code: [Select]

// All the standard bits.
$return_data['hidden']['business'] = $modSettings['paypal_email'];
$return_data['hidden']['item_name'] = $sub_data['name'] . ' ' . $txt['subscription'];
$return_data['hidden']['item_number'] = $unique_id;
$return_data['hidden']['currency_code'] = strtoupper($modSettings['paid_currency_code']);
$return_data['hidden']['no_shipping'] = 1;
$return_data['hidden']['no_note'] = 1;
$return_data['hidden']['amount'] = $value;
$return_data['hidden']['cmd'] = !$sub_data['repeatable'] ? '_xclick' : '_xclick-subscriptions';
>>> $return_data['hidden']['return'] = $return_url;
$return_data['hidden']['a3'] = $value;
$return_data['hidden']['src'] = 1;
$return_data['hidden']['notify_url'] = $boardurl . '/subscriptions.php';


You'll have to contact PayPal support and ask them wtf they're doing.


Quote
Also, what happens if the subscriber does not hit the return to site button after payment does that mean SMF will not be able to record and Admin will have to manually enter the subscription based on an Email from Paypal?

The subscription should activate regardless of whether the subscriber returns to your forum or not.  As I understand it, this is how the process works:

- Forum posts subscription data to PayPal
- If payment is successful, PP posts IPN to forum.  IPN includes verify_sign, which is verification code.
- Forum posts verification code back to PP.
- PP verifies code and posts verification to forum.
- Subscription activates.

None of this is affected by $return_url

Upload the modified Subscriptions-PayPal.php I posted in the other thread.  It contains additional error handling that may tell you why subscription is failing.

 
Title: Re: Paid Subscriptions Bug?
Post by: Looking on April 19, 2016, 10:11:55 AM
As a followup, everything is working well. It seems that sandbox mode limits the ability to test what happens with some of the features described above. When not in test mode everything executed fine.

Thanks for your help Sir Osis of Liver.