bound_payment_id ) && 0 > $this->gross ); } /** * Checks if the payment was migrated from another platform. * * @author Vova Feldman (@svovaf) * @since 2.0.2 * * @return bool */ function is_migrated() { return ( 0 != $this->source ); } /** * @return bool */ private function has_presentment() { return is_object( $this->presentment ); } /** * @return float */ private function get_display_gross() { return $this->has_presentment() ? (float) $this->presentment->gross : (float) $this->gross; } /** * @return float */ private function get_display_vat() { return $this->has_presentment() ? (float) $this->presentment->vat : (float) $this->vat; } /** * @return string */ private function get_display_currency() { return $this->has_presentment() ? $this->presentment->currency : $this->currency; } /** * Returns the gross in this format: * `{symbol}{amount | 2 decimal digits} {currency | uppercase}` * * Examples: £9.99 GBP, -£9.99 GBP. * * @author Leo Fajardo (@leorw) * @since 2.3.0 * * @return string */ function formatted_gross() { $price = $this->get_display_gross() + $this->get_display_vat(); return ( ( $price < 0 ? '-' : '' ) . $this->get_symbol() . number_format( abs( $price ), 2, '.', ',' ) . ' ' . strtoupper( $this->get_display_currency() ) ); } /** * A map between supported currencies with their symbols. * * @var array */ static $CURRENCY_2_SYMBOL; /** * @author Leo Fajardo (@leorw) * @since 2.3.0 * * @return string */ private function get_symbol() { if ( ! isset( self::$CURRENCY_2_SYMBOL ) ) { // Lazy load. self::$CURRENCY_2_SYMBOL = array( self::CURRENCY_USD => '$', self::CURRENCY_GBP => '£', self::CURRENCY_EUR => '€', self::CURRENCY_ILS => '₪', self::CURRENCY_CAD => '$', self::CURRENCY_AUD => '$', self::CURRENCY_PLN => 'zł', ); } $currency = $this->get_display_currency(); return isset( self::$CURRENCY_2_SYMBOL[ $currency ] ) ? self::$CURRENCY_2_SYMBOL[ $currency ] : strtoupper( $currency ) . ' '; } }