Zen Cart Logo
Forums / Addon Payment Modules / Stripe.com payment integration module

Stripe.com payment integration module

Views: 233,173

Results 341 to 360 of 679
19 Jun 2024, 2:43 PM
#341
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
942
Plugin Contributions:
3

Stripe.com payment integration module

OJ_SIMON:

define('TABLE_STRIPE', DB_PREFIX . 'stripe');

> ```php
$db-> execute("CREATE TABLE " . TABLE_STRIPE  . "(id INT(11) AUTO_INCREMENT PRIMARY KEY,customers_id INT(11),Stripe_Customers_id VARCHAR(32))");

the above is how it should be done then anyone can use it without having to change code.

Noted. I forgot that the TABLE_ constants are always accessible. Submitting now.

19 Jun 2024, 2:45 PM
#342
oj_simon avatar

oj_simon

Zen Follower

Join Date:
Nov 2023
Location:
Hounslow
Posts:
129
Plugin Contributions:
0

Re: Stripe.com payment integration module

can i ask what this upgrade version is fixing or dealing with?

19 Jun 2024, 2:54 PM
#343
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
942
Plugin Contributions:
3

Re: Stripe.com payment integration module

OJ_SIMON:

can i ask what this upgrade version is fixing or dealing with?

Just a bugfix for configurations that are using table prefixes.

The native code makes a call to a database table named TABLE_STRIPE but on the modules installation, it only makes a table named 'stripe' and ignores the prefix configuration. If this module is already working, you don't need to change anything (this means your ZenCart tables do not have prefixes and works fine with the table named just stripe). However, if someone just snags the module from the plugins directory and they do have table prefixes configured, they'll run into errors as the table is wrongly named and referred to incorrectly in the database define.

19 Jun 2024, 3:00 PM
#344
oj_simon avatar

oj_simon

Zen Follower

Join Date:
Nov 2023
Location:
Hounslow
Posts:
129
Plugin Contributions:
0

Re: Stripe.com payment integration module

retched:

Just a bugfix for configurations that are using table prefixes.

The native code makes a call to a database table named TABLE_STRIPE but on the modules installation, it only makes a table named 'stripe' and ignores the prefix configuration. If this module is already working, you don't need to change anything (this means your ZenCart tables do not have prefixes and works fine with the table named just stripe). However, if someone just snags the module from the plugins directory and they do have table prefixes configured, they'll run into errors as the table is wrongly named and referred to incorrectly in the database define.

Seem needed.

can i also ask if you have or could check if the amount sent to Stripe is the correct amount when using the following:

  1. a coupon,
  2. a product that has a offer price,

I only ask this because in my installation the only amount sent to stripe is the total before any discount is applied?

19 Jun 2024, 3:01 PM
#345
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
942
Plugin Contributions:
3

Re: Stripe.com payment integration module

I can check on the first in a few but can you explain the second? What do you mean by "offer price"?

19 Jun 2024, 3:04 PM
#346
oj_simon avatar

oj_simon

Zen Follower

Join Date:
Nov 2023
Location:
Hounslow
Posts:
129
Plugin Contributions:
0

Re: Stripe.com payment integration module

retched:

I can check on the first in a few but can you explain the second? What do you mean by "offer price"?
a offer made via SaleMaker in admin

19 Jun 2024, 3:13 PM
#347
oj_simon avatar

oj_simon

Zen Follower

Join Date:
Nov 2023
Location:
Hounslow
Posts:
129
Plugin Contributions:
0

Re: Stripe.com payment integration module

    $i = count($order_totals);
    $i -= 1;
    
 echo $order_totals[$i]['value'];

gets the full total amount to send to Stripe but I can only get it to work on index.php?main_page=checkout_confirmation page and need to get this to
includes/modules/payment/stripe.php

line 146

$amount_total=round($order->info['total']*$order->info['currency_value'],$decimal_places)*$multiplied_by;

should be like

    $i = count($order_totals);    $i -= 1;
$order_value = $order_totals[$i]['value'];
        $amount_total = round($order_value * $order->info['currency_value'], $decimal_places) * $multiplied_by;
19 Jun 2024, 4:43 PM
#348
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
942
Plugin Contributions:
3

Re: Stripe.com payment integration module

OJ_SIMON:

$i = count($order_totals);
$i -= 1;

echo $order_totals[$i]['value'];

> 
> gets the full total amount to send to Stripe but I can only get it to work on index.php?main_page=checkout_confirmation page and need to get this to 
> includes/modules/payment/stripe.php
> 
> line 146
> ```php
$amount_total=round($order->info['total']*$order->info['currency_value'],$decimal_places)*$multiplied_by;

