thephpleague / omnipay-paypal

PayPal driver for the Omnipay PHP payment processing library
MIT License
295 stars 174 forks source link

This update to allow you to change the shipping address in the paypal express checkout #251

Open butta74 opened 2 years ago

butta74 commented 2 years ago

I ask if it is possible to make this change.

File \vendor\omnipay\paypal\src\Message\RestAuthorizeRequest.php Line 254 ADD:

    $shipping_address = $this->getShippingAddress();
    if ($shipping_address) {
        $data['transactions'][0]['item_list']["shipping_address"] = $shipping_address;
    }

File \vendor\omnipay\common\src\Common\Message\AbstractRequest.php -- Line 541 ADD:

/**
 * Custom Shipping Address
 */
public function getShippingAddress()
{
    return $this->getParameter('shipping_address');
}

/**
 * Set Shipping Address
 * @return $this
 */
public function setShippingAddress($value)
{
    return $this->setParameter('shipping_address', $value);
}

So in my controller I can call "purchase" method with custom shipping_addres :

$response = $this->gateway->purchase([ 'transactionId' => $myIdTransaction 'amount' => $tot_payment, 'currency' => $currency, 'returnUrl' => $myurl, 'cancelUrl' => $myCancelUrl, 'shipping_address' => [ "line1"=> "111 First Street", "city"=> "Saratoga", "country_code"=> "US", "postal_code"=> "95070", "state"=> "CA" ] ])->send();

It's work for me. Thanks Img1