Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit c6d3765

Browse files
author
Jens Schulze
committed
fix(Payment): add missing type for payment transactions
1 parent 7fa6b26 commit c6d3765

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

src/Model/Common/AbstractJsonDeserializeObject.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ protected function isDeserializable($value)
126126
*/
127127
protected function isDeserializableType($type)
128128
{
129-
if (!is_string($type)) {
129+
if (!is_string($type) || empty($type)) {
130130
return false;
131131
}
132132
return $this->hasInterface($type, static::JSON_DESERIALIZE_INTERFACE);
133133
}
134134

135135
protected function isTypeableType($type)
136136
{
137-
if (!is_string($type)) {
137+
if (!is_string($type) || empty($type)) {
138138
return false;
139139
}
140140
return $this->hasInterface($type, static::TYPEABLE_INTERFACE);

src/Model/Payment/Payment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function fieldDefinitions()
7878
'paymentMethodInfo' => [static::TYPE => '\Commercetools\Core\Model\Payment\PaymentMethodInfo'],
7979
'custom' => [static::TYPE => '\Commercetools\Core\Model\CustomField\CustomFieldObject'],
8080
'paymentStatus' => [static::TYPE => '\Commercetools\Core\Model\Payment\PaymentStatus'],
81-
'transactions' => [static::TYPE => ''],
81+
'transactions' => [static::TYPE => '\Commercetools\Core\Model\Payment\TransactionCollection'],
8282
'interfaceInteractions' => [
8383
static::TYPE => '\Commercetools\Core\Model\CustomField\CustomFieldObjectCollection'
8484
],

src/Model/Payment/Transaction.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
*/
2424
class Transaction extends JsonObject
2525
{
26+
const AUTHORIZATION = 'Authorization';
27+
const CANCEL_AUTHORIZATION = 'CancelAuthorization';
28+
const CHARGE = 'Charge';
29+
const REFUND = 'Refund';
30+
const CHARGE_BACK = 'Chargeback';
31+
2632
public function fieldDefinitions()
2733
{
2834
return [

src/Model/Payment/TransactionCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected function indexRow($offset, $row)
2525
if ($row instanceof Transaction) {
2626
$id = $row->getInteractionId();
2727
} else {
28-
$id = $row[static::INTERACTION_ID];
28+
$id = isset($row[static::INTERACTION_ID]) ? $row[static::INTERACTION_ID] : null;
2929
}
3030
$this->addToIndex(static::INTERACTION_ID, $offset, $id);
3131
}

0 commit comments

Comments
 (0)