should be like

$i = count($order_totals);    $i -= 1;

$order_value = $order_totals[$i]['value'];
$amount_total = round($order_value * $order->info['currency_value'], $decimal_places) * $multiplied_by;



I'll look into both of these but no promises as I have a bit of work ahead of me.
19 Jun 2024, 4:45 PM
#349
oj_simon avatar

oj_simon

Zen Follower

Join Date:
Nov 2023
Location:
Hounslow
Posts:
129
Plugin Contributions:
0

Re: Stripe.com payment integration module

retched:

I'll look into both of these but no promises as I have a bit of work ahead of me.

could I hire you (paid service) to help me make a new plugin from scratch for stripe

26 Jun 2024, 12:15 PM
#350
gozzandes avatar

gozzandes

Zen Follower

Join Date:
Jul 2021
Location:
Fukuoka Japan
Posts:
131
Plugin Contributions:
0

Re: Stripe.com payment integration module

Sorry for making you wait.
The previous module had a problem. Stripe ID generated twice for a single order, but I resolved it today and uploaded a new module. Please wait until it is published.:smile:

27 Jun 2024, 4:36 PM
#351
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
942
Plugin Contributions:
3

Re: Stripe.com payment integration module

Gozzandes:

Sorry for making you wait.
The previous module had a problem. Stripe ID generated twice for a single order, but I resolved it today and uploaded a new module. Please wait until it is published.:smile:

Did you also get to the table error?

29 Jun 2024, 3:45 AM
#352
jmsnyder23 avatar

jmsnyder23

Zen Follower

Join Date:
Jan 2010
Location:
Richmond, Virginia, United States
Posts:
122
Plugin Contributions:
0

Re: Stripe.com payment integration module

Is there any way to change the payment confirmation page layout from tabs to accordion without radio buttons?

9 Jul 2024, 5:18 PM
#353
richard7315 avatar

richard7315

New Zenner

Join Date:
Jul 2017
Location:
West Midlands, UK
Posts:
51
Plugin Contributions:
1

Re: Stripe.com payment integration module

jmsnyder23:

Is there any way to change the payment confirmation page layout from tabs to accordion without radio buttons?

Hi,
Yes it is possible to change the layout of the stripe payment options from tabs to accordion (without radio buttons). The stripe documentation details the various layout options available.

find the following code in checkout.js

  const paymentElementOptions = {
    layout: "tabs",
  };

then change it to the following:

  const paymentElementOptions = {
  layout: {
    type: 'accordion',
    defaultCollapsed: true,
    radios: false,
    spacedAccordionItems: true
  }
}

The defaultCollapsed option can be set to true or false depending on what look you prefer. It is also possible to change the order of the payment methods (e.g. to show Apple Pay first).
Richard

9 Jul 2024, 5:36 PM
#354
oj_simon avatar

oj_simon

Zen Follower

Join Date:
Nov 2023
Location:
Hounslow
Posts:
129
Plugin Contributions:
0

Re: Stripe.com payment integration module

richard7315:

It is also possible to change the order of the payment methods (e.g. to show Apple Pay first).
Richard
This is not a option as you have put it - as there is only two options on showing/listing of payment methods with stripe:
"Manage payment methods from the Dashboard" or "Manually list payment methods" with only the later having the ability of "changing the order of payment methods" to do this you would have to harded code each method you wish to display and the down side of this is that errors can end up being displayed to your customers if stripe would not of displayed this method if the setting was of "Manage payment methods from the Dashboard" so I would say try your best to use the default setting of "Manage payment methods from the Dashboard" as Stripe uses many factors to decide if a method should or should not be displayed which would be too large to code these within a if statement and at lest one factor is fraud detection.

9 Jul 2024, 5:45 PM
#355
oj_simon avatar

oj_simon

Zen Follower

Join Date:
Nov 2023
Location:
Hounslow
Posts:
129
Plugin Contributions:
0

Re: Stripe.com payment integration module

This is the best option on this point:
https://docs.stripe.com/payments/payment-methods/integration-options

