By Matt Jackson on Thursday, 05 April 2018
Posted in Payment Gateways
Replies 32
Likes 0
Views 1.2K
Votes 0
Hi there,

We've noticed a couple of our users that have signed up to our plans are being charged twice when their plan is renewed. Most of the users that have had this issue have paid using stripe. We would like to know what could be causing this as we can't keep worrying whether our clients will get charged twice every time their plan is up for renewal.
Hello,

I checked your site and found double payment changed from client , from log's i've found that when payment get completed somehow subscription not updated (expiration date still same as previous), so that next payment was charged on this second one payment subscription updated properly and the notification is correct for both transaction. see attached screenshot. It's coming for some user's only not for every user.

I need some more info on this to rectify this issue
1. Please share your server access and error log of last 2 days.
2. Any kind of customization done on site ?

Please update me , so i'll be able to rectify it.
·
Thursday, 05 April 2018 19:55
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi there I have attached the log files requested.
·
Friday, 06 April 2018 12:45
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Matt,

In error log you attached show error regarding GetCounter function.

[05-Mar-2018 04:14:53 Australia/Sydney] PHP Fatal error: Call to a member function getCounter() on a non-object in /home/dsicapit/public_html/components/com_payplans/libraries/lib/order.php on line 714


Regarding the error, It looks few entries missing in database from order or subscription tables.
Have you deleted some entries manually from database ?
I see some deleted entry logs in payplans Logs section. see attached screen shot.

To resolve this issue , refer below mentioned solution.
Here is the solution for getCounter() function issue.
Go to root/components/com_payplans/libraries/lib/order.php, near line no. 700, find below mentioned of code function

public function getRecurringInvoiceCount()
{
$status = array(PayplansStatus::INVOICE_PAID, PayplansStatus::INVOICE_REFUNDED);

// get counter of last master invoice
$last_master_invoice = $this->getLastMasterInvoice(PAYPLANS_INSTANCE_REQUIRE);
$counter = 0;
if($last_master_invoice){
$counter = $last_master_invoice->getCounter();
}

$totalInvoices = $this->getInvoices($status);
sort($totalInvoices);
$lastInvoice = array_pop($totalInvoices);
$lastCounter = $lastInvoice->getCounter();

return $lastCounter - ($counter - 1);
}


Replace with below mentioned code


public function getRecurringInvoiceCount()
{
$status = array(PayplansStatus::INVOICE_PAID, PayplansStatus::INVOICE_REFUNDED);

// get counter of last master invoice
$last_master_invoice = $this->getLastMasterInvoice(PAYPLANS_INSTANCE_REQUIRE);
$counter = 0;
if($last_master_invoice){
$counter = $last_master_invoice->getCounter();
}

$totalInvoices = $this->getInvoices($status);
sort($totalInvoices);
$lastInvoice = array_pop($totalInvoices);

if($lastInvoice && $lastInvoice instanceof PayplansInvoice)
{
$lastCounter = $lastInvoice->getCounter();
return $lastCounter - ($counter - 1);
}

return false;
}


Update me , if any entity you have deleted then why you have deleted ?
·
Friday, 06 April 2018 15:10
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi there thanks for the reply. What will that code replacement do?

The entries that were deleted were either duplicate subscriptions or some of our test subscriptions that we had before launching the site. Everything deleted was done from the payplans plugin admin backend.

Will that code replacement solve our issue of the duplicate payments?

Thanks
·
Saturday, 07 April 2018 10:50
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello,

Actually you deleted some entities so it's giving fatel error when invoice not found. So i have applied check on the code if invoice object is available then call the get counter function, so it's will not give any error .

Note : In futhure please don't delete any invoice of recurring payment's because it will cause the issue.

This will fix your issue as well as, if still you face any issue please update me.
·
Saturday, 07 April 2018 18:16
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Manisha, I have the same issue with few clients, and they're always getting charged twice. Since we deleted some fake subscriptions and data before, we applied the same fix you mentioned in this ticket on our system as well, but it did not help. Can you please help us figure out why some clients get charged twice?

Here is our Stripe screenshot showing the duplicates and the refunds we had to do: http://prntscr.com/jnnskl
·
Monday, 28 May 2018 23:45
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello,

If you have deleted some of entities related to recurring subscription (invoice , transaction ) manually then the above fix will work in your case. It seems your issue is something else.

I've checked your site and found that on your site one payment made today and last payment done on 24/5/18 (4 days ago), as per screen shot it shows payment made on 27 and 28, but it's not logged in payplans. Payplans will log every transaction if payment request initiated by payplans iteself. I've tried to find out the subscription id as per screenshot but not shown.

