Example #1
0
 /**
  * @param Payment $payment
  * @return Payment
  */
 public function signPayment(Payment $payment)
 {
     $payment->setSkinCode($this->context->getSkinCode());
     $payment->setMerchantAccount($this->context->getMerchantAccount());
     if ($this->context->isGaTrackingEnabled()) {
         $payment = GaTracking::addTrackingParameters($payment);
     }
     // sign shopper if is not null
     $shopper = $payment->getShopper();
     if ($shopper) {
         $signedShopper = $this->signShopper($shopper);
         $payment->setShopper($signedShopper);
     }
     // sign delivery address if is not null
     $deliveryAddress = $payment->getDeliveryAddress();
     if ($deliveryAddress) {
         $deliveryAddress = $this->signAddress($deliveryAddress);
         $payment->setDeliveryAddress($deliveryAddress);
     }
     // sign billing address if is not null
     $billingAddress = $payment->getBillingAddress();
     if ($billingAddress) {
         $billingAddress = $this->signAddress($billingAddress);
         $payment->setBillingAddress($billingAddress);
     }
     $signature = $this->context->getSignaturesGenerator()->generatePaymentSignature($payment);
     $payment->sign($signature);
     return $payment;
 }