Use dynamic payment methods

Stripe dynamically displays the most relevant payment methods to your customers based on the payment method preferences you set in the Dashboard and eligibility factors such as transaction amount, currency, and payment flow. To enable and manage your payment method preferences, go to the Dashboard. Stripe enables certain payment methods for you by default and might enable additional payment methods after notifying you.
Unless you have to list payment methods manually, we recommend using dynamic payment methods. Dynamic payment methods automatically determines whether to display payment methods according to set rules.
See Dynamic payment methods to learn more.

Manually list payment methods

Listing payment methods manually requires some coding. Every payment method you want your PaymentIntent to accept must be added to payment_method_types. Unless your integration requires that you list payment methods manually, we recommend that you manage payment methods from the Dashboard. Stripe handles the return of eligible payment methods based on factors such as the transaction’s amount, currency, and payment flow.

9 Jul 2024, 6:59 PM
#356
richard7315 avatar

richard7315

New Zenner

Join Date:
Jul 2017
Location:
West Midlands, UK
Posts:
51
Plugin Contributions:
1

Re: Stripe.com payment integration module

Hi,
Apologies for not being clearer - I believe it is possible to change the sort order of the stripe payment methods by using the paymentMethodOrder array.

Any payment methods listed in the paymentMethodOrder (such as Apple Pay or Google Pay) will be displayed first – other methods turned on in the dashboard will then be automatically added lower down the list.

I have not had a chance to test this yet, but I can’t see any reason why it wouldn’t work.

Full details on this feature are available here

Stripe will dynamically show payment methods that are available to your customer (e.g. Apple Pay will only be displayed if the customer is signed up).
Richard

11 Jul 2024, 6:15 PM
#357
richard7315 avatar

richard7315

New Zenner

Join Date:
Jul 2017
Location:
West Midlands, UK
Posts:
51
Plugin Contributions:
1

Re: Stripe.com payment integration module

Hi,
I have been testing the latest stripe module for Zen Cart 2.0.1. Unfortunately, there appears to be a few minor issues.

1)After uploading the header_php.php file in the checkout_payment folder a PHP warning is logged (--> PHP Warning: Undefined variable $gv_balance in /includes/templates/template_default/templates/tpl_checkout_payment_default.php on line 206.).

This seems to be because the 1.5.8 file has been included with the mod instead of the 2.0.1 file.

2)When accessing the checkout_confirmation page the following PHP warnings are logged:

[11-Jul-2024 17:53:04 Europe/London] Request URI: /index.php?main_page=checkout_confirmation, Language id 1
#0 /includes/modules/payment/stripepay/create.php(69): zen_debug_error_handler()
#1 /includes/modules/payment/stripe.php(165): require_once('/home/virtual/v...')
#2 /includes/classes/payment.php(248): stripe->pre_confirmation_check()
#3 /includes/modules/pages/checkout_confirmation/header_php.php(92): payment->pre_confirmation_check()
#4 /index.php(35): require('/home/virtual/v...')
--> PHP Warning: Undefined array key "order_add_comment" in /includes/modules/payment/stripepay/create.php on line 69.

[11-Jul-2024 17:53:04 Europe/London] Request URI: /index.php?main_page=checkout_confirmation, Language id 1
#0 [internal function]: zen_debug_error_handler()
#1 /includes/templates/responsive_classic/common/html_header.php(20): header()
#2 /index.php(42): require('/home/virtual/v...')
--> PHP Warning: Cannot modify header information - headers already sent by (output started at /includes/modules/payment/stripepay/create.php:76) in /includes/templates/responsive_classic/common/html_header.php on line 20.

3)If an alternative payment method is selected (such as check/money order) the following PHP warning is logged:

[11-Jul-2024 17:58:22 Europe/London] Request URI: /index.php?main_page=checkout_confirmation, Language id 1
#0 /includes/modules/pages/checkout_confirmation/jscript_stripe.php(1): zen_debug_error_handler()
#1 /includes/templates/responsive_classic/common/html_header.php(205): require('/home/virtual/v...')
#2 /index.php(42): require('/home/virtual/v...')
--> PHP Warning: Undefined variable $stripe_select in /includes/modules/pages/checkout_confirmation/jscript_stripe.php on line 1.
  1. When using payment methods other than stripe there is a problem with the order total display at checkout. Image 1 shows how the totals should display normally. Image 2 shows the orders totals do not appear.