Can you share me the subscription id's where you are facing double payment issue.
Update me.
·
Tuesday, 29 May 2018 11:43
·
0 Likes
·
0 Votes
·
0 Comments
·
I believe you were accessing our dev site (as it's showing the payment as per Stripe TEST in your screenshot).

Please access the backend on our live site to see those subscriptions.

I have just sent you a msg on Skype with the login details for the live site.

The most recent double charge is for subscription # 8O56WJCMAHT5.
·
Tuesday, 29 May 2018 13:05
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Mohammad,

I've checked your site and the subscription id you told in your previous reply , shows the transaction correctly. No double payment transaction is created. If payplans request for payment then it always log in transaction , but there is no double charge transaction.
see attached screen shot.

Double payment shown on your stripe account, so need to confirm with Stripe team about second payment.
That second payment request initiated by payplans or not. Can you please contact with stripe team about this and let me know the response, so we will be able to rectify this.

Update me.
·
Wednesday, 30 May 2018 12:08
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Manisha,

I just spoke to Stripe, and their response is:
"It looks like your integration has the subscription(recurring payments) set up on their side and when it's time to invoice the customer they send over a charge request. For this one it looks like they are sending over two separate charge requests starting back in April. This is totally something they will need to look into and handle so your customers are not being charged multiple time."

They have confirmed that the charge requests are both coming from PayPlans. It's funny because the duplicate charge happens 2 hours or 13 hours after the first one. You can tell these are each separate as they each have their own unique ch_ID - http://prntscr.com/josflh .

"Between 04/18/2018 and 04/27/2018 something likely changed during that period of time that is causing your integration to send over duplicate charge requests. At least we have it narrowed down to the integration that is sending the duplicate charge requests and we have a period of time when there probably was some of a change that caused this to happen."

So do you think this is related to the time I deleted those test subscriptions I did on the site? I'm not sure what day I deleted those subscriptions, but it may have been around that period Stripe mentioned.

Let me know what you come up with please. The next charge will be on the 18th of June, so I really hope we solve the issue before then, as it'll be a duplicate charge as well.

Thanks!
·
Thursday, 31 May 2018 07:38
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Mohammad,

Thanks for updating us stripe team response.

I'll need more details from you on this, can you tell me what exactly you have deleletd, deleted invoice , transaction only or something else. Anything changed on your site during period as you said in april.
This is the only user facing double transaction issue and or any other user's also, if yes then share their subription id/userid also.

Also provide me site ftp details and allow me to install Mijosql extension , because i need to check databse entries also or you can provide me db access also.

Update me.
·
Thursday, 31 May 2018 11:52
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Manisha,

With all honesty, I do not remember what fake data I deleted, I'm sure I deleted a combination of old subscriptions, old invoices and/or old transactions. I am really not sure exactly what. I can assure you though that anything I deleted was from PayPlans, and not from DB. Maybe PayPlans should come with a BIG red warning saying "Do not delete any data at any time! ". No one can possibly know that deleting old records from PayPlans can cause an issue!

There are 2 clients facing this issue are:
- Subscription ID = 351(8O56WJCMAHT5) / user ID = 3206
- Subscription ID = 393(8O56WJCMAH4F) / user ID = 3278

The only thing I can say is that those 2 clients subscriptions were most likely started BEFORE I deleted old data. The 3rd client we have does not have an issue so far (Subscription ID = 410(8O56WJCMA60A) / user ID = 3273).

You can install Mijosql extension if you like. I gave your account access to install now. I also just gave you access to ftp on Skype, please check.

Thanks.
·
Thursday, 31 May 2018 16:26
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Mohammad,

I've installed Mijosql extension but unable to access this.

Error
You are not authorised to view this resource.


Please provide me access of this and also can you share server access log of the day when double payment charged.
Update me.
·
Thursday, 31 May 2018 19:16
·
0 Likes
·
0 Votes
·
0 Comments
·
Can you please try again? You should have access to this new extension you installed.

I'll look for the server access log for you.
·
Thursday, 31 May 2018 20:22
·
0 Likes
·
0 Votes
·
0 Comments
·
Since there are duplicate charges on the 18th, 27th/28th of May (as shown here http://prntscr.com/jp26ql ), I have sent you on Skype the access log for those 3 days only.

Let me know if you need anything else.

Thanks.
·
Thursday, 31 May 2018 22:06
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Manisha,

I have found the reason why. We had copied over the live site to development site near mid-April. Hence, those 2 subscriptions were also copied but we never cancelled them! We now have cancelled those 2 subscriptions on the development site, so that should stop any duplicate charges.

Which brings me to my next question, next time we do a copy, how do we make sure the payments are not happening on the dev site to the copied subscriptions? Do we just unpublish the payment method? Is that enough? If not, then if I cancel the subscription manually on the dev site, will it remove the same token on stripe? If yes, then that mean the live site is cancelled too!?

Let me know please as we are always copying the live site to different development boxes.

Sorry for the trouble we caused. At least this has been figured out

Thanks,
Mohammad
·
Friday, 01 June 2018 04:16
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Mohammad,

Thanks for updating on this, it sound good that you have figure out the issue .

Next time when you copy subscriptions from dev site to live site then disable payment method as well as disable cron job also , because in stripe recurring payment request made on cron execution. If you cancel the subscription manually on dev site then it will not remove the token , it just mark cancel recurring order on dev site only.

Let me know if you have any query.
·
Friday, 01 June 2018 10:46
·
0 Likes
·
0 Votes
·
0 Comments
·
This issue still seems to be happening for us. Because this hasn't been resolved we are losing more and more subscribers.

What else can we try doing to stop the duplicate stripe payments?
·
Monday, 06 August 2018 10:52
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Matt,

Let me know the subscription id's for which this issue is coming, so i can check this .
Also make sure it's not coming from your developer site.

Update me.
·
Monday, 06 August 2018 11:01
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Manisha,

I have attached the Id's which we have had to give refunds due to duplicate payments.
·
Monday, 06 August 2018 16:07
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Matt,

Please share me your server access and error logs of 2 days (yesterday and today).
I need to check the logs to rectify this issue.

Also let me know any entity deleted manually from backend or from database.
Update me with response.
·
Monday, 06 August 2018 17:48
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post