Skip to content
Snippets Groups Projects

Issue #3486635 by Aerzas: Use transaction data when creating payment if available

1 file
+ 5
1
Compare changes
  • Side-by-side
  • Inline
@@ -161,11 +161,15 @@ class DatatransBase extends PaymentGatewayBase implements SupportsRefundsInterfa
@@ -161,11 +161,15 @@ class DatatransBase extends PaymentGatewayBase implements SupportsRefundsInterfa
}
}
if (!$payment) {
if (!$payment) {
 
$transaction_amount = $transaction_data['detail']['settle']['amount'] ?? $transaction_data['detail']['authorize']['amount'] ?? NULL;
$payment_storage = $this->entityTypeManager->getStorage('commerce_payment');
$payment_storage = $this->entityTypeManager->getStorage('commerce_payment');
// Create a payment if there is none yet.
// Create a payment if there is none yet.
// @todo: Support non-complete payment amount for new payment?
// @todo: Support non-complete payment amount for new payment?
$payment = $payment_storage->create([
$payment = $payment_storage->create([
'amount' => $order->getTotalPrice(),
'amount' => new Price(
 
isset($transaction_amount) ? ($transaction_amount / 100) : $order->getTotalPrice()->getAmount(),
 
$transaction_data['currency']
 
),
'payment_gateway' => $this->parentEntity->id(),
'payment_gateway' => $this->parentEntity->id(),
'order_id' => $order->id(),
'order_id' => $order->id(),
'remote_id' => $transaction_data['transactionId'],
'remote_id' => $transaction_data['transactionId'],
Loading