protected function getAddressData($type = 'Billing')
    {
        $card = $this->getCard();

        // Mapping is Sage Pay name => Omnipay Name

        $mapping = [
            'Firstnames'    => 'FirstName',
            'Surname'       => 'LastName',
            'Address1'      => 'Address1',
            'Address2'      => 'Address2',
            'City'          => 'City',
            'PostCode'      => 'Postcode',
            'State'         => 'State',
            'Country'       => 'Country',
            'Phone'         => 'Phone',
        ];

        $data = [];

        foreach ($mapping as $sagepayName => $omnipayName) {
            $data[$sagepayName] = call_user_func([$card, 'get' . $type . $omnipayName]);
        }

        // The state must not be set for non-US countries.

        if ($data['Country'] !== 'US') {
            $data['State'] = '';
        }

        return $data;
    }
protected function getAddressData($type = 'Billing')
    {
        $card = $this->getCard();

        // Mapping is Sage Pay name => Omnipay Name

        $mapping = [
            'Firstnames'    => 'FirstName',
            'Surname'       => 'LastName',
            'Address1'      => 'Address1',
            'Address2'      => 'Address2',
            'City'          => 'City',
            'PostCode'      => 'Postcode',
            'State'         => 'State',
            'Country'       => 'Country',
            'Phone'         => 'Phone',
        ];

        $data = [];

        foreach ($mapping as $sagepayName => $omnipayName) {
            $data[$sagepayName] = call_user_func([$card, 'get' . $type . $omnipayName]);
        }

        // The state must not be set for non-US countries.

        if ($data['Country'] !== 'US') {
            $data['State'] = '';
        }

        return $data;
    }
protected function getAddressData ( $ type = 'Billing' ) { $ card = $ this -> getCard ( ) ; // Mapping is Sage Pay name => Omnipay Name $ mapping = [ 'Firstnames' => 'FirstName' , 'Surname' => 'LastName' , 'Address1' => 'Address1' , 'Address2' => 'Address2' , 'City' => 'City' , 'PostCode' => 'Postcode' , 'State' => 'State' , 'Country' => 'Country' , 'Phone' => 'Phone' , ] ; $ data = [ ] ; foreach ( $ mapping as $ sagepayName => $ omnipayName ) { $ data [ $ sagepayName ] = call_user_func ( [ $ card , 'get' . $ type . $ omnipayName ] ) ; } // The state must not be set for non-US countries. if ( $ data [ 'Country' ] !== 'US' ) { $ data [ 'State' ] = '' ; } return $ data ; }
Get either the billing or the shipping address from
the card object, mapped to Sage Pay field names.

@param string $type 'Billing' or 'Shipping'
@return array
Get either the billing or the shipping address from the card object mapped to Sage Pay field names .