src/Commands/ConvertCommand.php
/*
     * Maps a transaction to an array that later becomes a line in the CSV file.
     * Looking up the payment description for each capture is a bit nasty, but the information
     * can't be retrieved from the capture alone.
     */
Maps a transaction to an array that later becomes a line in the CSV file.
Looking up the payment description for each capture is a bit nasty, but the information
can't be retrieved from the capture alone.
Maps a transaction to an array that later becomes a line in the CSV file . Looking up the payment description for each capture is a bit nasty but the information can ' t be retrieved from the capture alone .
private function mapTransactionToArray(BaseResource $transaction, Settlement $settlement): array
    {
        $transactionArray[0] = $transaction->createdAt; 
        if ($transaction instanceof Payment) {
            $transactionArray[1] = $transaction->method;
        } elseif ($transaction instanceof Refund) {
            $transactionArray[1] = 'refund';
        } elseif ($transaction instanceof Chargeback) {
            $transactionArray[1] = 'chargeback';
        } else {
            $transactionArray[1] = null;
        }
        $transactionArray[2] = $transaction->amount->currency;
        if ($transaction instanceof Chargeback || $transaction instanceof Refund) {
            $transactionArray[3] = $transaction->amount->value * -1;
        } else {
            $transactionArray[3] = $transaction->amount->value;
        }
        $transactionArray[4] = $transaction->status ?? null;
        $transactionArray[5] = $transaction->id;
        if ($transaction instanceof Payment || $transaction instanceof Refund) {
            $transactionArray[6] = $transaction->description;
        } elseif ($transaction instanceof Capture) {
            $transactionArray[6] = 'Original payment: ' . $transaction->paymentId . ' - ' .
                $this->mollie->payments->get($transaction->paymentId)->description;
        } else {
            $transactionArray[6] = null;
        }
        $transactionArray[7] = $transaction->details->consumerName ?? null;
        $transactionArray[8] = $transaction->details->consumerAccount ?? null;
        $transactionArray[9] = $transaction->details->consumerBic ?? null;
        $transactionArray[10] = $transaction->settlementAmount->currency;
        $transactionArray[11] = $transaction->settlementAmount->value;
        $transactionArray[12] = $settlement->reference;
         refunded
        $transactionArray[13] = $transaction->amountRefunded->value ?? null;
        return $transactionArray;
    }
private function mapTransactionToArray ( BaseResource $ transaction , Settlement $ settlement ) : array { $ transactionArray [ 0 ] = $ transaction -> createdAt ; if ( $ transaction instanceof Payment ) { $ transactionArray [ 1 ] = $ transaction -> method ; } elseif ( $ transaction instanceof Refund ) { $ transactionArray [ 1 ] = 'refund' ; } elseif ( $ transaction instanceof Chargeback ) { $ transactionArray [ 1 ] = 'chargeback' ; } else { $ transactionArray [ 1 ] = null ; } $ transactionArray [ 2 ] = $ transaction -> amount -> currency ; if ( $ transaction instanceof Chargeback || $ transaction instanceof Refund ) { $ transactionArray [ 3 ] = $ transaction -> amount -> value * - 1 ; } else { $ transactionArray [ 3 ] = $ transaction -> amount -> value ; } $ transactionArray [ 4 ] = $ transaction -> status ?? null ; $ transactionArray [ 5 ] = $ transaction -> id ; if ( $ transaction instanceof Payment || $ transaction instanceof Refund ) { $ transactionArray [ 6 ] = $ transaction -> description ; } elseif ( $ transaction instanceof Capture ) { $ transactionArray [ 6 ] = 'Original payment: ' . $ transaction -> paymentId . ' - ' . $ this -> mollie -> payments -> get ( $ transaction -> paymentId ) -> description ; } else { $ transactionArray [ 6 ] = null ; } $ transactionArray [ 7 ] = $ transaction -> details -> consumerName ?? null ; $ transactionArray [ 8 ] = $ transaction -> details -> consumerAccount ?? null ; $ transactionArray [ 9 ] = $ transaction -> details -> consumerBic ?? null ; $ transactionArray [ 10 ] = $ transaction -> settlementAmount -> currency ; $ transactionArray [ 11 ] = $ transaction -> settlementAmount -> value ; $ transactionArray [ 12 ] = $ settlement -> reference ; $ transactionArray [ 13 ] = $ transaction -> amountRefunded -> value ?? null ; return $ transactionArray ; }
Maps a transaction to an array that later becomes a line in the CSV file.
Maps a transaction to an array that later becomes a line in the CSV file .
// todo receive more details about chargebacks // Date // todo format date // Payment Method // Currency // Amount // Status // ID // Description // Consumer Name // Consumer Bank Account // Consumer BIC // Settlement Currency // Settlement Amount // Settlement Reference // Amount refunded