I am thinking potentially about an upgrade to the latest API version from Stripe. Currently, the integration is running on library v1.18.0 -- and the current library is v5.3.x.

CommentFileSizeAuthor
#111 0001-Stripe-billing-checkout-prefilling-and-billing-updat.patch3.27 KBMarcoPBazz
#104 0001-Stripe-Add-option-to-choose-to-store-saved-cards.patch6.87 KBMarcoPBazz
#102 5. information not passed to Stripe Checkout.JPG39.93 KBJane.L
#102 4. DB log after trying to pay with saved card.JPG69.24 KBJane.L
#102 3. error message after hitting PayNow button.JPG68.38 KBJane.L
#102 2. On MS_Stripe page, Pay button not leading to Checkout.JPG39.95 KBJane.L
#102 1. user offered option to Pay With Saved Card.JPG62.61 KBJane.L
#99 0001-Stripe-SCA-authentication-checkout-and-Stripe-module.patch29.61 KBMarcoPBazz
#97 ms_stripe.zip25.07 KBMarcoPBazz
#95 09-06_4 details of error log.JPG64.42 KBJane.L
#95 09-05 ajax confrim payment error.JPG76.63 KBJane.L
#93 09-06 MS_Stripe error log.JPG46.59 KBJane.L
#91 ms_stripe_new.module.zip6.84 KBMarcoPBazz
#90 09-05 product is correctly added but payment is not recorded in Payment.JPG29.56 KBJane.L
#90 09-05 Stripe Event log error.JPG48.74 KBJane.L
#88 ms_stripe_new.module.zip6.98 KBMarcoPBazz
#86 09-05 manually processed payment.JPG37.41 KBJane.L
#86 09-05 manually completed order.JPG22.22 KBJane.L
#86 09-05 dlog of failed payment.JPG44.32 KBJane.L
#86 09-04 success page - ajax.JPG31 KBJane.L
#84 ms_stripe_new.module.zip6.98 KBMarcoPBazz
#81 ms_stripe_old.zip4.97 KBJane.L
#80 ms_stripe_new.zip6.22 KBJane.L
#77 09-03 Stripe Event log of test payment.txt1018 bytesJane.L
#76 09-02 Order still in checkout.JPG41.81 KBJane.L
#73 08-30 Event log of test payment from my Stripe dashboard.txt1.56 KBJane.L
#68 ms_stripe (1).zip21.57 KBJane.L
#61 Stripe checkout button selected..JPG16.03 KBJane.L
#56 Stripe checkout client or server integration.JPG37.78 KBJane.L
#53 Schermata 2019-08-28 alle 11.23.45.png151.42 KBMarcoPBazz
#52 Drupal Stripe module settings.JPG41.56 KBJane.L
#44 ms_stripe.zip23.64 KBMarcoPBazz
#41 moneysuite.zip4.17 MBMarcoPBazz
#41 Schermata 2019-08-22 alle 15.54.16.png66.29 KBMarcoPBazz
#41 Schermata 2019-08-22 alle 15.53.06.png38.29 KBMarcoPBazz
#40 Stripe checkout - Old Checkout.JPG22.63 KBJane.L
#39 Stripe New Checkout.JPG55.57 KBJane.L
#31 0001-ms_stripe-SCA-missing-lines.patch933 bytesMarcoPBazz
#30 0001-ms_stripe-SCA.patch19.81 KBMarcoPBazz
#24 Stripe API screenshot.JPG29.53 KBJane.L
#21 Stripe Module Settings.JPG54.86 KBJane.L
#3 stripe-library-upgrade-2916933-3.patch8.21 KBvaccinemedia
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Shane Birley created an issue. See original summary.

Shane Birley’s picture

For documentation. The error that has recently appeared in my php error logs:

Stripe Notice: Undefined property of Stripe_Customer instance: cards

vaccinemedia’s picture

Status: Active » Needs review
FileSize
8.21 KB

Here's a patch which implements the library the same as does the stripe module. It uses hook_libraries_info() and libraries_load() to load the stripe library and the classes have been updated. This has been tested to work with the stripe library officially supported by the stripe module which is 3.9.0

I've also commented out 4 items in ms_stripe_payment_submit_form_validate() which are not present when using the Stripe checkout button. When not using the button i.e. using standard checkout form I received an email from Stripe saying that you should not send full credit card details through the website and that tokenisation should be used instead. The stripe button implementation by this module does just that. The items which are not present in the callback are the card details cc_type, cc_num, exp_month and exp_year

Shane Birley’s picture

I just saw this and will test it next week.

kebne’s picture

Tried this both with current version and dev. Got an error:
Error: Class 'Stripe\Stripe' not found i ms_stripe_payment_submit_form_validate() (row 366 av /www/sites/all/modules/moneysuite/ms_core/gateways/ms_stripe/ms_stripe.module).

vaccinemedia’s picture

Hopefully not a silly question @kebne but have you added the stripe library to your libraries folder and is it version 3.9.0? It has to be that precise version number.

kebne’s picture

Sorry I missed that step! But I got another error now:
Error: Call to undefined function stripe_libraries_postload_callback() i libraries_traverse_library() (row 196 av /www/sites/all/modules/libraries/libraries.module).

Tried both the library version 3.9.0 and the current 6.35.2

kebne’s picture

Tried to uninstall the patch and running with library version 1.18.0 - worked but only for the simple test without 3d secure technology. I assume that's because of the outdated library.

The errors I got:
Warning: Creating default object from empty value i ms_stripe_payment_submit_form_validate() (row 359 av /www/sites/all/modules/moneysuite/ms_core/gateways/ms_stripe/ms_stripe.module).

TypeError: Argument 1 passed to ms_core_enter_payment() must be an instance of MsPayment, instance of stdClass given, called in /www/sites/all/modules/moneysuite/ms_core/gateways/ms_stripe/ms_stripe.module on line 372 i ms_core_enter_payment() (row 4718 av /www/sites/all/modules/moneysuite/ms_core/ms_core.module).

MarcoPBazz’s picture

Hi,
i'm getting similar error of #7 with version 6.38.0

Error: Call to undefined function stripe_libraries_postload_callback() i libraries_traverse_library() (row 212 at /www/sites/all/modules/libraries/libraries.module).

Unless stripe module is installed, function stripe_libraries_postload_callback() must be declared somewhere in the module.

MarcoPBazz’s picture

Ok i've declared the function right after function ms_stripe_load_library() and now it's working.

Anyway there's a log to look out:

Notice: Use of undefined constant STRIPE_API_ACCOUNT_DEFAULT - assumed 'STRIPE_API_ACCOUNT_DEFAULT' in stripe_libraries_postload_callback() (line 76 di ...sites/all/modules/moneysuite/ms_core/gateways/ms_stripe/ms_stripe.module).

Referring to this line of code:

