/** * Build the transaction request object * * @param Varien_Object $payment * @return Shift4_Shift4Payment_Model_ApiRequest */ protected function _buildRequest(Varien_Object $payment) { $order = $payment->getOrder(); $this->setStore($order->getStoreId()); $frcArray = $this->_requestTypeToFrc($payment->getShift4RequestType()); $request = $this->_getRequest()->setData('functionrequestcode', $frcArray['frc'])->setData('saleflag', $frcArray['saleFlag']); if ($order && $order->getIncrementId()) { $request->setData('invoice', $order->getIncrementId()); } if ($payment->getAmount()) { $request->setData('primaryamount', $payment->getAmount(), 2); } $request->setData('apioptions', $request->getData('apioptions') . ',ALLOWPARTIALAUTH'); if (!empty($order)) { $billingAddress = $order->getBillingAddress(); $items = $order->getAllItems(); $products = array(); $qty = array(); foreach ($items as $itemId => $item) { $qty = $item->getQtyToInvoice(); $products[$item->getName()] = $qty; } $productNotes = ''; $productDescriptor = array(); foreach ($products as $name => $quantity) { $msg = $quantity . ' x ' . $name; $productNotes .= $msg . '<br />'; $productDescriptor[] = $msg; } for ($i = 0; $i < 4; $i++) { $productDescriptor[] = ''; } $shippingPostCode = $order->getShippingAddress()->getPostcode(); if (!empty($billingAddress)) { $request->setData('customername', $billingAddress->getFirstname() . ' ' . $billingAddress->getLastname())->setData('customerreference', $billingAddress->getCustomerId())->setData('streetaddress', $billingAddress->getStreet(1))->setData('zipcode', $billingAddress->getPostcode())->setData('destinationzipcode', $shippingPostCode); } $request->setData('notes', $productNotes)->setData('productdescriptor1', $productDescriptor[0])->setData('productdescriptor2', $productDescriptor[1])->setData('productdescriptor3', $productDescriptor[2])->setData('productdescriptor4', $productDescriptor[3]); if ($order->getBaseTaxAmount() > 0) { $request->setData('taxindicator', 'Y'); $request->setData('taxamount', $order->getBaseTaxAmount()); } } if ($payment->getCcNumberEnc()) { $request->setData('uniqueid', $payment->getCcNumberEnc())->setData('cardtype', $payment->getCcType())->setData('expirationmonth', $payment->getCcExpMonth())->setData('expirationyear', $payment->getCcExpYear()); } return $request; }