/** * @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()); if ($info->getPayoneFinancingType() == Payone_Api_Enum_FinancingType::KLS) { $configPaymentMethodId = $info->getPayoneConfigPaymentMethodId(); $paymentConfig = $paymentMethod->getConfigPayment(); $payData = new Payone_Api_Request_Parameter_Paydata_Paydata(); $payData->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(array('key' => 'klsid', 'data' => $info->getPayoneKlarnaCampaignCode()))); $payment->setPaydata($payData); } $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(); $sType = false; $aPostPayment = Mage::app()->getRequest()->getPost('payment'); if ($aPostPayment && array_key_exists('payone_wallet_type', $aPostPayment)) { $sType = $aPostPayment['payone_wallet_type']; } else { $sType = Payone_Api_Enum_WalletType::PAYPAL_EXPRESS; } $payment->setWallettype($sType); $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); } } } elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_CreditcardIframe) { $payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_CreditCardIframe(); $isRedirect = true; } elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Barzahlen) { $payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_Barzahlen(); $payment->setApiVersion(); $payment->setCashtype(); } 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; }
/** * @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(); $bankaccount = $info->getPayoneAccountNumber(); $bankcode = $info->getPayoneBankCode(); $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) && !empty($bic)) { $payment->setIban(strtoupper($iban)); $payment->setBic(strtoupper($bic)); // ensure bic and iban are sent uppercase } elseif (!empty($bankaccount) && !empty($bankcode)) { $payment->setBankaccount($bankaccount); $payment->setBankcode($bankcode); } 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_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(); $payment->setWallettype($this->_getWalletType()); $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)) { $payment->setIban(strtoupper($iban)); if (!empty($bic)) { $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); } } } elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_CreditcardIframe) { $payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_CreditCardIframe(); $isRedirect = true; } elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Barzahlen) { $payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_Barzahlen(); $payment->setApiVersion(); $payment->setCashtype(); } elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Ratepay) { $payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_RatePay(); $payment->setFinancingtype(); $payment->setApiVersion(); $checkoutSession = $this->getFactory()->getSingletonCheckoutSession(); $mandateStatus = $checkoutSession->getRatePayFingerprint(); $payData = new Payone_Api_Request_Parameter_Paydata_Paydata(); $payData->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(array('key' => 'customer_allow_credit_inquiry', 'data' => 'yes'))); $payData->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(array('key' => 'device_token', 'data' => $checkoutSession->getRatePayFingerprint()))); $payData->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(array('key' => 'shop_id', 'data' => $info->getPayoneRatepayShopId()))); $payment->setPaydata($payData); $birthdayDate = $info->getPayoneCustomerDob(); if (empty($birthdayDate)) { $birthdayDate = $this->getOrder()->getCustomerDob(); } $payment->setBirthday($this->formatBirthday($birthdayDate)); $telephone = $info->getPayoneCustomerTelephone(); if (empty($telephone)) { $telephone = $this->getOrder()->getBillingAddress()->getTelephone(); } $payment->setTelephonenumber($telephone); } elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_Payolution) { $payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_Payolution(); $payment->setApiVersion(); $payment->setFinancingtype($info->getPayonePayolutionType()); $payment->setWorkorderid($info->getPayoneWorkorderid()); $payment->setIban(strtoupper($info->getPayonePayolutionIban())); $payment->setBic(strtoupper($info->getPayonePayolutionBic())); $checkoutSession = $this->getFactory()->getSingletonCheckoutSession(); $payment->setWorkorderid($checkoutSession->getPayoneWorkorderId()); $info->setPayoneWorkorderId($checkoutSession->getPayoneWorkorderId()); if ((bool) $info->getPayoneIsb2b() === true) { $payData = new Payone_Api_Request_Parameter_Paydata_Paydata(); $payData->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(array('key' => 'b2b', 'data' => 'yes'))); $payData->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(array('key' => 'company_trade_registry_number', 'data' => $info->getPayoneTradeRegistryNumber()))); $payment->setPaydata($payData); } else { $birthdayDate = $info->getPayoneCustomerDob(); if (empty($birthdayDate)) { $birthdayDate = $this->getOrder()->getCustomerDob(); } if ($birthdayDate) { $payment->setBirthday($this->formatBirthday($birthdayDate)); } } } 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; }