Skip to content
GitLab
Erkunden
Anmelden
Registrieren
Primärnavigation
Suchen oder aufrufen …
Projekt
payment-stripe
Verwalten
Aktivität
Mitglieder
Labels
Planen
Tickets
9
Ticketübersichten
Meilensteine
Wiki
Code
Merge Requests
1
Repository
Branch
Commits
Tags
Repository-Diagramm
Revisionen vergleichen
Code-Schnipsel
Build
Pipelines
Aufgaben
Pipeline-Zeitpläne
Artefakte
Bereitstellung
Releases
Betreiben
Umgebungen
Überwachen
Vorfälle
Service-Desk
Analysieren
Wertschöpfungskettenanalyse
Mitwirkenden-Analyse
CI/CD-Analyse
Repository-Analysen
Hilfe
Hilfe
Support
GitLab-Dokumentation
GitLab-Pläne vergleichen
Community-Forum
Zu GitLab beitragen
Feedback geben
Tastenkürzel
?
Code-Schnipsel
Gruppen
Projekte
Show more breadcrumbs
QUIQQER
payment-stripe
Commits
4f40b459
Bestätigt
Commit
4f40b459
erstellt
vor 1 Jahr
von
Henning Leutz
Dateien durchsuchen
Optionen
Downloads
Patches
Einfaches Diff
feat: compatiblity to payments v2
Übergeordneter
8029f48b
No related branches found
Branches enthält Commit
No related tags found
Tags enthält Commit
2 Merge Requests
!4
Next
,
!3
feat: compatiblity to payments v2
Pipeline
#5252
mit Warnungen bestanden mit Phase
in 12 Sekunden
Änderungen
2
Pipelines
1
Leerzeichenänderungen ausblenden
Inline
Nebeneinander
2 geänderte Dateien
composer.json
+1
-1
1 Ergänzung, 1 Löschung
composer.json
src/QUI/ERP/Payments/Stripe/AbstractBasePayment.php
+43
-39
43 Ergänzungen, 39 Löschungen
src/QUI/ERP/Payments/Stripe/AbstractBasePayment.php
werden angezeigt
mit
44 Ergänzungen
und
40 Löschungen
composer.json
+
1
−
1
Zeige Datei @
4f40b459
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
"url"
:
"http:
\/\/
www.pcsg.de"
"url"
:
"http:
\/\/
www.pcsg.de"
},
},
"require"
:
{
"require"
:
{
"quiqqer\/payments"
:
"^1.1|dev-master|dev-dev"
,
"quiqqer\/payments"
:
"^
2|^
1.1|dev-master|dev-dev"
,
"stripe\/stripe-php"
:
"^7"
,
"stripe\/stripe-php"
:
"^7"
,
"cbschuld\/browser.php"
:
"^1"
"cbschuld\/browser.php"
:
"^1"
},
},
...
...
This diff is collapsed.
Zum Erweitern klicken.
src/QUI/ERP/Payments/Stripe/AbstractBasePayment.php
+
43
−
39
Zeige Datei @
4f40b459
...
@@ -4,10 +4,10 @@
...
@@ -4,10 +4,10 @@
use
QUI
;
use
QUI
;
use
QUI\ERP\Accounting\Payments\Gateway\Gateway
;
use
QUI\ERP\Accounting\Payments\Gateway\Gateway
;
use
QUI\ERP\Accounting\Payments\Transactions\Factory
as
TransactionFactory
;
use
QUI\ERP\Accounting\Payments\Transactions\Transaction
;
use
QUI\ERP\Accounting\Payments\Transactions\Transaction
;
use
QUI\ERP\Order\AbstractOrder
;
use
QUI\ERP\Order\AbstractOrder
;
use
QUI\ERP\Order\Handler
as
OrderHandler
;
use
QUI\ERP\Order\Handler
as
OrderHandler
;
use
QUI\ERP\Accounting\Payments\Transactions\Factory
as
TransactionFactory
;
use
Stripe\Exception\ApiErrorException
;
use
Stripe\Exception\ApiErrorException
;
use
Stripe\PaymentIntent
as
StripePaymentIntent
;
use
Stripe\PaymentIntent
as
StripePaymentIntent
;
use
Stripe\Refund
as
StripeRefund
;
use
Stripe\Refund
as
StripeRefund
;
...
@@ -24,11 +24,11 @@ abstract class AbstractBasePayment extends QUI\ERP\Accounting\Payments\Api\Abstr
...
@@ -24,11 +24,11 @@ abstract class AbstractBasePayment extends QUI\ERP\Accounting\Payments\Api\Abstr
*/
*/
const
ATTR_STRIPE_PAYMENT_INTENT_ID
=
'stripe-PaymentIntentId'
;
const
ATTR_STRIPE_PAYMENT_INTENT_ID
=
'stripe-PaymentIntentId'
;
const
ATTR_STRIPE_PAYMENT_METHOD_ID
=
'stripe-PaymentMethodId'
;
const
ATTR_STRIPE_PAYMENT_METHOD_ID
=
'stripe-PaymentMethodId'
;
const
ATTR_STRIPE_REFUND_ID
=
'stripe-RefundId'
;
const
ATTR_STRIPE_REFUND_ID
=
'stripe-RefundId'
;
const
ATTR_STRIPE_ORDER_SUCCESSFUL
=
'stripe-OrderSuccessful'
;
const
ATTR_STRIPE_ORDER_SUCCESSFUL
=
'stripe-OrderSuccessful'
;
const
ATTR_STRIPE_BILLING_PLAN_ID
=
'stripe-BillingPlanId'
;
const
ATTR_STRIPE_BILLING_PLAN_ID
=
'stripe-BillingPlanId'
;
const
ATTR_STRIPE_SUBSCRIPTION_ID
=
'stripe-SubscriptionId'
;
const
ATTR_STRIPE_SUBSCRIPTION_ID
=
'stripe-SubscriptionId'
;
const
ATTR_STRIPE_INVOICE_ID
=
'stripe-InvoiceId'
;
const
ATTR_STRIPE_INVOICE_ID
=
'stripe-InvoiceId'
;
/**
/**
* Stripe User attributes
* Stripe User attributes
...
@@ -38,9 +38,9 @@ abstract class AbstractBasePayment extends QUI\ERP\Accounting\Payments\Api\Abstr
...
@@ -38,9 +38,9 @@ abstract class AbstractBasePayment extends QUI\ERP\Accounting\Payments\Api\Abstr
/**
/**
* Error codes
* Error codes
*/
*/
const
ERROR_GENERAL
=
'error_general'
;
const
ERROR_GENERAL
=
'error_general'
;
const
ERROR_REFUND
=
'error_refund'
;
const
ERROR_REFUND
=
'error_refund'
;
const
ERROR_REFUND_STATUS
=
'error_refund_status'
;
const
ERROR_REFUND_STATUS
=
'error_refund_status'
;
const
ERROR_REFUND_MISSING_PAYMENT_INTENT_ID
=
'error_missing_payment_intent_id'
;
const
ERROR_REFUND_MISSING_PAYMENT_INTENT_ID
=
'error_missing_payment_intent_id'
;
/**
/**
...
@@ -179,7 +179,7 @@ public function getGatewayDisplay(AbstractOrder $Order, $Step = null)
...
@@ -179,7 +179,7 @@ public function getGatewayDisplay(AbstractOrder $Order, $Step = null)
$Control
=
new
PaymentDisplay
([
$Control
=
new
PaymentDisplay
([
'paymentMethod'
=>
$type
,
'paymentMethod'
=>
$type
,
'infoText'
=>
$this
->
getPaymentStepInfo
()
'infoText'
=>
$this
->
getPaymentStepInfo
()
]);
]);
$Control
->
setAttribute
(
'Order'
,
$Order
);
$Control
->
setAttribute
(
'Order'
,
$Order
);
...
@@ -193,7 +193,7 @@ public function getGatewayDisplay(AbstractOrder $Order, $Step = null)
...
@@ -193,7 +193,7 @@ public function getGatewayDisplay(AbstractOrder $Order, $Step = null)
'stepTitle'
=>
$stepTitle
'stepTitle'
=>
$stepTitle
]);
]);
$Step
->
setContent
(
$Engine
->
fetch
(
dirname
(
__FILE__
)
.
'/PaymentDisplay.Header.html'
));
$Step
->
setContent
(
$Engine
->
fetch
(
dirname
(
__FILE__
)
.
'/PaymentDisplay.Header.html'
));
return
$Control
->
create
();
return
$Control
->
create
();
}
}
...
@@ -226,7 +226,7 @@ public function createPaymentIntent(AbstractOrder $Order, $paymentMethodId)
...
@@ -226,7 +226,7 @@ public function createPaymentIntent(AbstractOrder $Order, $paymentMethodId)
$PaymentIntent
=
$this
->
createPaymentIntentForOrder
(
$Order
,
$paymentMethodId
);
$PaymentIntent
=
$this
->
createPaymentIntentForOrder
(
$Order
,
$paymentMethodId
);
$Order
->
setPaymentData
(
self
::
ATTR_STRIPE_PAYMENT_INTENT_ID
,
$PaymentIntent
->
id
);
$Order
->
setPaymentData
(
self
::
ATTR_STRIPE_PAYMENT_INTENT_ID
,
$PaymentIntent
->
id
);
$this
->
addOrderHistoryEntry
(
$Order
,
'PaymentIntent '
.
$PaymentIntent
->
id
.
' created.'
);
$this
->
addOrderHistoryEntry
(
$Order
,
'PaymentIntent '
.
$PaymentIntent
->
id
.
' created.'
);
return
$PaymentIntent
;
return
$PaymentIntent
;
}
}
...
@@ -268,9 +268,11 @@ public function confirmPaymentIntent(AbstractOrder $Order, StripePaymentIntent $
...
@@ -268,9 +268,11 @@ public function confirmPaymentIntent(AbstractOrder $Order, StripePaymentIntent $
$confirmData
=
[];
$confirmData
=
[];
if
(
$PaymentIntent
->
status
===
$PaymentIntent
::
STATUS_REQUIRES_ACTION
if
(
&&
$PaymentIntent
->
next_action
->
type
===
'use_stripe_sdk'
)
{
$PaymentIntent
->
status
===
$PaymentIntent
::
STATUS_REQUIRES_ACTION
$confirmData
[
'status'
]
=
'action_required'
;
&&
$PaymentIntent
->
next_action
->
type
===
'use_stripe_sdk'
)
{
$confirmData
[
'status'
]
=
'action_required'
;
$confirmData
[
'clientSecret'
]
=
$PaymentIntent
->
client_secret
;
$confirmData
[
'clientSecret'
]
=
$PaymentIntent
->
client_secret
;
$this
->
addOrderHistoryEntry
(
$Order
,
'Additional user action required for PaymentIntent confirmation.'
);
$this
->
addOrderHistoryEntry
(
$Order
,
'Additional user action required for PaymentIntent confirmation.'
);
...
@@ -303,7 +305,7 @@ public function confirmPaymentIntent(AbstractOrder $Order, StripePaymentIntent $
...
@@ -303,7 +305,7 @@ public function confirmPaymentIntent(AbstractOrder $Order, StripePaymentIntent $
$this
->
addOrderHistoryEntry
(
$this
->
addOrderHistoryEntry
(
$Order
,
$Order
,
'Error while trying to set order as successful: '
.
$Exception
->
getMessage
()
'Error while trying to set order as successful: '
.
$Exception
->
getMessage
()
);
);
}
}
}
else
{
}
else
{
...
@@ -355,10 +357,12 @@ public function getPaymentIntentByOrder(AbstractOrder $Order)
...
@@ -355,10 +357,12 @@ public function getPaymentIntentByOrder(AbstractOrder $Order)
public
function
refundPayment
(
Transaction
$Transaction
,
$refundHash
,
$amount
,
$reason
=
''
)
public
function
refundPayment
(
Transaction
$Transaction
,
$refundHash
,
$amount
,
$reason
=
''
)
{
{
$Process
=
new
QUI\ERP\Process
(
$Transaction
->
getGlobalProcessId
());
$Process
=
new
QUI\ERP\Process
(
$Transaction
->
getGlobalProcessId
());
$Process
->
addHistory
(
'Stripe :: Start refund for transaction #'
.
$Transaction
->
getTxId
());
$Process
->
addHistory
(
'Stripe :: Start refund for transaction #'
.
$Transaction
->
getTxId
());
if
(
!
$Transaction
->
getData
(
self
::
ATTR_STRIPE_PAYMENT_INTENT_ID
))
{
if
(
!
$Transaction
->
getData
(
self
::
ATTR_STRIPE_PAYMENT_INTENT_ID
))
{
$Process
->
addHistory
(
'PayPal :: Transaction cannot be refunded because it is not yet captured / completed.'
);
$Process
->
addHistory
(
'PayPal :: Transaction cannot be refunded because it is not yet captured / completed.'
);
$this
->
throwStripeException
(
$this
->
throwStripeException
(
self
::
ERROR_REFUND_MISSING_PAYMENT_INTENT_ID
,
self
::
ERROR_REFUND_MISSING_PAYMENT_INTENT_ID
,
...
@@ -371,7 +375,7 @@ public function refundPayment(Transaction $Transaction, $refundHash, $amount, $r
...
@@ -371,7 +375,7 @@ public function refundPayment(Transaction $Transaction, $refundHash, $amount, $r
}
}
$paymentIntentId
=
$Transaction
->
getData
(
self
::
ATTR_STRIPE_PAYMENT_INTENT_ID
);
$paymentIntentId
=
$Transaction
->
getData
(
self
::
ATTR_STRIPE_PAYMENT_INTENT_ID
);
$Currency
=
$Transaction
->
getCurrency
();
$Currency
=
$Transaction
->
getCurrency
();
// Create a refund transaction (QUIQQER)
// Create a refund transaction (QUIQQER)
$RefundTransaction
=
TransactionFactory
::
createPaymentRefundTransaction
(
$RefundTransaction
=
TransactionFactory
::
createPaymentRefundTransaction
(
...
@@ -381,7 +385,7 @@ public function refundPayment(Transaction $Transaction, $refundHash, $amount, $r
...
@@ -381,7 +385,7 @@ public function refundPayment(Transaction $Transaction, $refundHash, $amount, $r
$Transaction
->
getPayment
()
->
getName
(),
$Transaction
->
getPayment
()
->
getName
(),
[
[
'isRefund'
=>
1
,
'isRefund'
=>
1
,
'message'
=>
$reason
'message'
=>
$reason
],
],
null
,
null
,
false
,
false
,
...
@@ -393,12 +397,12 @@ public function refundPayment(Transaction $Transaction, $refundHash, $amount, $r
...
@@ -393,12 +397,12 @@ public function refundPayment(Transaction $Transaction, $refundHash, $amount, $r
// Create refund (Stripe)
// Create refund (Stripe)
try
{
try
{
$PaymentIntent
=
StripePaymentIntent
::
retrieve
(
$paymentIntentId
);
$PaymentIntent
=
StripePaymentIntent
::
retrieve
(
$paymentIntentId
);
$AmountValue
=
new
QUI\ERP\Accounting\CalculationValue
(
$amount
,
$Transaction
->
getCurrency
(),
2
);
$AmountValue
=
new
QUI\ERP\Accounting\CalculationValue
(
$amount
,
$Transaction
->
getCurrency
(),
2
);
$refundAmount
=
$AmountValue
->
get
()
*
100
;
// convert to smallest currency unit
$refundAmount
=
$AmountValue
->
get
()
*
100
;
// convert to smallest currency unit
$Refund
=
StripeRefund
::
create
([
$Refund
=
StripeRefund
::
create
([
'charge'
=>
$PaymentIntent
->
charges
->
data
[
0
]
->
id
,
'charge'
=>
$PaymentIntent
->
charges
->
data
[
0
]
->
id
,
'amount'
=>
$refundAmount
,
'amount'
=>
$refundAmount
,
// 'reason' => StripeRefund::REASON_REQUESTED_BY_CUSTOMER,
// 'reason' => StripeRefund::REASON_REQUESTED_BY_CUSTOMER,
'metadata'
=>
[
'metadata'
=>
[
'refundTxId'
=>
$RefundTransaction
->
getTxId
()
'refundTxId'
=>
$RefundTransaction
->
getTxId
()
...
@@ -414,9 +418,9 @@ public function refundPayment(Transaction $Transaction, $refundHash, $amount, $r
...
@@ -414,9 +418,9 @@ public function refundPayment(Transaction $Transaction, $refundHash, $amount, $r
'quiqqer/payment-stripe'
,
'quiqqer/payment-stripe'
,
'history.refund.error_api'
,
'history.refund.error_api'
,
[
[
'amount'
=>
$amount
,
'amount'
=>
$amount
,
'currency'
=>
$Currency
->
getCode
(),
'currency'
=>
$Currency
->
getCode
(),
'txId'
=>
$Transaction
->
getTxId
()
'txId'
=>
$Transaction
->
getTxId
()
]
]
)
)
);
);
...
@@ -436,9 +440,9 @@ public function refundPayment(Transaction $Transaction, $refundHash, $amount, $r
...
@@ -436,9 +440,9 @@ public function refundPayment(Transaction $Transaction, $refundHash, $amount, $r
'history.refund.success'
,
'history.refund.success'
,
[
[
'refundId'
=>
$Refund
->
id
,
'refundId'
=>
$Refund
->
id
,
'amount'
=>
$amount
,
'amount'
=>
$amount
,
'currency'
=>
$Currency
->
getCode
(),
'currency'
=>
$Currency
->
getCode
(),
'txId'
=>
$Transaction
->
getTxId
()
'txId'
=>
$Transaction
->
getTxId
()
]
]
)
)
);
);
...
@@ -460,9 +464,9 @@ public function refundPayment(Transaction $Transaction, $refundHash, $amount, $r
...
@@ -460,9 +464,9 @@ public function refundPayment(Transaction $Transaction, $refundHash, $amount, $r
'history.refund.pending'
,
'history.refund.pending'
,
[
[
'refundId'
=>
$Refund
->
id
,
'refundId'
=>
$Refund
->
id
,
'amount'
=>
$amount
,
'amount'
=>
$amount
,
'currency'
=>
$Currency
->
getCode
(),
'currency'
=>
$Currency
->
getCode
(),
'txId'
=>
$Transaction
->
getTxId
()
'txId'
=>
$Transaction
->
getTxId
()
]
]
)
)
);
);
...
@@ -483,12 +487,12 @@ public function refundPayment(Transaction $Transaction, $refundHash, $amount, $r
...
@@ -483,12 +487,12 @@ public function refundPayment(Transaction $Transaction, $refundHash, $amount, $r
'quiqqer/payment-stripe'
,
'quiqqer/payment-stripe'
,
'history.refund.error_status'
,
'history.refund.error_status'
,
[
[
'refundId'
=>
$Refund
->
id
,
'refundId'
=>
$Refund
->
id
,
'refundStatus'
=>
$Refund
->
status
,
'refundStatus'
=>
$Refund
->
status
,
'failureReason'
=>
$stripeFailureReason
,
'failureReason'
=>
$stripeFailureReason
,
'amount'
=>
$amount
,
'amount'
=>
$amount
,
'currency'
=>
$Currency
->
getCode
(),
'currency'
=>
$Currency
->
getCode
(),
'txId'
=>
$Transaction
->
getTxId
()
'txId'
=>
$Transaction
->
getTxId
()
]
]
)
)
);
);
...
@@ -506,7 +510,7 @@ public function refundPayment(Transaction $Transaction, $refundHash, $amount, $r
...
@@ -506,7 +510,7 @@ public function refundPayment(Transaction $Transaction, $refundHash, $amount, $r
*/
*/
protected
function
addOrderHistoryEntry
(
AbstractOrder
$Order
,
$msg
)
protected
function
addOrderHistoryEntry
(
AbstractOrder
$Order
,
$msg
)
{
{
$Order
->
addHistory
(
'Stripe :: '
.
$msg
);
$Order
->
addHistory
(
'Stripe :: '
.
$msg
);
$this
->
saveOrder
(
$Order
);
$this
->
saveOrder
(
$Order
);
}
}
...
@@ -521,9 +525,9 @@ protected function addOrderHistoryEntry(AbstractOrder $Order, $msg)
...
@@ -521,9 +525,9 @@ protected function addOrderHistoryEntry(AbstractOrder $Order, $msg)
*/
*/
protected
function
throwStripeException
(
$errorCode
=
self
::
ERROR_GENERAL
,
$exceptionAttributes
=
[])
protected
function
throwStripeException
(
$errorCode
=
self
::
ERROR_GENERAL
,
$exceptionAttributes
=
[])
{
{
$L
=
$this
->
getLocale
();
$L
=
$this
->
getLocale
();
$lg
=
'quiqqer/payment-stripe'
;
$lg
=
'quiqqer/payment-stripe'
;
$msg
=
$L
->
get
(
$lg
,
'exception.BasePayment.'
.
$errorCode
);
$msg
=
$L
->
get
(
$lg
,
'exception.BasePayment.'
.
$errorCode
);
$Exception
=
new
StripeException
(
$msg
);
$Exception
=
new
StripeException
(
$msg
);
$Exception
->
setAttributes
(
$exceptionAttributes
);
$Exception
->
setAttributes
(
$exceptionAttributes
);
...
...
This diff is collapsed.
Zum Erweitern klicken.
Vorschau
0%
Wiederholen
oder
Neue Datei anhängen
.
Abbrechen
You are about to add
0
people
to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Kommentar speichern
Abbrechen
Bitte
registrieren
oder
Anmelden
zum Kommentieren