Skip to content

Commit 0b26454

Browse files
vasikebojanz
authored andcommitted
Issue #2856209 by vasike, bojanz: PaymentStorage should provide a method to load a payment by its remote id
1 parent e1c691b commit 0b26454

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

modules/payment/src/PaymentStorage.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111
*/
1212
class PaymentStorage extends CommerceContentEntityStorage implements PaymentStorageInterface {
1313

14+
/**
15+
* {@inheritdoc}
16+
*/
17+
public function loadByRemoteId($remote_id) {
18+
$payments = $this->loadByProperties(['remote_id' => $remote_id]);
19+
$payment = reset($payments);
20+
21+
return $payment ?: NULL;
22+
}
23+
1424
/**
1525
* {@inheritdoc}
1626
*/

modules/payment/src/PaymentStorageInterface.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010
*/
1111
interface PaymentStorageInterface extends ContentEntityStorageInterface {
1212

13+
/**
14+
* Loads the payment for the given remote ID.
15+
*
16+
* @param string $remote_id
17+
* The remote ID.
18+
*
19+
* @return \Drupal\commerce_payment\Entity\PaymentInterface|null
20+
* The payment, or NULL if none found.
21+
*/
22+
public function loadByRemoteId($remote_id);
23+
1324
/**
1425
* Loads all payments for the given order.
1526
*

0 commit comments

Comments
 (0)