Beispiel #1
0
 /**
  * @return Payone_Api_Request_Parameter_Authorization_PaymentMethod_Abstract
  */
 protected function mapPaymentParameters()
 {
     $payment = null;
     $paymentMethod = $this->getPaymentMethod();
     $info = $paymentMethod->getInfoInstance();
     $isRedirect = false;
     if ($paymentMethod instanceof Payone_Core_Model_Payment_Method_CashOnDelivery) {
         $payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_CashOnDelivery();
         $payment->setShippingprovider(Payone_Api_Enum_Shippingprovider::DHL);
     } elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Creditcard) {
         $payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_CreditCard();
         // check if it is an adminorder and set ecommercemode to moto
         if ($this->getIsAdmin()) {
             $payment->setEcommercemode('moto');
         }
         $payment->setPseudocardpan($info->getPayonePseudocardpan());
         $isRedirect = true;
     } elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_OnlineBankTransfer) {
         $country = $this->getOrder()->getBillingAddress()->getCountry();
         $payoneOnlinebanktransferType = $info->getPayoneOnlinebanktransferType();
         $iban = $info->getPayoneSepaIban();
         $bic = $info->getPayoneSepaBic();
         $payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_OnlineBankTransfer();
         $payment->setBankcountry($country);
         $payment->setOnlinebanktransfertype($payoneOnlinebanktransferType);
         switch ($payoneOnlinebanktransferType) {
             case Payone_Api_Enum_OnlinebanktransferType::INSTANT_MONEY_TRANSFER:
             case Payone_Api_Enum_OnlinebanktransferType::GIROPAY:
                 if (!empty($iban) and !empty($bic)) {
                     $payment->setIban(strtoupper($iban));
                     $payment->setBic(strtoupper($bic));
                     // ensure bic and iban are sent uppercase
                 } else {
                     $payment->setBankaccount($info->getPayoneAccountNumber());
                     $payment->setBankcode($info->getPayoneBankCode());
                 }
                 break;
             case Payone_Api_Enum_OnlinebanktransferType::IDEAL:
             case Payone_Api_Enum_OnlinebanktransferType::EPS_ONLINE_BANK_TRANSFER:
                 $payment->setBankgrouptype($info->getPayoneBankGroup());
                 break;
             case Payone_Api_Enum_OnlinebanktransferType::POSTFINANCE_EFINANCE:
                 break;
             case Payone_Api_Enum_OnlinebanktransferType::POSTFINANCE_CARD:
                 break;
         }
         $isRedirect = true;
     } elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Financing) {
         $payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_Financing();
         $payment->setFinancingtype($info->getPayoneFinancingType());
         $isRedirect = true;
     } elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_SafeInvoice) {
         $payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_Financing();
         $payment->setFinancingtype($info->getPayoneSafeInvoiceType());
         if ($info->getPayoneSafeInvoiceType() == Payone_Api_Enum_FinancingType::BSV) {
             // BillSAFE is a redirect payment method, Klarna not
             $isRedirect = true;
         }
     } elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Wallet) {
         $payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_Wallet();
         // @comment currently hardcoded because there is no other Type
         $payment->setWallettype(Payone_Api_Enum_WalletType::PAYPAL_EXPRESS);
         $isRedirect = true;
     } elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_DebitPayment) {
         $payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_DebitPayment();
         $payment->setBankcountry($info->getPayoneBankCountry());
         $iban = $info->getPayoneSepaIban();
         $bic = $info->getPayoneSepaBic();
         if (!empty($iban) and !empty($bic)) {
             $payment->setIban(strtoupper($iban));
             $payment->setBic(strtoupper($bic));
             // ensure bic and iban are sent uppercase
         } else {
             $payment->setBankaccount($info->getPayoneAccountNumber());
             $payment->setBankcode($info->getPayoneBankCode());
         }
         $payment->setBankaccountholder($info->getPayoneAccountOwner());
         // for frontend orders set mandate identification if data provided in checkout session:
         if (!$this->getIsAdmin()) {
             $checkoutSession = $this->getFactory()->getSingletonCheckoutSession();
             $mandateStatus = $checkoutSession->getPayoneSepaMandateStatus();
             $mandateIdentification = $checkoutSession->getPayoneSepaMandateIdentification();
             if ($mandateStatus == Payone_Core_Model_Service_Management_ManageMandate::STATUS_PENDING and !empty($mandateIdentification)) {
                 $payment->setMandateIdentification($mandateIdentification);
             }
         }
     }
     if ($isRedirect === true) {
         $successurl = $this->helperUrl()->getSuccessUrl();
         $errorurl = $this->helperUrl()->getErrorUrl();
         $backurl = $this->helperUrl()->getBackUrl();
         $payment->setSuccessurl($successurl);
         $payment->setErrorurl($errorurl);
         $payment->setBackurl($backurl);
     }
     return $payment;
 }