- /**
- * Add link between payment token and order payment.
- *
- * @param int $paymentTokenId
- * @param int $orderPaymentId
- * @return bool
- */
- public function addLinkToOrderPayment($paymentTokenId, $orderPaymentId)
- {
- $connection = $this->getConnection();
-
- $select = $connection->select()
- ->from($this->getTable(InstallSchema::ORDER_PAYMENT_TO_PAYMENT_TOKEN_TABLE))
- ->where('order_payment_id = ?', (int) $orderPaymentId)
- ->where('payment_token_id =?', (int) $paymentTokenId);
-
- if (!empty($connection->fetchRow($select))) {
- return true;
- }
-
- return 1 === $connection->insert(
- $this->getTable(InstallSchema::ORDER_PAYMENT_TO_PAYMENT_TOKEN_TABLE),
- ['order_payment_id' => (int) $orderPaymentId, 'payment_token_id' => (int) $paymentTokenId]
- );
- }