if ($api_version <> STRIPE_API_ACCOUNT_DEFAULT) {

I think maybe it depends by the library version...

MarcoPBazz’s picture

I find out STRIPE_API_ACCOUNT_DEFAULT is a constant declared at line 9 of stripe.module.

I think this solution must consider 2 option;

  1. Consider the Stripe module a dependency
  2. Integrate all the variable and the related functions
Jane.L’s picture

I just entered a new Stripe issue at
https://www.drupal.org/project/moneysuite/issues/3070001

which relates to Strong Customer Authentication (SCA) compliance starting Sept 2019.
I have been in touch with Stripe support and they say as long as we use the latest version of their Stripe Checkout then it is automatically compliant.
But the MoneySuite Stripe module is currently connecting to the legacy version of the Stripe Checkout . Please see my issue at https://www.drupal.org/project/moneysuite/issues/3070001
for more information on this.

Stripe support also told me that if we upgrade to latest Stripe Checkout, then Apple Pay will automatically be enable without further integration.

If you have upgraded your Stripe library (as detailed here in this issue) do you know if this also upgrades to newest version of Stripe Checkout?

MarcoPBazz’s picture

Hi jane,
to me it seem that Stripe Checkout remain the same even after upgrading to the latest version

Jane.L’s picture

Thank you Marco. I will apply the Stripe Library patch and then check it as well. Are you in the Eu or accepting payments in the EU? I checked with Stripe support if the library upgrade can also upgrade to latest version of checkout - they said it is a separate issue.

On upgrading the Stripe Library, Stripe support said:

"You can upgrade your API version in your dashboard under the developers tab. However, I would recommend having your developer make the upgrade for you. Something could possibly disconnect in your integration, and they may have to redo some setting up on their side. It wouldn't completely disconnect from your website, I just don't want you to get any surprise error messages."

My question is:
When you apply this Stripe Library Upgrade patch, do you have to upgrade the library in Stripe dashboard first? Or if not, what is the process? Thanks so much for any advice you can give me here!

MarcoPBazz’s picture

Yep, i'm in EU and I'm accepting payment from EU.

From Stripe dashboard you can change default API version, also you can rollback that settings change in 3 days after activation.

Another way is to declare the STRIPE_API_ACCOUNT_DEFAULT constant in ms_stripe.module and force the version, for example

define('STRIPE_API_ACCOUNT_DEFAULT', '2019-05-16');

If you apply the patch like I did, you have to change also a few lines in function stripe_libraries_postload_callback:

if ($api_version <> STRIPE_API_ACCOUNT_DEFAULT) {
      if ($api_version == STRIPE_API_VERSION_CUSTOM) {
       + $api_version = 'STRIPE_API_ACCOUNT_DEFAULT';
      }
Jane.L’s picture

Thanks Marco, I will apply the patch this week. Do you have a plan on how to address the issue I raised at

https://www.drupal.org/project/moneysuite/issues/3070001

to comply with the EU Strong Customer Authentication rules coming in on 14 September 2019? If we can get the MoneySuite Stripe module to connect with the latest version of Stripe checkout, the support team at Stripe say it should then be SCA compliant and will also add Apple pay function,which would increase conversion rates I expect.

Farreres’s picture

As soon as the patch reaches Reviewed & tested by the community I will update dev version.

Jane.L’s picture

Thank you Farreres, and also thanks for your work in updating these modules over the last few years.

Perhaps when the Stripe Library Upgrade is added into the dev version, it would make sense to add the new Checkout button into the dev version as well? This issue is at

https://www.drupal.org/project/moneysuite/issues/3070001

This is something that needs to be in place by September in order for the Stripe module to keep working for payments originating in the EU.

Is there anyone following this thread who can make the upgrade to the new Stripe checkout button please? I am happy to test, feedback and contribute but I'm not able to do the module upgrade.

Here is the Stripe link to the Checkout button upgrade:

https://stripe.com/docs/payments/checkout/migration#client-products

Jane.L’s picture

We have upgraded the Stripe Library by applying the patch. Payments are working fine.

The upgrade was from version 1.1.8 ( date 2014-01-31) to the latest version (date 2019-05-16)

Adjustments to MoneySuite Stripe as recommended in some comments above did not work for us, so we installed the Stripe module as recommended by MarcoPBazz in #11 above, who said

"I find out STRIPE_API_ACCOUNT_DEFAULT is a constant declared at line 9 of stripe.module.

I think this solution must consider 2 option;

1. Consider the Stripe module a dependency
2. Integrate all the variable and the related functions"

I think it's preferable that the Stripe module at

https://www.drupal.org/project/stripe

is a dependency as this will automatically upgrade to the latest library version when a new one is released.

Jane.L’s picture

FileSize
54.86 KB

To follow my comment at #20, here is a screenshot of which parts of the Stripe module we enabled. There seem to be no conflicts with MoneySuite

MarcoPBazz’s picture

I agree, Stripe module should be a dependency.

I'm trying to figure it out how migrate the checkout button, in particular i'm studing Woocommerce Stripe Payment gateway which has already introduced it

Jane.L’s picture

That's great news, Marco.

I just looked at the WooCommerce Stripe Payment gateway and the introduction says:
"Accept Visa, MasterCard, American Express, Discover, JCB, Diners Club, SEPA, Sofort, iDeal, Giropay, Alipay, and more directly on your store with the Stripe payment gateway for WooCommerce, including Apple Pay, Google Pay, and Microsoft Pay for mobile and desktop."

I think (hope) that the new Stripe checkout button might automatically enable all these extra payment options, as well as making the payments SCA compliant.

Please let me know if there is anything I can do or test. I am not a developer but would like to help in any other way, such as testing in a dev or live environment when that becomes available.

Jane.L’s picture

FileSize
29.53 KB

This is an update to my comment #20 above.

I have many recurring payment Membership Plans that were set up in MoneySuite Membership Suite. These payments are gong through without any problem since my Stripe library upgrade.

The reason I mention this is that in my Stripe Dashboard, on the Developers tab, it says:
"You may be using multiple API versions due to your client libraries or plugins." (see attached screenshot)

so I wondered whether my existing recurring payments might go through on the old Stripe API, and if so whether this would cause a problem.

But I'm pleased to say that all recurring payments set up on the old Stripe Library are going through successfully on the latest Stripe API.

Also regarding the separate issue I entered about SCA compliance, should I instead make this a child issue of this library upgrade issue? As this issue has more followers and we could then delete the other issue.

Jane.L’s picture

Hi Marco,
Just wanted to let you know that I have a test version of my live website so I am happy to test the changes that you make to the Stripe Checkout button on that test site if it is helpful. The test website runs the same MoneySuite modules as my live site.

I had another email from Stripe warning that we have to upgrade to the new version of Stripe Checkout by 14 September in order to avoid payments declines. I know you are working on it as you mentioned above, so please let me know if there is anything I can help with.

Shane Birley’s picture

Hi!

I am just catching up on this thread. I tested a while back but there was an issue where the library wasn't recognized. I will update my brain on this today and see what I may need to do.

@Jane L., what version of the Drupal Stripe module did you utilize?

Jane.L’s picture

Hi Shane

We used the latest version of the Drupal Stripe module, which is 7x-1.0-alpha1

Basically we followed the recommendations of MarcoPBazz in comment #15 above.
In my comments at #20 and #21 in this thread, you can see the steps we followed and also a screenshot of teh Stripe module settings as we have them now. The library upgrade is working perfectly.

This library upgrade still has not upgraded us to the latest version of Stripe Checkout, as the MoneySuite Stripe module is still using the legacy version of checkout. You can see the issues this causes both in this thread and in the issue at
https://www.drupal.org/project/moneysuite/issues/3070001

But anyway the library upgrade is a good start.

MarcoPBazz’s picture

Hi Jane,

thank you, i'm working on the patch, but still i'm far from a decent version, I hope to do it soon.

MarcoPBazz’s picture

@Shane I'm using Drupal Stripe 7x-1 dev version beacause you can set the API version from the settings page.

Here's the thread https://www.drupal.org/project/stripe/issues/2138577

MarcoPBazz’s picture

Here's my first patch: It's very rough and I have to clean up comments, but I think it's just a starting point.

Following Ubercart Stripe logic (https://www.drupal.org/project/uc_stripe/issues/3040854) and Commerce Stripe i've added an ajax page for catching the payment response and then register it via ms_stripe_confirm_payment (using the PaymentIntent::create method).

Please note that right now i've worked on single payment and not on recurrent.

MarcoPBazz’s picture

Ops! I've noticed that two lines are missing in ms_stripe_process_payment.js

Jane.L’s picture

Hi Marco,
thank you, we will test it and get back to you as soon as possible.

Jane.L’s picture

Hi Marco,

We have applied the patch on my test site.

I can pay using a test card on the Stripe check out, but when I click “pay with card” , and then enter the test Stripe checkout card number and click “pay“, it just takes me straight back to the stripe module on my site (the page where it says “pay with card”)

Is this the result you had? Just in case we applied the missing lines incorrectly, would you mind supplying the complete patch with the missing lines in place?

Also, I wonder whether the Stripe test checkout card number (4242 4242 4242 4242) works on testing the new stripe checkout. I will check this with their support team.

The reason I use the test card is that my test site is not secure and we can only use test mode on it.

Perhaps it might also be worth supplying the patch you have created to the stripe support team so they can check over it?

Jane.L’s picture

Hi Marco
I contacted Stripe support and it turns out they have a new set of test credit card numbers for testing the new SCA compliant payments. I have successfully made payments using the top 2 cards on this list

https://stripe.com/docs/payments/payment-intents/quickstart#testing

The membership plans are successfully created in Membership Suite as well.
The only thing is they did not require authentication (which is the whole point of the SCA thing)
I will contact Stripe again about this.

But just wanted you to know now that the payments did work.
Is this patch using the new version of Stripe Checkout?

Jane.L’s picture

To follow my comment #34 above, I contacted Stripe support again about why their test card did not require authentication. They said it should have required this, so they have referred this to their specialists and will get back to me. I have given them the URL of my test site subscription page and they are going to do a test subscription. So maybe that will be helpful! I'll get back to you ass soon as I hear from them.

MarcoPBazz’s picture

Hi Jane, many thanks :)
in order:
#33 When I tested my patch it worked as usual, after payment I was redirected to the order complete page. I will resubmit the patch as soon as possibile. I used the first CC number on the list that you posted (https://stripe.com/docs/payments/payment-intents/quickstart#testing)
#34 As I said I didn't worked on membership payments, so actualy this kind of payments is working with the old process. For what concern the checkout version I migrated all the library call like UC Stripe did so technically if I've done it correctly it should be the latest version.
#35 Ok, I was missing this point, so let's see what Stripe will tell us

Jane.L’s picture

Hi Marco,
When you say in #36 that you didn't work on membership payments, are you referring to your comment in #30 where you say
"Please note that right now I've worked on single payment and not on recurrent."?

The reason I ask is that the payments I made were single payments, not for recurring schedule. I was using the Membership Suite but I only paid for a non recurring Membership Plan.

But just to check, I also just paid on my test site for some items built on the Pay Per View module of MoneySuite, and had the same result as yesterday.

I'm wondering whether the new Stripe checkout is being used in your patch as it looks exactly the same as the old one. We need to be using the new version of Checkout in order to be SCA compliant, because that is the one that asks the customer for authentication for a payment.

Yesterday I was trying to understand if Payment Intents and Stripe Checkout both had to be used together or whether it was either/or.

I had this from Stripe support:

Me:
But I just want to know whether the new Stripe Checkout can be used AS WELL AS the Payment Intents or whether it is an EITHER/OR thing

Stripe support:
You would setup Stripe Checkout and you would then process payment intent payments. If you take a look at the top of this page it explains that you couldn't use payment intents without Stripe Checkout:
https://stripe.com/docs/payments/checkout

I have not heard back yet from Stripe support (see #35) but will chase it up now.

Jane.L’s picture

HI again Marco,
I guess you have seen these but just in case , here are the links from Stripe about how the old checkout migrates to the new one:

A link on the new Checkout from our Docs here:
https://stripe.com/docs/payments/checkout

A link about migrating to the new version of checkout:
https://stripe.com/docs/payments/checkout/migration#client-products

Jane.L’s picture

FileSize
55.57 KB

Hi Marco,
I contacted Stripe with a screenshot of the Checkout that is displaying on my test site after applying the patch. They said it is the old checkout.

So that will be why the SCA card is not asking for authentication - we are still using the old version of Stripe Checkout that is not SCA compliant. So there is no point yet in Stripe support doing a test payment on my test site.

Here are 2 screenshots - you can see the difference in how the new checkout will look.
When you do a test payment, do you see the old or new one?

It could be that the Ubercart patch you adapted uses the new version of Stripe checkout but that there is some conflict that forces the Old checkout to display when we use MoneySuite. Or it could be that something on my test site is forcing it.

Jane.L’s picture

sorry the screenshot of old checkout did not upload - here it is

MarcoPBazz’s picture

I find out that the problem was the ms_stripe_checkout.js file which was using the old syntax.

I've rewrite it including the session_id parameter now it's calling the new checkout form (see first screenshot).

Anyway there's a problem: Stripe process payment correcty, but Moneysuite doesn't update the order (see second screenshot), so

  • In Stripe dashboard I see the payment
  • In MS the has pending status

@Jane here's the zip version of my latest version

Jane.L’s picture

Hi Marco, thank you.
We will apply your latest version and test it.
I see in the zip file that you have a complete version of MoneySuite with all its modules.
Do you recommend that I overwrite all the MS modules on my test site with this version? That's fine if it's what you recommend.

MarcoPBazz’s picture

i've just worked on the ms_stripe submodule, so you can just overwrite that folder

MarcoPBazz’s picture

FileSize
23.64 KB

Sorry, I've noticed an error in ms_stripe.module: success_url and cancel_url must be change using $base_path variable since an absolute path is required.

Here's the update version, this time i've just zipped the stripe submodule and I've also removed some custom debug functions

Jane.L’s picture

Thank you Marco.
We will apply the new version.
We had some problems with the one you sent and i was just waiting to test some more before contacting you.

Could you please let me know if you have all the options enabled in the Drupal Stripe module? There are 3 options
Stripe
Stripe Customers
Stripe Payment methods

Are they all enabled?

MarcoPBazz’s picture

Hi Jane,
actually I've enabled only the Stripe module and the Stripe Customers

Jane.L’s picture

Hi Marco, We applied your new version of the MS Stripe submodule.

However, before doing that. (and before reading your reply at #46) I had enabled the third option in the Drupal Stripe module.
This third option is "Stripe Payment Methods." (see my screenshot at #21)

This seems to have broken our database so we are having to rebuild the test site.

The reason I enabled "Stripe Payment Methods." was that after we applied your module version at #41 in this thread, the option to 'pay with card' disappeared from my Checkout page. It was as if the Stripe module was not there, even though it was installed. So the only payment option showing was PayPal (as I use that one too)

But enabling "Stripe Payment Methods." in the Drupal Stripe module broke my test site!

We will apply and test your new version of the MS Stripe sub module again when my test site is ready

Can I just check which versions of Drupal and MoneySuite you are running? We are running MoneySuite 7 x 10.4 and Drupal 7.67

MarcoPBazz’s picture

Very strange, was the gateway alse disabled in ms UI?

Anyway I'm using Drupal 7.67 and the MoneySuite 7.x-10.x-dev version

Jane.L’s picture

Hi Marco, sorry for the late reply. We had a 3 day holiday in the UK.
We are updating the php on the demo server and will test again tomorrow. I will then update you.
But we will be testing on MoneySuite 7 x 10.4 rather than MoneySuite 7.x-10.x-dev as we use MoneySuite 7 x 10.4 on our live site that accepts ecommerce payments.

Jane.L’s picture

Hi Marco,

we have upgraded our test site to PHP 5.5 and added your new stripe sub module. Unfortunately, when we click pay in the checkout page, we just got the message
“The website encountered an unexpected error”

We could update to the same version of moneysuite that you are using, but first could you please let me know what happens when you go through a test payment? Is it successful using the test card numbers?

Also, Perhaps as we are adding your module which was created in the later version of MoneySuite 10x4xdev , it is conflicting with our module

MarcoPBazz’s picture

Hi Jane,

haven't you a log module activated? Even database log should check out the source of the error.

What PHP version are you using? I'm using the 7.1 version.

As I said, when I go through test payment it redirect me to the successfull page (ms/thankyou) without saving the payment in Moneysuite

Jane.L’s picture

Hi Marco,

thank you for letting me know your php version 7.1. We are updating the test site again to that version as ours was on php 5.5

We've also updated MoneySuite to the latest dev version, which for some reason is displaying in my module list as MoneySuite 7.x-10.4+4-dev rather than as MoneySuite 7.x-10.x-dev

Once the updates are complete, I will test again and supply any error log messages.

But I have another question:

In your Drupal Stripe module settings at
/admin/config/stripe/settings

what settings do you have for the Drupal Stripe module?

At the moment, on both my live and test sites, we have the Drupal Stripe module set at
Test rather than at Live
Please see the attached screenshot for all my Drupal Stripe module settings>

The setting are the same on my live site, and it is successfully taking Stripe payments.
The Stripe API keys are entered in MoneySuite Stripe gateway at
/admin/moneysuite/gateways/ms_stripe

But do you also have them enabled in the Drupal Stripe module settings at
/admin/config/stripe/settings

I just want to make sure we have exactly the same set up

MarcoPBazz’s picture

Hi Jane,

here's my settings, just look at the screenshot.

Jane.L’s picture

Thanks Marco.
Very different from our settings. That could be causing the issue.

Jane.L’s picture

Hi Marco,

I have changed the Drupal Stripe Module settings to match yours. I no longer get the 'site in unexpected error' problem. so Now I can move on to the third stage of checkout, using the MoneySuite Stripe Module.

However this is creating error logs. I will supply the error logs shortly, with all arrays expanded.

The issue now is that when I click the Stripe payment button "pay with card", which is supposed to open Stripe Checkout, nothing works, as if the hyperlink in he button it is broken. I have enabled the test mode in my Stripe dashboard, as instructed by Stripe support team.

I have a question about your Stripe dashboard settings at https://dashboard.stripe.com/account/checkout/settings

Have you developed the new SCA compliant Stripe submodule using Stripe Client side integration or Stripe server side integration? Please see my screenshot. I currently do not have Client side integration enabled, but in a chat just now with Stripe support, they said I may need to have it enabled but to check with the plugin developer (i.e.you!)

My concern would be that I might then not be able to take payments in my live site, but I guess I could enable it temporarily if needed.

by the way,
We have not yet upgraded the site to PHP 7.1, so it is still on PHP 5.5, but now that we are not receiving the “Site in unexpected error“ issue, it could be that the PHP version is not what is causing the problem.

Jane.L’s picture

sorry here is my screenshot

Jane.L’s picture

Hi Marco, here is a link to one of my error logs.

This error log is on the MS Stripe module page (with the blue Stripe'Pay" button on it), and this error log appears before I press the blue "Pay" button

https://docs.google.com/document/d/1yad_AZrxQ8s6ws0Ccc7RfuTwk4JHKOrdFbkl...

I will send other error logs if you want me to - please let me know if so. But it would be good to know whether to enable Stripe Checkout client side integration (see comment #55) before expanding and copying the other error logs.

MarcoPBazz’s picture

I think it's a Javascript error.

Try this, edit ms_stripe.module at line 370 and 371 and change this two parameters:

'success_url' => '
'cancel_url' => '

And insert the absolute url of your site, for example

'success_url' => 'https://YOURSITE/ms/thankyou',
'cancel_url' => 'https://YOURSITE/ms/cancel',
Jane.L’s picture

Thanks Marco, we will try that.

Also, as per#55 above, are you using the Client Side Integration or the Server Side Integration for the new Stripe Checkout?

According to Stripe support, this could also cause the Pay button to fail if Client Side Integration is disabled on Stripe dashboard but used in the MoneySuite Stripe module.

MarcoPBazz’s picture

Sorry I didn't saw your previous comment.

Edit ms_stripe.module at line 391

- 'order_id' => $order->id,'method_id',
+'order_id' => $order->oid,

I'm using Client Side Integration

Jane.L’s picture

OK thank you - that's important!
I have now enabled Client side integration in the Stripe dashboard. I tested my live site payments and they are still working fine for MoneySuite Membership plans.

But There is no change in the test site - the Pay button still does not work - so we will make the edits you suggest.

Marco, also could I please check if you are using the Checkout Button option at
/admin/moneysuite/gateways/ms_stripe

The 2 options are:
Checkout form
Checkout button

(see screenshot)

The reason I ask is that the error log I gave at #57 refers many time to submitting a form.
But I think for the new SCA compliant checkout, we probably have to use the Checkout button option

MarcoPBazz’s picture

I'm using Checkout button

Also apply #58 edit to line 309 and 310

Jane.L’s picture

Thank you.
The edits to teh MS Stripe module will be tomorrow morning now as the person who will make the edits is in a different time zone and has finished work for the day. I'll update you as soon as I can tomorrow when we have made the edits.

Shane Birley’s picture

Just checking in on this thread. A huge shout out to you both for tackling this one.

Jane.L’s picture

Hi Marco,

We have upgraded the php to 7.1 and added all your edits to the MS_stripe module. We are still getting some errors but not exactly the same as before. I have numbered the issues here:

1. When I click the Stripe Pay button, nothing happens, as before. But when I click it i get errors both on the site logs and on the browser developer console. Here is the JS log from Chrome console inspector:

https://docs.google.com/document/d/1QjYQm2zbgN99xw-qhOj1Wi0ZVcHLosE8wbYA...

I have marked the error in red.
it looks as if it is not loading my public Stripe key for some reason. Can you think why this could be? I am also going to contact Stripe support about this now.

2. Here are the error logs that appear on my site when I click the Stripe Pay button on the MS_Stripe page:

MS_Stripe yesterday's error
https://docs.google.com/document/d/1yad_AZrxQ8s6ws0Ccc7RfuTwk4JHKOrdFbkl...

MS_Stripe Today's error
https://docs.google.com/document/d/1uIQcuxkCGp-fKRlxskNXyLDOnPKo6QT-Zr7T...

I ran them through a diff checker so you can see the result here

https://www.diffchecker.com/WQJLzNqI

(Please note some differences are in my test site URL as we upgraded to php 7.1 so as to be on exactly the same platform as you.)

3. The new version of MoneySuite we loaded on the test site displaying in the module list as:

7.x-10.4+4-dev

whereas the version you are using is
7.x10.x-dev

What has appeared on my test site seems to be a combination of the live version (7.x-10.4) and the dev version (7.x10.x-dev), as the version 7.x-10.4+4-dev does not appear on the MoneySuite module page.

Could this possibly be an issue? I think may be the exact same version might need to be installed?

Jane.L’s picture

Hi Marco,

We have upgraded the php to 7.1 and added all your edits to the MS_stripe module. We are still getting some errors but not exactly the same as before. I have numbered the issues here so as to be less confusing!

1. When I click the Stripe Pay button, nothing happens, as before. But when I click it i get errors both on the site logs and on the browser developer console Here is the JS log from Chrome console inspector:

https://docs.google.com/document/d/1QjYQm2zbgN99xw-qhOj1Wi0ZVcHLosE8wbYA...

it looks as if it is not loading my public Stripe key for some reason. Can you think why this could be? I am also going to contact Stripe support about this now.

2. Here are the error logs that appear on my site when I click the Stripe Pay button on the MS_Stripe page:

MS_Stripe yesterday's error
https://docs.google.com/document/d/1yad_AZrxQ8s6ws0Ccc7RfuTwk4JHKOrdFbkl...

MS_Stripe Today's error
https://docs.google.com/document/d/1uIQcuxkCGp-fKRlxskNXyLDOnPKo6QT-Zr7T...

I ran them through a diff checker so you can see the result here

https://www.diffchecker.com/WQJLzNqI

(Please note some differences are in my test site URL as we upgraded to php 7.1 so as to be on exactly the same platform as you.)

3. The new version of MoneySuite we loaded on the test site displaying in the module list as:

7.x-10.4+4-dev

whereas the version you are using is
7.x10.x-dev

What has appeared on my test site seems to be a combination of the live version (7.x-10.4) and the dev version (7.x10.x-dev), as the version 7.x-10.4+4-dev does not appear on the MoneySuite module page.

Could this possbibly be an issue? I think may be the exact same version might need to be installed?

MarcoPBazz’s picture

Hi Jane,
no, I don't think they're related.

Stripe public key is passed to js via ms_stripe.module at line 393 (if your are using checkout button, 324 if checkout form instead).

$form['#attached']['js'][] = array(
      'data' => array('stripe' => array(
        'publicKey' => variable_get('ms_stripe_public_key', ''),
        'orderTitle' => $order->title,
        'orderDescription' => '',
        'orderEmail' => $order->email_address,
        'orderTotal' => ms_stripe_convert_amount($amount, $order->currency),
        'orderCurrency' => strtolower($order->currency),
        'order_id' => $order->id,
        'method_id' => 'credit',
        'sessionId' => $stripeSession[0]['id']
       )),
      'type' => 'setting'
    );

First of all you should check if there's empty spaces or wrong chars in your Stripe settings (admin/moneysuite/gateways/ms_stripe), if not please let me know how your code looks right now.

Jane.L’s picture

FileSize
21.57 KB

Hi Marco,

I have been in touch with Stripe Support. They pointed out to me that my test payment was trying to use my Stripe Live Keys.

I then realised that although I had the test keys correctly entered, and Test Mode enabled, in the Drupal Stripe module, I still had the Stripe Live keys entered in my MS stripe module.

The effect of this was that when I pressed the Pay button, even though nothing happened visibly (i.e. Stripe Checkout did not open and i was not required to enter card details) the payments were registering in my Stripe dashboard.

After Stripe Support pointed out this issue, I changed my MoneySuite Stripe settings so that my Stripe Test keys were entered there.

The effect of this is that the payment is not recorded at all.

Also, Stripe Support said that for the new Stripe Checkout, Test mode in Stripe dashboard is not really relevant. This is their exact wording (from my Stripe Support chat today):

Beth H.: The Stripe dashboard is not tied to the Checkout button itself.
Jane L: Oh I see. But i have to toggle test mode in order to do test payments, right?
Beth H.: When creating them through the dashboard, yes. With Checkout no, it goes off the test keys to make test payments to send to your Stripe dashboard.

To see what would happen, I entered my Stripe Live keys in both the Drupal Stripe module and the MoneySuite Stripe module on my test site. I then did another test payment, and the test payment is correctly recorded under Events in the Developers tab of my Stripe dashboard.

But it is just creating the payment record without any card details being entered. The Stripe Checkout its self is not opening at all. So I just click “pay”, nothing happens apparently on the website, the payment is recorded without any card details and without seeing the checkout button.

When I inspect the console for this, I see this error message

Uncaught reference error: Stripe is not defined (see screenshot)

There is a thread about this error here
https://stackoverflow.com/questions/43172843/uncaught-referenceerror-str...

When I expand this error in my browser console, this is the script that displays:

**
* @file
* Javascript for the Checkout method.
*/

(function ($) {
Drupal.behaviors.stripe = {
attach: function (context, settings) {
if (settings.stripe.fetched == null) {
settings.stripe.fetched = true;

// var handler = StripeCheckout.configure({
// key: settings.stripe.publicKey,
// token: function(token, args) {
// Use the token to create the charge with a server-side script.
// jQuery(".ms_stripe_token_field").val(token.id);
// jQuery("#ms-stripe-payment-submit-form").submit();
// }
// });

document.getElementById('ms_stripe_payment_button').addEventListener('click', function(e) {
// Open Checkout with further options
var stripe = Stripe(settings.stripe.publicKey);
var methodId = settings.stripe.method_id;
var orderId = settings.stripe.order_id;
stripe.redirectToCheckout({
sessionId: settings.stripe.sessionId,
}).then(function (result) {
// If `redirectToCheckout` fails due to a browser or network
// error, display the localized error message to your customer
// using `result.error.message`.
window.location.reload(true);
result.error.message
});
$.ajax({
url: '/ms/ajax/confirm_payment',
type: "POST",
data: JSON.stringify({ payment_method_id: methodId, order_id: orderId }),
contentType: 'application/json;',
dataType: 'json'
})
e.preventDefault();
});
}
else {
window.location.reload(true);
}
}
}
})(jQuery);

I am also attaching the MS_Stripe module here as we now have it - we added your edits but I wanted to send it to you to check it.
Stripe support have said they will inspect it for us, but I am not sure which part to send them and when I tried to send it all, it was classed as a risky attachment. Please send me any code you would like me to ask them to inspect (if you prefer me to do it)

Jane.L’s picture

Hi marco, we pressed send at teh same time!

I attached my current MS Stripe module to my comment just now, so would you mind taking a look at the code as it is now please?

MarcoPBazz’s picture

Hi Jane,
I looked at the module and I didn't see notable difference with my code.
What kind of product are you using for your test? membership or ms_products?

Jane.L’s picture

Hi Marco,

Thank you for checking the code. I'll number my points so you can answer them more easily

1. I am testing with MS_Membership and MS_pay-per-view as these are the only MS modules I am using for my site.

2. If you send me the relevant code I can ask Stripe support to check it, as they have said they are happy to do so. They may come up with an idea.

3. Also, we are now on same PHP and MS version as you are. Are there any other site or server settings that you think may be relevant? It's odd that we are getting different results.

4. As the payments can be recorded as Events in my Stripe Developer dashboard (although no Stripe Checkout appears when I click Pay), and as these payments are recorded as Payment Intents (i.e the new system), I think we must be not far from finding the problem.
I can see that the payments on my live site are being recorded in Events at https://dashboard.stripe.com/events as "charge" and the test site payments as "payment intents". (see below) This is good as the new Stripe Checkout needs payment intents.

Live site payment today:
Event data
{
"object": {
"id": "ch_1FxxxxxxxxxxxxxxxxXq",
"object": "charge",

Test site payment today:

Event data
{
"object": {
"id": "pi_1FDxxxxxxxxxxxxxxxxxME",
"object": "payment_intent",

Please let me know if you would like me to send you the full logs from my Stripe Events .

5. You mentioned yesterday that you thought it might be a JavaScript problem. We changed the code as you advised but it did not solve the issue.

Did you have a chance to read this thread?

https://stackoverflow.com/questions/43172843/uncaught-referenceerror-str...

This sounds to me a bit like our issue:
Question: Every time I load the page I get this error in the console Uncaught ReferenceError: Stripe is not defined - STRIPE ERROR. I think it has something the to do with the way I'm loading stripe.js but I'm not sure?

Answer: I suspect what's happening is that Stripe.js is loading AFTER your own javascript. Try moving Stripe.js above your own javascript in the header.

Marco - so do you think this is something that might need to change in the module, or on my site?

MarcoPBazz’s picture

1 - Ok, same as me
2 -I think first of all they should take a look at the entire ms_stripe_checkout which is the checkout generator and is supposed to confirm the order after payment success.
3 - Are you using some javascript aggregation modules look Advanced aggregation, Speedy, minify ecc....? Maybe it depends on where and when the scripts are loaded. Also, what kind of Jquery version are you using?
4 - It would be helpfull to have more details on those logs. In test mode I have

Event data
{
"object": {
"id": "ch_xxxxxxxxxxxxxxxxx",
"object": "charge",

and payments results complete

5 - Actually the Checkout button is calling only 2 scripts

  • external script checkout.js
  • Internal ms_stripe_checkout.js

stripe.js and ms_stripe.js are called for the Checkout form (see line 289 of ms_stripe.module).

in my case is working regulary, but just as I said on 3 in your case it could depends by some other configuration.

You can try to declare https://js.stripe.com/v3 for the Checkout button declaring it after line 289 and before checkout.js script

Jane.L’s picture

Hi Marco

1. Ok that's good

2. I have sent Stripe support the entire ms_stripe_checkout and they will inspect it.

3. We are not using any of those, but I have asked our developer to remove all additional javascript from the pages on our test site in case it is causing any conflict. He is is in a different time zone so away now until Monday.

4. I notice your Event log shows:
Event data
{
"object": {
"id": "ch_xxxxxxxxxxxxxxxxx",
"object": "charge",

Whereas mine shows

Event data
{
"object": {
"id": "pi_1FDxxxxxxxxxxxxxxxxxME",
"object": "payment_intent",

I think Payment intents needs to be used for SCA compliant payments. This was part of my conversation with Stripe support a few days ago:
"After taking a look at your test mode logs, I can see that you’re creating Payment Intents which is good because that’s a large part of how SCA is collected. "

Marco i think maybe it's a good idea if you liaise directly with Stripe Support. Your site is working better than mine with the new process, so you may find that you can solve the issue if they can inspect your Event logs and Browser developer console. They are so helpful on chat and email. You can reach them here https://support.stripe.com/contact

I am going to continue to liaise with them as well but as we don't know if there is some issue causing an additional conflict on my site, then it's better if we both deal with them I think.

5. I will ask our developer to declare https://js.stripe.com/v3 for the Checkout button declaring it after line 289 and before checkout.js script.

Marco thanks for your hard work and have a great weekend! :)

Jane.L’s picture

Hi Marco

We are still working on some changes (now removing all addition jquery from the page as your other suggestions did not fix it)

But for now i just have a quick question:

Have you set up webhooks in your Stripe dashboard at

https://dashboard.stripe.com/webhooks (live)
https://dashboard.stripe.com/test/webhooks (test)

I do not have any set up, as my MS module have never needed them. But maybe this could be a difference in the way you and I have things set up?

This page covers setting them up
https://stripe.com/docs/webhooks/setup

Please let me know if you have set them up and if so, what your endpoints are. I will then do the same.

MarcoPBazz’s picture

Hi Jane,

no I didn't set any webhook.

PS: i'm contacting Stripe support, I will let you know as soon as I can

Jane.L’s picture

Hi Marco,
Some good news! I can now use the new Stripe Checkout to do test payments. The SCA works and so does Apple Pay.

But the payment is not being recorded in MoneySuite Payments, and therefore the Membership is not being created.

These are the logs for the test payment in my dblogs

1. Notice: Trying to get property of non-object in ms_stripe_confirm_payment() (line 763 of /home/dailystepdemo/public_html/sites/all/modules/moneysuite/ms_core/gateways/ms_stripe/ms_stripe.module).

then

2. Error: Class 'Stripe\PaymentIntent' not found in ms_stripe_confirm_payment() (line 774 of /home/dailystepdemo/public_html/sites/all/modules/moneysuite/ms_core/gateways/ms_stripe/ms_stripe.module).

Also the Thank you page show the order as still in Checkout (see screenshot)
I think this is the same issue you are having?

I will send you our MS_Stripe module as it is now.

Anyway we are getting there! :)

Jane.L’s picture

Also, here is my Stripe Event log of that test payment.
It is being put as a modification rather than a new order
(see screenshot)

MarcoPBazz’s picture

Hi Jane,
ok finally we're at the same point :)

The new checkout is not sending to MS the payment result, so we must make them communicate.

I though about webhooks and maybe that could be the solution: https://stripe.com/docs/payments/checkout/fulfillment#webhooks

If we instruct ms/ajax/confirm_payment page to intercept the webhooks call for checkout.session.completed we can record the order and then redirect to MS thank you page.

I tryed something similar yesterday but the page is not getting the Json response, but from Stripe dashboard I see that the call is getting 200 code.

Here's my code (ms_stripe.module):

function ms_stripe_menu(){
  $items = array();

  $items['ms/ajax/confirm_payment'] = array(
    'access callback' => true,
    'page callback' => 'ms_stripe_confirm_payment',
    'delivery callback' => 'drupal_json_encode',
  );

  return $items;

}

Then

  ms_stripe_load_library();
  \Stripe\Stripe::setApiKey(variable_get('ms_stripe_secret_key', ''));

  // You can find your endpoint's secret in your webhook settings
  $endpoint_secret = 'Stripe webhook key'; //Maybe we can add it via ms_stripe settings

  $payload = file_get_contents('php://input');
  $sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];
  $event = null;

  try {
    $event = \Stripe\Webhook::constructEvent(
      $payload, $sig_header, $endpoint_secret
    );

The problem is that $payload variable is empty, is not getting any data...

MarcoPBazz’s picture

2. Error: Class 'Stripe\PaymentIntent' not found in ms_stripe_confirm_payment() (line 774 of /home/dailystepdemo/public_html/sites/all/modules/moneysuite/ms_core/gateways/ms_stripe/ms_stripe.module).

So in your case MS is reading correctly the generated json and is processing the order, but it seems that the Stripe library is not loading at that moment.

Can you send me your MS_Stripe module? I think it may depends by my dev area configuration but I want to see if your developer has applyed some other changes.

Jane.L’s picture

FileSize
6.22 KB

Hi Marco,

1. This was the comment of our developer yesterday, after the changes he made where i was finally able to load the new Stripe Checkout.

"I have updated the "success_url" and "cancel_url" as static in code file but they should fetch the base url.
'success_url' => 'http://dxxxxxxxxxxxxxxs.in/en/ms/thankyou',
'cancel_url' => 'http://dxxxxxxxxxxxxxxxs.in/en/ms/cancel',

Also I have attached the js "https://js.stripe.com/v3" in the checkout button form condition."

2. I asked Stripe Support if webhooks were necessary for the correct functioning of the new checkout and they said no, it just depends how our plug in works.

3. There are 2 attachments here, my MS_Stripe module as it is now and also the old version.

Jane.L’s picture

FileSize
4.97 KB
Jane.L’s picture

sorry they uploaded into different comments - please start at #80 above

Jane.L’s picture

Hi Marco,

to follow my comments starting at #80 above, I ran a diff checker on the old version of MS_Stripe and our new version of MS_Stripe. Here is a link to that

https://www.diffchecker.com/rTogmFUK

There are a lot of differences! Maybe Stripe support might be able to pinpoint the problem. I'll wait to hear from you on that as you might be able to spot something important in the code.

MarcoPBazz’s picture

FileSize
6.98 KB

Hi Jane,
so let's recap:

  1. New Checkout OK
  2. Stripe payments OK
  3. Money Suite order/payments NO

Usually MS save payments on ms_stripe_payment_submit_form_validate(), but somehow the new version is ignoring this function leaving the order in hiatus.

I made some adjustments to your versio: I've edited only the ms_stripe_confirm_payment function fixing your last 2 error log and adding ms_stripe_do_customer_payment and ms_core_enter_payment, so now if all parameters are ok it should update the order and close it regulary.

Let me know about it

Jane.L’s picture

Thank you Marco,

That sounds positive! We will apply this new MS_Stripe module and get back to you.

Jane.L’s picture

Hi Marco,

We added the new module and got these results:

1. There was an error message on the MS_Stripe page before I clicked the Pay button

The error was:

Notice: Undefined property: MsOrder::$id in ms_stripe_payment_submit_form() (line 394 of /home/dailystepdemo/public_html/sites/all/modules/moneysuite/ms_core/gateways/ms_stripe/ms_stripe.module). =>

and its expanded arrays are at this link

https://docs.google.com/document/d/1BLgdazC1VKAr1y3hvnVEyYqoCiSzcWMIzXv0...

2. I then clicked Pay, the new Stripe Checkout opened and I successfully paid.

But then I was taken to a blank page (see screenshot) at

/ms/ajax/confirm_payment

rather than

/ms/thankyou

so it did not take me to the correct Success URL

When I clicked "View source" on the /ms/ajax/confirm_payment, it was completely blank.

3. Here is the Stripe Event log of that payment

https://docs.google.com/document/d/1hAPRusWL4vDMpfpqjAfxte4fIGA0Kd-w9u_T...

4. The order was still showing as 'in checkout' in my MS Payments page.

But I was able to manually adjust and complete the order, so that the membership was correctly created. To do this I clicked on the user, then opened Order History, then Edit Order.

There was nothing showing under Payment so I clicked it and manually added a payment, I had to add the amount as this field was blank, then clicked 'Process Payment as if it was live'

(see screenshots)

The user then has the correct membership plan in place and the order is no longer in checkout.

Obviously this has to happen automatically rather than manually but I thought it might be useful to let you know that it's possible to complete the order like that.

Marco how does this new version of the module perform for you? If it is correctly completing the order in the MS Payments then perhaps these errors are to do with configuration on my site. Please let me know.

Jane.L’s picture

also to follow my comment above, here is a diff checker on the versions of the module from 03 September compared to the latest version

https://www.diffchecker.com/s324swNj

You can see at line 370 that the success URL has changed to
/ms/ajax/confirm_payment'

and there are other changes too if you scroll to the bottom.

MarcoPBazz’s picture

FileSize
6.98 KB

Hi Jane,

Notice: Undefined property: MsOrder::$id in ms_stripe_payment_submit_form() (line 394 of /home/dailystepdemo/public_html/sites/all/modules/moneysuite/ms_core/gateways/ms_stripe/ms_stripe.module). =>

The property declared was wrong (it's $order->oid) and I think this was the main problem because without the order oid the function can't load and update it.

Yes I changed the success URL because my goal is to use an ajax call to pass the arguments from session, update the order and then redirect to the thank you page, but as you said the redirect isn't working.

Here's another patch, I've corrected line 394 and improved the ms_stripe_confirm_payment, let's see if it works now, later i'll explain my test (sorry busy day :) )

Jane.L’s picture

Thank you Marco, we will test it and let you know. Hope your day goes well :)

Jane.L’s picture

Hi Marco

We applied the patch. Now we seem to get the same issue as before. So Order is showing as In Checkout on the MS Orders page.

I notice that now in my Stripe Test Events log at https://dashboard.stripe.com/test/logs , there is an error ( see screenshot attached), whereas there was not one before.

if I expand this error, this is the code:

Request POST body
{
"payment_method": "credit",
"description": "Order Number: 12280",
"amount": "7400",
"currency": "gbp",
"confirmation_method": "automatic",
"confirm": "true",
"setup_future_usage": "off_session",
"save_payment_method": "true"
}
Response body
{
"error": {
"code": "resource_missing",
"doc_url": "https://stripe.com/docs/error-codes/resource-missing",
"message": "No such payment_method: credit",
"param": "payment_method",
"type": "invalid_request_error"
}
}

So I think the missing resource is the problem.

I contacted Stripe Support about this. Here is a record of some of our chat:

Me:
Hello, when I pay with a test payment on the new Stripe checkout I get this error

Response body { "error": { "code": "resource_missing", "doc_url": "https://stripe.com/docs/error-codes/resource-missing", "message": "No such payment_method: credit", "param": "payment_method", "type": "invalid_request_error" } }

and even though the payment shows as successful in my Stripe Event, It does not update my site that a payment has been received

Stripe Support (after examining my Stripe Event logs):
I'm not seeing a payment method on the Log so that is the correct response from our API. I didn't think to check it but the line with card number or customer token to charge isn't there. No payment method.

Me:
Thank you. I am using a test payment card supplied by Stripe for testing the SCA compliant checkout. Could that be an issue? The card number is not supplied until we reach Stripe Checkout.
The order is correctly passed (I think) because the amount and product name appears in Checkout
So if is the card number/token to charge that's missing, is that a Checkout error? Or how can we change things to fix it?

Stripe Support:
It could be, I'm having a team member check if that got lost somewhere but the payment method should be listed there, because it did go through in the end. The log is having that error because it never loaded the payment method in the call (or the call didn't have the field for it)

There are two theories as to why this is having an issue - both are that the Payment Method Argument says the wrong thing. it should be either card or card_present. If those don't work then it should be the ID of the payment method I believe. You may need both, but we're testing that on our dashboard now.

Me:
I just tested Apple pay and had the same problem. It allowed me to do a test payment but the error logs are in Stripe Event logs and the order does not update as completed on my website

Stripe Support:
If you'd like I could move this to email and ask my team who works with SCA and the new checkout more specifically to see if they have some insight into this that we could use. This is very odd and I'd like to ask their opinions on what's going on since this is certainly odd.

So Marco I will let you know the response when it comes. I have sent them our latest MS-Stripe module code as well to see if they can find anything that may cause the error.

MarcoPBazz’s picture

FileSize
6.84 KB

Ok, after a long series of adjustments I finally say IT'S FUCKING WORKING NOW!!!!!

The problem was still in ms_stripe_confirm_payment because the paymentintent create was reduntant and useless (also as you pointed the payment_method is not a valid parameter) , so instead I recall the previously created payment, loaded and run the ms_stripe_do_customer_payment to generate the complete array which MS is using to complete the payment_profile and the order_add_data function.

Also there's lot of variables retrived by Stripe API who where different from the old version, so a lot of data were missing.

Here's my last version, I've also updated again the success and cancel url using $base_url correctly.

Let me know if it work for you, if not I have a little workaround to try.

Jane.L’s picture

Hey Marco - that's amazing!! Well done :)

I will ask our developer to apply the new module and I should be able to get back to you tomorrow about it.
Hope you have a good evening!

Jane.L’s picture

Hi Marco,

I think I will need your tweaks. This is what happens now for me:

1. The payment shows as successful in my Stripe Event logs (in Stripe dashboard) but the success URL is now
'success_url' => $base_url.'/ms/confirm_payment',

rather than

/ms/thankyou

We do not have a page

/ms/confirm_payment

so it appears as "page not found".

2. So the order appears as 'in checkout'
In the db logs, you can see this error log (see screenshot)

Also if I click on the ajax error, i get these errors at this link
https://docs.google.com/document/d/16iQjrN5nbFKOTXNQA6eRLsqM6D1fcV10zQ9O...

3. So I thought maybe I need my thank you page URL to be /ms/confirm_payment.
So I opened /admin/moneysuite/ms_core and tried creating a custom thank you URL

/ms/confirm_payment

but it still appears as page not found.

4. I notice that if I enter the current success URL of my test site

http://daxxxxxxxxxo.projectstatus.in/en/ms/thankyou

directly into the browser address bar, it auto redirects to

http://daxxxxxxxxxo.projectstatus.in/ms/confirm_payment

5. So is there a way that /ms/confirm payment can instead redirect to /ms/thankyou?
Or if not, then how can i change my success URL to be /ms/confirm_payment?

6.As you are getting a positive result, please let me know if you have changed your custom success URL.

MarcoPBazz’s picture

Hi Jane,
not sure why i've misspelled the success url: it's ms/ajax/confirm_payment.
Change the correct path and try again....

Jane.L’s picture

Hi Marco
we updated it and now the site goes to 'unexpected error'

Here is the log and screenshot

The user is correctly created, the product is entered but the payment is still not being recorded.

You mentioned other tweaks - could we try them please?

Jane.L’s picture

Also Marco - is it now working well for you, with the payment showing as completed and the product correctly in place? If so could you please resend the whole module again?

MarcoPBazz’s picture

FileSize
25.07 KB

The error that you posted was generated because ms_stripe_confirm_payment() wasn't loading the order oid property (without that it's impossible to get the other MS order properties and save it).

Here's the workaround with all the files this time, I confirm you that in my case is working on both sides (MS and Stripe dashboard)

Jane.L’s picture

Hi Marco,

FANTASTIC NEWS! It's working!! And I also tried a recurring membership, which was also set up correctly.
I also did a test Apple Pay payment and that also works. I assume then that Google Pay does too.

:)

Thank you for all your hard work and thank god it's done before the weekend. Have a great one. :)

MarcoPBazz’s picture

Happy that work, Have a great one too!

Ok, here's the definitive patch with:

  • patch #3 with improvements
  • Stripe Module dependency
  • Updated API call for paymentIntent, Session and Checkout (SCA)
Jane.L’s picture

Thanks Marco.

So could one of the maintainers please add these patches to the next module release? They need to be applied very soon in order for us to be compliant with new SCA rules coming in on 14 September.

Farreres or Clivem is it OK to add these to the MoneySuite modules please?

Also this means we could close 3 other issues

This one asking for SCA compliance:
https://www.drupal.org/project/moneysuite/issues/3070001

Discounts now working fine on the dev modules:
https://www.drupal.org/project/moneysuite/issues/2968042

Apple Pay and Google Pay are included as standard on the new Stripe Checkout. Android Pay and others are being added and will not require any additional integration from us. So this issue can be closed:
https://www.drupal.org/project/moneysuite/issues/2969146

Farreres’s picture

I am finishing my holidays. I come back to Barcelona on sunday morning. When I am there give me some two days to reestablish and I will apply the patch and create a dev release. If no complaints show up, later a new stable release will be created.

In any case, take into account that D7 is about to reach end of life, moneysuite for D8 should be developed.

Jane.L’s picture

Hi Marco and Farreres,

Farreres I hope you had a good holiday!

There are still a couple of issues I can see that need to be addressed. I did not notice them last week as too focussed on the Checkout payments.

Issue 1:

1. If a logged in user is making a second payment, even when this is minutes or days later, they are being offered the option to "Pay with saved card" (see screenshot 1). This card number ends with 0000, even though the Stripe Test card that the user paid with ended with 3184

2 Then when the user clicks 'next' and goes to the MS_Stripe module, the blue Checkout button is not showing, there is just a local Pay Now button. (see screenshot 2).

3. When the user clicks this "Pay Now" button, an error message appears. (see screenshot 3) and you can see my db log for this at screenshot 4.

This seems to me that MS_Stripe is mixing up the embedded Checkout Form with the Checkout Button.

Actually I think under new data protection laws the Checkout Form option may be illegal, as we are not supposed to save a user's card details. In any case it is a huge responsibility on a website to do this because if there was any fraud or the details were stolen, we could be held liable for the losses.

So really I think all sites should use the Checkout button if possible. It also offers new payment methods as standard with no further integration needed. Apple Pay, Google Pay are available now and more are under development for Stripe Checkout button.

Should the Checkout Form option be removed from MS Core? I don't think it makes any difference to the order, as when I first started using MoneyScripts i used to change from Checkout Form to Checkout Button and the order remained the same.

Issue 2 (much more minor):

1. Could the user's name and email address be passed over to the Checkout? So they do not have to enter them again? (see screenshot 5)

2. The order is called a "Modification" - could it just be called an Order, as 'modification' will confuse shoppers.

Jane.L’s picture

Hi Marco and Farreres,

Regarding my comment above in point 1, I think for now could the option to "Pay with saved card" just be removed from MS_Stripe dev version? This would mean that we can add the new MS_Stripe as soon as possible. I would like to apply it to my live site.

I had another email from Stripe this morning saying that some payments will start to be declined by European banks on 14 September. Other banks will phase in the new SCA rules.

MarcoPBazz’s picture

Hi Jane,
I think the right way is to let people choose to save cards or not.

Here's my patch, i've add this option in the Stripe settings (/admin/moneysuite/gateways/ms_stripe).

Also i've change removed the "Modification" word from the order description and I've fixed the saved payments error.

Jane.L’s picture

Thank you Marco,
we will apply the patch and test it.
Yes I think you are right, - if site owners want to save cards and are fully security compliant then that is their decision.

Jane.L’s picture

Hi Marco,

The patch worked fine thank you, so saved cards can be switched on or off.

We are going to apply the new module to our live site tomorrow and test it out with real payments. So I'll let you know how it goes! it will be interesting to see if it handles existing recurring memberships well.

Jane.L’s picture

Hi Marco,

We have applied your changes to our live site and the new Stripe checkout is working fine! Thank you.

We upgraded the live site PHP to 7.67 and installed the 7x-10x dev Moneysuite and your latest MS_Stripe patch from #104 above.

I'll have to wait for an existing recurring payment to come through (this does not happen every day) so will let you know how that goes - but just wanted to tell you that the changes are otherwise all fine on my live site. Fantastic!

MarcoPBazz’s picture

Hi Jane,
That's great ;)

Jane.L’s picture

Hi Marco,
Just an update - existing recurring payments work fine with this, so I would say it is all fixed. Thank you :)

Jane.L’s picture

Hi Marco,

Hope you are well!

I have noticed a big drop in conversion rates since using the new Stripe checkout. Lots of uncompleted payments or cancelled payments. Have you had a similar experience?

I think the main reason is that these customer details

Customer name
Customer email address

are not being passed to the Checkout so the user is having to enter them again.

Also the postcode/ZIP Code field appears even when it is not required.

I think this is confusing customers, and annoying them as they have to enter the details again (email address and name)

I have contacted Stripe support about this, and they said that the billing address should be set to auto – this will mean that the postcode/zip code field will only appear when the customers bank requires it in order to complete the transaction.

These are the links they sent me on all this:

https://stripe.com/docs/payments/checkout/customization#prefilling-custo...
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_ses...
https://stripe.com/docs/stripe-js/reference#stripe-redirect-to-checkout

Also, the “customer name” field is not required. We can bypass it when creating the following:

https://stripe.com/docs/api/customers/create#create_customer-name
https://stripe.com/docs/api/cards/object#card_object-name

So really all we need to pass to the checkout is the customer email and the amount /order number etc.

Would you mind making these changes please? The additional friction caused by the new checkout is leading to a drop in payments and I’m sure others may experience the same problem.

MarcoPBazz’s picture

Hi Jane, here's my patch.

It prefill the email field on checkout, unfortunately I can't figure out how prefill the user name either.
For the billing address side i've added an option in MS stripe configuration to let administrators choose how handle the billing_address_collection if automatically o required (so after apply this patch set this parameter first)

Jane.L’s picture

Thank you Marco, I will apply and let you know how it goes.
In my old Stripe checkout I did not require customer name when they reached checkout so there was no need to prefill the name.

Jane.L’s picture

Hi Marco, thank you for the patch. We have applied it and it does now pass the correct email address into checkout.

However I just made a successful live payment even though I entered a false name and post code, so these details are definitely not being checked. I will try to find out from Stripe support how to disable them.

gavin.hughes’s picture

Hi

I was looking to get this working on a site and here is what i'v tried so far

- Updated the php-strip library to version 6
- Updated to the dev release of moneysuite and applied the patches on this issue

- https://www.drupal.org/files/issues/2018-12-13/stripe-library-upgrade-29...
- https://www.drupal.org/files/issues/2019-09-06/0001-Stripe-SCA-authentic...
- https://www.drupal.org/files/issues/2019-09-10/0001-Stripe-Add-option-to...
- https://www.drupal.org/files/issues/2019-09-23/0001-Stripe-billing-check...

I'v also tried the zipped up version and applying patches against that. Unfortunately I don't seem to be able to get the transactions to work
I'm afraid i'm not overly familiar with this module suite or the issue but it seems like there is a number of issues being addressed and that there is no up to date patch that contains all patches. Im also not 100% sure that there is a requirement to have both the stripe module and the ms_stripe module as a dependency?

Happy to do a reroll of the issues and patches to bring it up to speed but there is certainly some confusion this issue was originally opened to update the php-strip library and it grown to include SCA as well.

Is anyone able to provide a summary of whats needed?

Which patches?
What version of the module?
What version of the php-stripe library

tonka67’s picture

​I've started seeing the following errors, and we can't start our D9 migration until March, so I'm hoping someone here can help me keep my site running. I've applied all of the above updates and everything now works, except the following:

I've got two sets of errors:

1)  Notice: Trying to access array offset on value of type null in ms_stripe_confirm_payment() (line 830 of /code/sites/all/modules/moneysuite/ms_core/gateways/ms_stripe/ms_stripe.module).

Corresponding to this ms_strip_confirm_payment function:

function ms_stripe_confirm_payment(){
  $received_json = file_get_contents("php://input",  TRUE);
  $data = drupal_json_decode($received_json, TRUE);
  try {
    ms_stripe_load_library();
    \Stripe\Stripe::setApiKey(variable_get('ms_stripe_secret_key', ''));
       if($data['order_id']){
        $order = ms_core_order_load($data['order_id']);
      }

Line 830 is the part that reads:

if($data['order_id']){

AND: 

2)  Notice: Trying to get property 'data' of non-object in ms_stripe_confirm_payment() (line 879 of /code/sites/all/modules/moneysuite/ms_core/gateways/ms_stripe/ms_stripe.module)

3)  Notice: Trying to access array offset on value of type null in ms_stripe_confirm_payment() (line 879 of /code/sites/all/modules/moneysuite/ms_core/gateways/ms_stripe/ms_stripe.module).

4)  Notice: Trying to get property 'type' of non-object in ms_stripe_confirm_payment() (line 879 of /code/sites/all/modules/moneysuite/ms_core/gateways/ms_stripe/ms_stripe.module)

These errors repeat for lines 880-882, which correspond to the credit card details in function ms_stripe_confirm_payment:

$payment_profile = array(
          'cc_type' => isset($intent["charges"]["data"][0]["payment_method_details"][0]["card"]) ? $intent["charges"]["data"][0]["payment_method_details"][0]["card"] : strtolower($customer->cards->data[0]->type),
          'cc_num' => isset($intent["charges"]["data"][0]["payment_method_details"][0]["card"]) ? $intent["card"]["last4"] : $customer->cards->data[0]->last4,
          'exp_month' => isset($intent["charges"]["data"][0]["payment_method_details"][0]["card"]) ? $intent["card"]["exp_month"] : $customer->cards->data[0]->exp_month,
          'exp_year' => isset($intent["charges"]["data"][0]["payment_method_details"][0]["card"]) ? $intent["card"]["exp_year"] : $customer->cards->data[0]->exp_year,
        );