/** * Tries to accept transaction by sending user's PIN code using API * * @param string $transactionKey * @param int|Paysera_WalletApi_Entity_WalletIdentifier|string $payer * @param string $pin * @param Paysera_WalletApi_Entity_FundsSource[] $fundsSources * * @return Paysera_WalletApi_Entity_Transaction * */ public function acceptTransactionUsingPin($transactionKey, $payer, $pin, $fundsSources = array()) { Paysera_WalletApi_Util_Assert::isScalar($transactionKey); Paysera_WalletApi_Util_Assert::isScalar($pin); $content = $this->mapper->encodePin($pin); if (count($fundsSources) > 0) { $content = array_merge($this->mapper->encodeFundsSources($fundsSources)); } if ($payer instanceof Paysera_WalletApi_Entity_WalletIdentifier) { $payer->validate(); $content = array_merge($content, $this->mapper->encodePayer($payer)); $uri = 'transaction/' . $transactionKey . '/reserve'; } else { Paysera_WalletApi_Util_Assert::isId($payer); $uri = 'transaction/' . $transactionKey . '/reserve/' . (string) $payer; } $responseData = $this->put($uri, $content); return $this->mapper->decodeTransaction($responseData); }
/** * Decodes wallet identifier object from array * * @param array $data * * @return Paysera_WalletApi_Entity_WalletIdentifier */ public function decodeWalletIdentifier($data) { $walletIdentifier = new Paysera_WalletApi_Entity_WalletIdentifier(); if (is_int($data)) { $walletIdentifier->setId($data); } elseif (is_array($data)) { if (isset($data['id'])) { $walletIdentifier->setId($data['id']); } if (isset($data['email'])) { $walletIdentifier->setEmail($data['email']); } if (isset($data['phone'])) { $walletIdentifier->setPhone($data['phone']); } } return $walletIdentifier; }