forked from Wavyzz/dolibarr
Fix PhanPluginMixedKeyNoKey by using explicit keys
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2018-2021 Thibault FOUCART <support@ptibogxiv.net>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -206,10 +207,10 @@ class Stripe extends CommonObject
|
||||
try {
|
||||
if (empty($key)) { // If the Stripe connect account not set, we use common API usage
|
||||
//$customer = \Stripe\Customer::retrieve("$tiers");
|
||||
$customer = \Stripe\Customer::retrieve(array('id'=>"$tiers", 'expand[]'=>'sources'));
|
||||
$customer = \Stripe\Customer::retrieve(array('id' => "$tiers", 'expand[]' => 'sources'));
|
||||
} else {
|
||||
//$customer = \Stripe\Customer::retrieve("$tiers", array("stripe_account" => $key));
|
||||
$customer = \Stripe\Customer::retrieve(array('id'=>"$tiers", 'expand[]'=>'sources'), array("stripe_account" => $key));
|
||||
$customer = \Stripe\Customer::retrieve(array('id' => "$tiers", 'expand[]' => 'sources'), array("stripe_account" => $key));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// For example, we may have error: 'No such customer: cus_XXXXX; a similar object exists in live mode, but a test mode key was used to make this request.'
|
||||
@@ -221,7 +222,7 @@ class Stripe extends CommonObject
|
||||
$dataforcustomer = array(
|
||||
"email" => $object->email,
|
||||
"description" => $object->name,
|
||||
"metadata" => array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>$ipaddress)
|
||||
"metadata" => array('dol_id' => $object->id, 'dol_version' => DOL_VERSION, 'dol_entity' => $conf->entity, 'ipaddress' => $ipaddress)
|
||||
);
|
||||
|
||||
$vatcleaned = $object->tva_intra ? $object->tva_intra : null;
|
||||
@@ -256,7 +257,7 @@ class Stripe extends CommonObject
|
||||
$isineec = isInEEC($object);
|
||||
if ($object->country_code && $isineec) {
|
||||
//$taxids = $customer->allTaxIds($customer->id);
|
||||
$customer->createTaxId($customer->id, array('type'=>'eu_vat', 'value'=>$vatcleaned));
|
||||
$customer->createTaxId($customer->id, array('type' => 'eu_vat', 'value' => $vatcleaned));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -444,7 +445,7 @@ class Stripe extends CommonObject
|
||||
if (empty($paymentintent)) {
|
||||
// Try to create intent. See https://stripe.com/docs/api/payment_intents/create
|
||||
$ipaddress = getUserRemoteIP();
|
||||
$metadata = array('dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>$ipaddress);
|
||||
$metadata = array('dol_version' => DOL_VERSION, 'dol_entity' => $conf->entity, 'ipaddress' => $ipaddress);
|
||||
if (is_object($object)) {
|
||||
$metadata['dol_type'] = $object->element;
|
||||
$metadata['dol_id'] = $object->id;
|
||||
@@ -681,7 +682,7 @@ class Stripe extends CommonObject
|
||||
|
||||
if (empty($setupintent)) {
|
||||
$ipaddress = getUserRemoteIP();
|
||||
$metadata = array('dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>$ipaddress);
|
||||
$metadata = array('dol_version' => DOL_VERSION, 'dol_entity' => $conf->entity, 'ipaddress' => $ipaddress);
|
||||
if (is_object($object)) {
|
||||
$metadata['dol_type'] = $object->element;
|
||||
$metadata['dol_id'] = $object->id;
|
||||
@@ -877,19 +878,19 @@ class Stripe extends CommonObject
|
||||
|
||||
$dataforcard = array(
|
||||
"source" => array(
|
||||
'object'=>'card',
|
||||
'exp_month'=>$exp_date_month,
|
||||
'exp_year'=>$exp_date_year,
|
||||
'number'=>$number,
|
||||
'cvc'=>$cvc,
|
||||
'name'=>$cardholdername
|
||||
'object' => 'card',
|
||||
'exp_month' => $exp_date_month,
|
||||
'exp_year' => $exp_date_year,
|
||||
'number' => $number,
|
||||
'cvc' => $cvc,
|
||||
'name' => $cardholdername
|
||||
),
|
||||
"metadata" => array(
|
||||
'dol_type'=>$object->element,
|
||||
'dol_id'=>$object->id,
|
||||
'dol_version'=>DOL_VERSION,
|
||||
'dol_entity'=>$conf->entity,
|
||||
'ipaddress'=>$ipaddress
|
||||
'dol_type' => $object->element,
|
||||
'dol_id' => $object->id,
|
||||
'dol_version' => DOL_VERSION,
|
||||
'dol_entity' => $conf->entity,
|
||||
'ipaddress' => $ipaddress
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1022,7 +1023,7 @@ class Stripe extends CommonObject
|
||||
} elseif ($createifnotlinkedtostripe) {
|
||||
$iban = $obj->iban;
|
||||
$ipaddress = getUserRemoteIP();
|
||||
$metadata = array('dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>$ipaddress);
|
||||
$metadata = array('dol_version' => DOL_VERSION, 'dol_entity' => $conf->entity, 'ipaddress' => $ipaddress);
|
||||
if (is_object($object)) {
|
||||
$metadata['dol_type'] = $object->element;
|
||||
$metadata['dol_id'] = $object->id;
|
||||
@@ -1032,7 +1033,7 @@ class Stripe extends CommonObject
|
||||
$description = 'SEPA for IBAN '.$iban;
|
||||
|
||||
$dataforcard = array(
|
||||
'type'=>'sepa_debit',
|
||||
'type' => 'sepa_debit',
|
||||
"sepa_debit" => array('iban' => $iban),
|
||||
'billing_details' => array(
|
||||
'name' => $soc->name,
|
||||
@@ -1042,19 +1043,19 @@ class Stripe extends CommonObject
|
||||
);
|
||||
// Complete owner name
|
||||
if (!empty($soc->town)) {
|
||||
$dataforcard['billing_details']['address']['city']=$soc->town;
|
||||
$dataforcard['billing_details']['address']['city'] = $soc->town;
|
||||
}
|
||||
if (!empty($soc->country_code)) {
|
||||
$dataforcard['billing_details']['address']['country']=$soc->country_code;
|
||||
$dataforcard['billing_details']['address']['country'] = $soc->country_code;
|
||||
}
|
||||
if (!empty($soc->address)) {
|
||||
$dataforcard['billing_details']['address']['line1']=$soc->address;
|
||||
$dataforcard['billing_details']['address']['line1'] = $soc->address;
|
||||
}
|
||||
if (!empty($soc->zip)) {
|
||||
$dataforcard['billing_details']['address']['postal_code']=$soc->zip;
|
||||
$dataforcard['billing_details']['address']['postal_code'] = $soc->zip;
|
||||
}
|
||||
if (!empty($soc->state)) {
|
||||
$dataforcard['billing_details']['address']['state']=$soc->state;
|
||||
$dataforcard['billing_details']['address']['state'] = $soc->state;
|
||||
}
|
||||
|
||||
//$a = \Stripe\Stripe::getApiKey();
|
||||
@@ -1084,7 +1085,7 @@ class Stripe extends CommonObject
|
||||
} else {
|
||||
// link customer and src
|
||||
//$cs = $this->getSetupIntent($description, $soc, $cu, '', $status);
|
||||
$dataforintent = array(['description'=> $description, 'payment_method_types' => ['sepa_debit'], 'customer' => $cu->id, 'payment_method' => $sepa->id], 'metadata'=>$metadata);
|
||||
$dataforintent = array(0 => ['description' => $description, 'payment_method_types' => ['sepa_debit'], 'customer' => $cu->id, 'payment_method' => $sepa->id], 'metadata' => $metadata);
|
||||
|
||||
$cs = $s->setupIntents->create($dataforintent);
|
||||
//$cs = $s->setupIntents->update($cs->id, ['payment_method' => $sepa->id]);
|
||||
|
||||
Reference in New Issue
Block a user