Set delivery address API Pagseguro

4

I have to pre-define the delivery address of the pagseguro in my code PHP . The problem is that I have tried and I can not, what I can do is just set the billing address. My code:

$paymentRequest = new PagSeguroPaymentRequest();

        $paymentRequest->setCurrency("BRL");

        $address = new PagSeguroAddress();

        /* Define o valor do frete */
        $shipping = new PagSeguroShipping();
        $type = new PagSeguroShippingType(3);
        $shipping->setType($type);
        $shipping->setCost($frete);


        $address->setStreet('Av. Brig. Faria Lima');

        /* Informando o número do logradouro */
        $address->setNumber('1384');

        /* Informando o complemento do logradouro */
        $address->setComplement('apto. 114');  //

        /* Informando o bairro do logradouro */
        $address->setDistrict('Jardim Paulistano');

        /* Informando o bairro a cidade */
        $address->setCity('São Paulo');

        /* Informando o bairro o estado */
        $address->setState('SP');

        /* Informando o bairro o país */
        $address->setCountry('BRA');

        $shipping->setAddress($address);

        $paymentRequest->setShipping($shipping);

This code is only setting the billing, but the delivery code it can for me to type CEP .

    
asked by anonymous 13.11.2015 / 15:58

1 answer

5

Use setShippingAddress

$shipping->setShippingAddress(  
  '01452002',  
  'Av. Brig. Faria Lima',  
  '1384',  
  'apto. 114',  
  'Jardim Paulistano',  
  'São Paulo',  
  'SP',  
  'BRA'  
); 

Complete code:

$paymentRequest = new PagSeguroPaymentRequest();

$paymentRequest->setCurrency("BRL");

$address = new PagSeguroAddress();

/* Define o valor do frete */
$shipping = new PagSeguroShipping();
$type = new PagSeguroShippingType(3);
$shipping->setType($type);
$shipping->setCost($frete);
$shipping->setShippingAddress(  
  '01452002',  
  'Av. Brig. Faria Lima',  
  '1384',  
  'apto. 114',  
  'Jardim Paulistano',  
  'São Paulo',  
  'SP',  
  'BRA'  
); 

$address->setStreet('Av. Brig. Faria Lima');

/* Informando o número do logradouro */
$address->setNumber('1384');

/* Informando o complemento do logradouro */
$address->setComplement('apto. 114');  //

/* Informando o bairro do logradouro */
$address->setDistrict('Jardim Paulistano');

/* Informando o bairro a cidade */
$address->setCity('São Paulo');

/* Informando o bairro o estado */
$address->setState('SP');

/* Informando o bairro o país */
$address->setCountry('BRA');

$shipping->setAddress($address);

$paymentRequest->setShipping($shipping);
    
17.11.2015 / 17:55