| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * MIT License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | namespace SprykerEco\Yves\Computop\Handler\ExpressCheckout; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Generated\Shared\Transfer\ComputopPayPalExpressPaymentTransfer; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Generated\Shared\Transfer\QuoteTransfer; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Spryker\Shared\Kernel\Transfer\TransferInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use SprykerEco\Client\Computop\ComputopClientInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use SprykerEco\Shared\Computop\ComputopConfig; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use SprykerEco\Yves\Computop\ComputopFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use SprykerEco\Yves\Computop\Converter\ConverterInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use SprykerEco\Yves\Computop\Dependency\Client\ComputopToQuoteClientInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use SprykerEco\Yves\Computop\Dependency\Client\ComputopToShipmentClientInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use SprykerEco\Yves\Computop\Mapper\Init\PrePlace\PayPalExpressToQuoteMapperInterface; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  | class ComputopPayPalExpressInitHandler implements ComputopPayPalExpressInitHandlerInterface | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |      * @var \SprykerEco\Yves\Computop\Converter\ConverterInterface | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |     protected $converter; | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |      * @var \SprykerEco\Yves\Computop\Dependency\Client\ComputopToQuoteClientInterface | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |     protected $quoteClient; | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |      * @var \SprykerEco\Client\Computop\ComputopClientInterface | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |     protected $computopClient; | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |      * @var \SprykerEco\Yves\Computop\Dependency\Client\ComputopToShipmentClientInterface | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |     protected $shipmentClient; | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |      * @var \SprykerEco\Yves\Computop\Mapper\Init\PrePlace\PayPalExpressToQuoteMapperInterface | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |     protected $payPalExpressToQuoteMapper; | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |      * @param \SprykerEco\Yves\Computop\Converter\ConverterInterface $converter | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |      * @param \SprykerEco\Yves\Computop\Dependency\Client\ComputopToQuoteClientInterface $quoteClient | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |      * @param \SprykerEco\Client\Computop\ComputopClientInterface $computopClient | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |      * @param \SprykerEco\Yves\Computop\Dependency\Client\ComputopToShipmentClientInterface $shipmentClient | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |      * @param \SprykerEco\Yves\Computop\Mapper\Init\PrePlace\PayPalExpressToQuoteMapperInterface $payPalExpressToQuoteMapper | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     public function __construct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         ConverterInterface $converter, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         ComputopToQuoteClientInterface $quoteClient, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         ComputopClientInterface $computopClient, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         ComputopToShipmentClientInterface $shipmentClient, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         PayPalExpressToQuoteMapperInterface $payPalExpressToQuoteMapper | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $this->converter = $converter; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $this->quoteClient = $quoteClient; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         $this->computopClient = $computopClient; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         $this->shipmentClient = $shipmentClient; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 66 |  |  |         $this->payPalExpressToQuoteMapper = $payPalExpressToQuoteMapper; | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |      * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |      * @param array $responseArray | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |      * @return \Generated\Shared\Transfer\QuoteTransfer | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |     public function handle(QuoteTransfer $quoteTransfer, array $responseArray): QuoteTransfer | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |         $responseTransfer = $this->converter->getResponseTransfer($responseArray); | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |         $quoteTransfer = $this->addPaymentToQuote($quoteTransfer, $responseTransfer); | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |         $quoteTransfer = $this->addPaymentSelectionToQuote($quoteTransfer); | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |         $quoteTransfer = $this->addShippingAddressToQuote($quoteTransfer); | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |         $quoteTransfer = $this->addBillingAddressToQuote($quoteTransfer); | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |         $quoteTransfer = $this->addCustomerToQuote($quoteTransfer); | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |         $quoteTransfer->setCheckoutConfirmed(true); | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |         $this->quoteClient->setQuote($quoteTransfer); | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |         return $quoteTransfer; | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |      * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |      * @param \Spryker\Shared\Kernel\Transfer\TransferInterface $responseTransfer | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |      * @return \Generated\Shared\Transfer\QuoteTransfer | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     protected function addPaymentToQuote(QuoteTransfer $quoteTransfer, TransferInterface $responseTransfer): QuoteTransfer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         if ($quoteTransfer->getPayment()->getComputopPayPalExpress() === null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |             $computopTransfer = new ComputopPayPalExpressPaymentTransfer(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |             $quoteTransfer->getPayment()->setComputopPayPalExpress($computopTransfer); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         /** @var \Generated\Shared\Transfer\ComputopPayPalExpressInitResponseTransfer $responseTransfer */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         $quoteTransfer->getPayment()->getComputopPayPalExpress()->setPayPalExpressInitResponse( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |             $responseTransfer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 110 |  |  |         return $quoteTransfer; | 
            
                                                                        
                                                                
            
                                    
            
            
                | 111 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 113 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 114 |  |  |      * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer | 
            
                                                                        
                            
            
                                    
            
            
                | 115 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 116 |  |  |      * @return \Generated\Shared\Transfer\QuoteTransfer | 
            
                                                                        
                            
            
                                    
            
            
                | 117 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 118 |  |  |     protected function addShippingAddressToQuote(QuoteTransfer $quoteTransfer): QuoteTransfer | 
            
                                                                        
                            
            
                                    
            
            
                | 119 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 120 |  |  |         $payPalInitResponseTransfer = $quoteTransfer->getPayment()->getComputopPayPalExpress()->getPayPalExpressInitResponse(); | 
            
                                                                        
                            
            
                                    
            
            
                | 121 |  |  |         if ($payPalInitResponseTransfer->getAddressStreet() === null) { | 
            
                                                                        
                            
            
                                    
            
            
                | 122 |  |  |             return $quoteTransfer; | 
            
                                                                        
                            
            
                                    
            
            
                | 123 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 125 |  |  |         $quoteTransfer = $this->shipmentClient->expandQuoteWithShipmentGroups($quoteTransfer); | 
            
                                                                        
                            
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 127 |  |  |         return $this | 
            
                                                                        
                            
            
                                    
            
            
                | 128 |  |  |             ->payPalExpressToQuoteMapper | 
            
                                                                        
                            
            
                                    
            
            
                | 129 |  |  |             ->mapAddressFromComputopPayPalExpressInitResponseToQuote($payPalInitResponseTransfer, $quoteTransfer); | 
            
                                                                        
                            
            
                                    
            
            
                | 130 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 131 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 132 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 133 |  |  |      * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer | 
            
                                                                        
                            
            
                                    
            
            
                | 134 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 135 |  |  |      * @return \Generated\Shared\Transfer\QuoteTransfer | 
            
                                                                        
                            
            
                                    
            
            
                | 136 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     protected function addBillingAddressToQuote(QuoteTransfer $quoteTransfer): QuoteTransfer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |         $payPalInitResponseTransfer = $quoteTransfer->getPayment()->getComputopPayPalExpress()->getPayPalExpressInitResponse(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |         if ($payPalInitResponseTransfer->getBillingAddressStreet() === null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |             return $quoteTransfer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 144 |  |  |         return $this->payPalExpressToQuoteMapper->mapBillingAddressFromComputopPayPalExpressInitResponseToQuote($quoteTransfer, $payPalInitResponseTransfer); | 
            
                                                                        
                                                                
            
                                    
            
            
                | 145 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 146 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 147 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 148 |  |  |      * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer | 
            
                                                                        
                            
            
                                    
            
            
                | 149 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 150 |  |  |      * @return \Generated\Shared\Transfer\QuoteTransfer | 
            
                                                                        
                            
            
                                    
            
            
                | 151 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 152 |  |  |     protected function addCustomerToQuote(QuoteTransfer $quoteTransfer): QuoteTransfer | 
            
                                                                        
                            
            
                                    
            
            
                | 153 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 154 |  |  |         if (!$quoteTransfer->getCustomer()->getIsGuest()) { | 
            
                                                                        
                            
            
                                    
            
            
                | 155 |  |  |             return $quoteTransfer; | 
            
                                                                        
                            
            
                                    
            
            
                | 156 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 157 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 158 |  |  |         $payPalInitResponseTransfer = $quoteTransfer | 
            
                                                                        
                            
            
                                    
            
            
                | 159 |  |  |             ->getPayment() | 
            
                                                                        
                            
            
                                    
            
            
                | 160 |  |  |             ->getComputopPayPalExpress() | 
            
                                                                        
                            
            
                                    
            
            
                | 161 |  |  |             ->getPayPalExpressInitResponse(); | 
            
                                                                        
                            
            
                                    
            
            
                | 162 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 163 |  |  |         return $this->payPalExpressToQuoteMapper->mapCustomerFromComputopPayPalExpressInitResponseToQuote($quoteTransfer, $payPalInitResponseTransfer); | 
            
                                                                        
                            
            
                                    
            
            
                | 164 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 166 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 167 |  |  |      * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer | 
            
                                                                        
                            
            
                                    
            
            
                | 168 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 169 |  |  |      * @return \Generated\Shared\Transfer\QuoteTransfer | 
            
                                                                        
                            
            
                                    
            
            
                | 170 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |     protected function addPaymentSelectionToQuote(QuoteTransfer $quoteTransfer): QuoteTransfer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |         $quoteTransfer->getPayment()->setPaymentSelection(ComputopConfig::PAYMENT_METHOD_PAY_PAL_EXPRESS); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |         $handler = (new ComputopFactory())->createComputopPaymentHandler(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 176 |  |  |         return $handler->addPaymentToQuote($quoteTransfer); | 
            
                                                                        
                                                                
            
                                    
            
            
                | 177 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 178 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 179 |  |  |  | 
            
                        
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths