Re: Stripe payment module - Duplicate charges, no order
Return url is not json encoded.
So script cannot read the PHP return URL
\www\includes\modules\payment\stripepay\create.php line 63
add following code
PHP Code:
$jason_confirmationULR = json_encode($confirmationURL);
and rewrite from
Code:
var confirmationURL = JSON.parse('<?php echo $confirmationURL; ?>');
to
Code:
var confirmationURL = JSON.parse('<?php echo $jason_confirmationULR; ?>');
if it's OK.
could you reply the post?
Re: Stripe payment module - Duplicate charges, no order
The customer further clarified, that when the first charge occurred, he never was directed to Amazon, it was if the "Edit" button for address had a similar effect as the "Confirm order" button. He said that after changing the address and clicking "Confirm Order", he was then redirected to Amazon; that's when the 2nd charge occurred.
Re: Stripe payment module - Duplicate charges, no order
Quote:
Originally Posted by
Gozzandes
Return url is not json encoded.
So script cannot read the PHP return URL
I put the changes on my mirrored test site, which operates in Stripe test mode.
Tried an Amazon Payment
Pressed the "Confirm Order" button and to the left of it appeared this message:
You must provide a `return_url` when confirming a PaymentIntent with the payment method type amazon_pay.
The transaction appeared on Stripe as "Incomplete"
On Zen, the message disappeared and I remained on the 3rd checkout page as if the "confirm order" button was never pressed
1 Attachment(s)
Re: Stripe payment module - Duplicate charges, no order
if you rewrite checkout.jp return_url: confirmationURL, to return_url: https://YOUR DOMEIN/index.php?main_page=checkout_confirmation,
Please revert this code to return_url: confirmationURL,.
I've checked live site using Googlepay.
Payment was made twice, 1st payment is failed and 2nd is succeeded.
And zen cart was also succeeded.
It works everything.
Attachment 20875
Re: Stripe payment module - Duplicate charges, no order
Here's the revised create.php code:
PHP Code:
<?php
require 'vendor/autoload.php';
\Stripe\Stripe::setApiKey($secret_key);
try {
global $db,$output,$param_json;
if ($registered_customer == false && $test_mode == false){
$customer = \Stripe\Customer::create([
'email' => $email,
'name' => $fullname,
]);
$stripeCustomerID = $customer->id;
$sql = "INSERT INTO " . TABLE_STRIPE . " (id,customers_id,Stripe_Customers_id) VALUES (NULL,:custID, :stripeCID )";
$sql = $db->bindVars($sql, ':custID', $_SESSION['customer_id'], 'integer');
$sql = $db->bindVars($sql, ':stripeCID', $stripeCustomerID, 'string');
$db->Execute($sql);
}elseif ($test_mode == false){
$stripeCustomerID = $stripe_customer->fields['stripe_customers_id'];
}
// Create a PaymentIntent with amount and currency
if ($test_mode == false){
$paymentIntent = \Stripe\PaymentIntent::create([
'amount' => $amount_total,
'currency' => $payment_currency,
'customer' => $stripeCustomerID,
'automatic_payment_methods' => [
'enabled' => true,
],
]);
}else{
$paymentIntent = \Stripe\PaymentIntent::create([
'amount' => $amount_total,
'currency' => $payment_currency,
'automatic_payment_methods' => [
'enabled' => true,
],
]);
}
$output = [
'clientSecret' => $paymentIntent->client_secret,
];
$clientS_json = json_encode($output);
} catch (Error $e) {
http_response_code(500);
$clientS_json =json_encode(['error' => $e->getMessage()]);
}
$jason_publishable_key = json_encode($publishable_key);
$jason_PaymentSuccess = json_encode(TEXT_PAYMENT_STRIPE_PAYMENTSUCCEEDED);
$confirmationURL = '"' . HTTPS_SERVER . DIR_WS_HTTPS_CATALOG . 'index.php?main_page=checkout_confirmation"';
$jason_confirmationURL = json_encode($confirmationURL);
//---comments---
if($order->info['comments']!=""){
$order_add_comment = $order->info['comments'];
$_SESSION['order_add_comment'] = $order_add_comment;
}else{
$_SESSION['order_add_comment'] = "";
}
$_SESSION['paymentIntent'] = $paymentIntent['id'];
//echo $paymentIntent['id'];
//------------
?>
<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 $jason_confirmationURL; ?>');
var PaymentSuccess = JSON.parse('<?php echo $jason_PaymentSuccess; ?>');
</script>
Re: Stripe payment module - Duplicate charges, no order
The first pi number is created through create.php.
The second pi number is created without going through create.php, so I think it is automatically generated by the Stripe server.
Perhaps the first one was for credit card payment, and the second one was created again to redirect to an external site.
Well, that's just my guess.
Re: Stripe payment module - Duplicate charges, no order
I'm not clear what changes are needed. Does checkout.jp and create.php need to change?
Re: Stripe payment module - Duplicate charges, no order
Quote:
Originally Posted by
Gozzandes
Here's the revised create.php code:
I replaced the contents of create.php with the code you just posted and tried it with Amazon Pay. I did not mess with checkout.jp.
Same issue as before,
I see the message:
You must provide a `return_url` when confirming a PaymentIntent with the payment method type amazon_pay.
Re: Stripe payment module - Duplicate charges, no order
Quote:
Originally Posted by
split63
I'm not clear what changes are needed. Does checkout.jp and create.php need to change?
checkout.js should not be changed, it's should be original line 39 return_url: confirmationURL,.
creat.php line 60 - should be changed
PHP Code:
$jason_publishable_key = json_encode($publishable_key);
$jason_PaymentSuccess = json_encode(TEXT_PAYMENT_STRIPE_PAYMENTSUCCEEDED);
$confirmationURL = '"' . HTTPS_SERVER . DIR_WS_HTTPS_CATALOG . 'index.php?main_page=checkout_confirmation"';
$jason_confirmationURL = json_encode($confirmationURL);
//---comments---
if($order->info['comments']!=""){
$order_add_comment = $order->info['comments'];
$_SESSION['order_add_comment'] = $order_add_comment;
}else{
$_SESSION['order_add_comment'] = "";
}
$_SESSION['paymentIntent'] = $paymentIntent['id'];
//echo $paymentIntent['id'];
//------------
?>
<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 $jason_confirmationURL; ?>');
var PaymentSuccess = JSON.parse('<?php echo $jason_PaymentSuccess; ?>');
</script>
Re: Stripe payment module - Duplicate charges, no order
Quote:
Originally Posted by
split63
I replaced the contents of create.php with the code you just posted and tried it with Amazon Pay. I did not mess with checkout.jp.
Same issue as before,
I see the message:
You must provide a `return_url` when confirming a PaymentIntent with the payment method type amazon_pay.
following codes are for Amazonpay.
create.php line 34-36 and 42-44
from
PHP Code:
'automatic_payment_methods' => [
'enabled' => true,
],
to
PHP Code:
payment_method_types: ['card', 'amazon_pay'],