Bitpay\Client\Client::getPayout PHP Method

getPayout() public method

public getPayout ( $payoutId )
    public function getPayout($payoutId)
    {
        $request = $this->createNewRequest();
        $request->setMethod(Request::METHOD_GET);
        $request->setPath(sprintf('payouts/%s?token=%s', $payoutId, $this->token->getToken()));
        $this->addIdentityHeader($request);
        $this->addSignatureHeader($request);
        $this->request = $request;
        $this->response = $this->sendRequest($this->request);
        $body = json_decode($this->response->getBody(), true);
        if (empty($body['data'])) {
            throw new \Exception('Error with request: no data returned');
        }
        $data = $body['data'];
        $payout = new \Bitpay\Payout();
        $payout->setId($data['id'])->setAccountId($data['account'])->setStatus($data['status'])->setCurrency(new \Bitpay\Currency($data['currency']))->setRate(@$data['rate'])->setAmount($data['amount'])->setBtcAmount(@$data['btc'])->setPricingMethod(@$data['pricingMethod'])->setReference(@$data['reference'])->setNotificationEmail(@$data['notificationEmail'])->setNotificationUrl(@$data['notificationURL'])->setRequestDate($data['requestDate'])->setEffectiveDate($data['effectiveDate'])->setResponseToken($data['token']);
        array_walk($data['instructions'], function ($value, $key) use(&$payout) {
            $instruction = new \Bitpay\PayoutInstruction();
            $instruction->setId($value['id'])->setLabel($value['label'])->setAddress($value['address'])->setStatus($value['status'])->setAmount($value['amount'])->setBtc($value['btc']);
            array_walk($value['transactions'], function ($value, $key) use(&$instruction) {
                $transaction = new \Bitpay\PayoutTransaction();
                $transaction->setTransactionId($value['txid'])->setAmount($value['amount'])->setDate($value['date']);
                $instruction->addTransaction($transaction);
            });
            $payout->addInstruction($instruction);
        });
        return $payout;
    }