I believe issue 4 has been caused by the core file edit to tpl_checkout_confirmation. The edit comments out the following code:

/*
  if (MODULE_ORDER_TOTAL_INSTALLED) {
    $order_totals = $order_total_modules->process();

?>
<?php
  }
*/

I would strongly recommend that core file edits are avoided whenever possible. This will reduce the chance of compatibility issues with other mods.

Most of the PHP warnings may not cause any problems but on a busy site a large number of logs would be produced.

It would be much appreciated if anyone could help resolve any of these issues.
Many thanks
Richard
Attachment 20697Attachment 20698

11 Jul 2024, 7:06 PM
#358
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,682
Plugin Contributions:
56

Re: Stripe.com payment integration module

Looking at (1)

1)After uploading the header_php.php file in the checkout_payment folder a PHP warning is logged (--> PHP Warning: Undefined variable $gv_balance in /includes/templates/template_default/templates/tpl_checkout_payment_default.php on line 206.).

Isn't $gv_balance set on includes/modules/pages/checkout_payment/header_php.php line 123 ?

12 Jul 2024, 9:24 AM
#359
richard7315 avatar

richard7315

New Zenner

Join Date:
Jul 2017
Location:
West Midlands, UK
Posts:
51
Plugin Contributions:
1

Re: Stripe.com payment integration module

Hi swguy
Thank you for your reply. Yes, the $gv_balance is set on line 123 in version 2.0.1. The issue seems to have been caused by the incorrect file being included with the stripe module.

I have uploaded the files from the stripe mod and noticed that there is an override/edit for includes/modules/pages/checkout_payment/header_php.php

The stripe mod has three sets of files that can be uploaded (depending on the zen cart version). It appears that the 2.0.1 header_php file has been mistakenly copied from the 1.5.8 version.

Issue 1 should be easy to fix – hopefully on the next update the correct file can be included. The other issues may be more complicated to fix.
Many thanks
Richard

23 Jul 2024, 11:04 AM
#360
richard7315 avatar

richard7315

New Zenner

Join Date:
Jul 2017
Location:
West Midlands, UK
Posts:
51
Plugin Contributions:
1

Re: Stripe.com payment integration module

Update:

Issue 2

I have noticed that the first warning from issue 2 (undefined array key) has been previously fixed by gozzandes. See post #306 for details

Carlwhat has previously mentioned that line 69 of create.php could be removed – I believe this is correct, however line 179 of stripe.php would need to be changed to:

$order_comment = (isset($_SESSION['order_add_comment']))."\n Stripe ID:";

This will prevent the undefined array key warning from showing.

Issue 3

It appears issue 3 can be fixed by changing line 1 of includes/modules/pages/checkout_confirmation/jscript_stripe.php to

<?php if (isset($stripe_select) && MODULE_PAYMENT_STRIPE_STATUS === 'True' && $stripe_select == 'True' ) {?>

Issue 4

I believe issue 4 can be fixed by editing the tpl_checkout_confirmation.php file supplied with the stripe module:

change lines 157 – 166 to the following:

<?php if (MODULE_ORDER_TOTAL_INSTALLED && $_SESSION['payment'] != 'stripe') { $order_totals = $order_total_modules->process(); } ?>

Other issues

Web developer console shows error at checkout – failed to load checkout_confirmation.css

Solution: remove line 2 from includes/modules/pages/checkout_confirmation/jscript_stripe.php


Web developer console shows that some files from stripe seem to have loaded twice. This causes a hcaptcha authentication error to appear in the console.


I have looked into the ‘cannot modify header information’ warning and have not found a solution yet. The cause appears to be <script> tags used at the end of the create.php file. The script code is as follows:

<script>
   'use strict';
    var clientS = JSON.parse('<?php echo $clientS_json; ?>');
    var PublishableKey = JSON.parse('<?php echo $jason_publishable_key; ?>');
    var confirmationURL = JSON.parse('<?php echo $confirmationURL; ?>');
    var PaymentSuccess = JSON.parse('<?php echo $jason_PaymentSuccess; ?>');
</script>

Does anyone know if it would be possible to move the script elsewhere to prevent headers being modified?

Any help fixing this issue would be much appreciated.
Many thanks
Richard

Note: the edits I have made apply to version 2.0.1. The edits may be different for other versions.