Пример #1
0
 /**
  * @param \Generated\Shared\Transfer\PayonePaymentTransfer $paymentTransfer
  *
  * @return \Orm\Zed\Payone\Persistence\SpyPaymentPayone
  */
 protected function savePayment(PayonePaymentTransfer $paymentTransfer)
 {
     $payment = new SpyPaymentPayone();
     $payment->fromArray($paymentTransfer->toArray());
     if ($payment->getReference() === null) {
         $orderEntity = $payment->getSpySalesOrder();
         $payment->setReference($this->config->generatePayoneReference($paymentTransfer, $orderEntity));
     }
     $payment->save();
     return $payment;
 }
Пример #2
0
 /**
  * @param array $orderItems
  * @param \Orm\Zed\Sales\Persistence\SpySalesOrder $orderEntity
  * @param \Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject $data
  *
  * @return array Array
  */
 public function run(array $orderItems, SpySalesOrder $orderEntity, ReadOnlyArrayObject $data)
 {
     $payoneRefundTransfer = new PayoneRefundTransfer();
     $orderTransfer = new OrderTransfer();
     $orderTransfer->fromArray($orderEntity->toArray(), true);
     $refundTransfer = $this->getFactory()->getRefundFacade()->calculateRefund($orderItems, $orderEntity);
     $payoneRefundTransfer->setAmount($refundTransfer->getAmount() * -1);
     $paymentPayoneEntity = $orderEntity->getSpyPaymentPayones()->getFirst();
     $payonePaymentTransfer = new PayonePaymentTransfer();
     $payonePaymentTransfer->fromArray($paymentPayoneEntity->toArray(), true);
     $payoneRefundTransfer->setPayment($payonePaymentTransfer);
     $payoneRefundTransfer->setUseCustomerdata(PayoneApiConstants::USE_CUSTOMER_DATA_YES);
     $narrativeText = $this->getFactory()->getConfig()->getNarrativeText($orderItems, $orderEntity, $data);
     $payoneRefundTransfer->setNarrativeText($narrativeText);
     $this->getFacade()->refundPayment($payoneRefundTransfer);
     return [];
 }
Пример #3
0
 /**
  * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
  *
  * @return \Generated\Shared\Transfer\PayonePaymentTransfer
  */
 protected function getPayment(OrderTransfer $orderTransfer)
 {
     $payment = $this->queryContainer->getPaymentByOrderId($orderTransfer->getIdSalesOrder())->findOne();
     $paymentDetail = $payment->getSpyPaymentPayoneDetail();
     $paymentDetailTransfer = new PaymentDetailTransfer();
     $paymentDetailTransfer->fromArray($paymentDetail->toArray(), true);
     $paymentTransfer = new PayonePaymentTransfer();
     $paymentTransfer->fromArray($payment->toArray(), true);
     $paymentTransfer->setPaymentDetail($paymentDetailTransfer);
     return $paymentTransfer;
 }
Пример #4
0
 /**
  * @return void
  */
 public function ppRefundAction()
 {
     $order = $this->getOrder();
     $payment = new PayonePaymentTransfer();
     $payment->setTransactionId(PayoneApiConstants::TEST_TRANSACTION_ID);
     $payment->setPaymentMethod(PayoneApiConstants::PAYMENT_METHOD_PAYPAL);
     $capture = new CaptureTransfer();
     $capture->setPayment($payment);
     $capture->setAmount($order->getTotals()->getGrandTotal());
     $result = $this->getFacade()->capture($capture);
     dump($result);
     die;
 }
Пример #5
0
 /**
  * @param \Generated\Shared\Transfer\PayonePaymentTransfer $payonePaymentTransfer
  *
  * @return \Generated\Shared\Transfer\PayoneAuthorizationCheckResponseTransfer
  */
 public function getAuthorizationResponse(PayonePaymentTransfer $payonePaymentTransfer)
 {
     $response = new PayoneAuthorizationCheckResponseTransfer();
     $paymentEntity = $this->findPaymentByTransactionId($payonePaymentTransfer->getTransactionId());
     // no payment - no success - but: what if auth call was successful but
     // exception occurred....?
     if (!$paymentEntity) {
         $response->setIsSuccess(false);
         // @todo define customer display message
         //$response->setCustomerErrorMessage($customerErrorMessage);
         return $response;
     }
     $apiLogEntity = $this->findApiLog($paymentEntity, $payonePaymentTransfer->getAuthorizationType());
     // no transaction id means it was not updated cause payment failed (or exception after call...)
     // but we should/may have api log with response
     if (!$paymentEntity->getTransactionId()) {
         $response->setIsSuccess(false);
         if ($apiLogEntity) {
             $response->setCustomerErrorMessage($apiLogEntity->getErrorMessageUser());
         } else {
             // @todo define customer display message
             //$response->setCustomerErrorMessage($customerErrorMessage);
         }
         return $response;
     }
     // we have transaction id, check api log. if we do not have api log entity we can not
     // say if it is a redirect! could check payment method.. cc/paypal/ideal... is dirty
     // what to do in this case
     if (!$apiLogEntity) {
         $response->setIsSuccess(false);
         // @todo define customer display message
         //$response->setCustomerErrorMessage($customerErrorMessage);
         return $response;
     }
     // we have transaction id in payment and api log
     if ($apiLogEntity->getStatus() === PayoneApiConstants::RESPONSE_TYPE_APPROVED || $apiLogEntity->getStatus() === PayoneApiConstants::RESPONSE_TYPE_REDIRECT) {
         $response->setIsSuccess(true);
         $response->setRequest($apiLogEntity->getRequest());
         if ($apiLogEntity->getStatus() === PayoneApiConstants::RESPONSE_TYPE_REDIRECT) {
             $response->setIsRedirect(true);
             $response->setRedirectUrl($apiLogEntity->getRedirectUrl());
         }
     } else {
         $response->setIsSuccess(false);
         $response->setErrorCode($apiLogEntity->getErrorCode());
         $response->setCustomerErrorMessage($apiLogEntity->getErrorMessageUser());
         $response->setInternalErrorMessage($apiLogEntity->getErrorMessageInternal());
     }
     return $response;
 }