/**
  * Map shop data to omnipay fields
  *
  * @param array $customData Usually user submitted data.
  *
  * @return array
  */
 protected function getGatewayData($customData)
 {
     $shipping = $this->order->getShippingAddress();
     $billing = $this->order->getBillingAddress();
     $numPayments = Payment::get()->filter(array('OrderID' => $this->order->ID))->count() - 1;
     $transactionId = $this->order->Reference . ($numPayments > 0 ? "-{$numPayments}" : '');
     return array_merge($customData, array('transactionId' => $transactionId, 'firstName' => $this->order->FirstName, 'lastName' => $this->order->Surname, 'email' => $this->order->Email, 'company' => $this->order->Company, 'billingAddress1' => $billing->Address, 'billingAddress2' => $billing->AddressLine2, 'billingCity' => $billing->City, 'billingPostcode' => $billing->PostalCode, 'billingState' => $billing->State, 'billingCountry' => $billing->Country, 'billingPhone' => $billing->Phone, 'shippingAddress1' => $shipping->Address, 'shippingAddress2' => $shipping->AddressLine2, 'shippingCity' => $shipping->City, 'shippingPostcode' => $shipping->PostalCode, 'shippingState' => $shipping->State, 'shippingCountry' => $shipping->Country, 'shippingPhone' => $shipping->Phone));
 }
 /**
  * Map shop data to omnipay fields
  *
  * @param array $customData Usually user submitted data.
  *
  * @return array
  */
 protected function getGatewayData($customData)
 {
     $shipping = $this->order->getShippingAddress();
     $billing = $this->order->getBillingAddress();
     $numPayments = Payment::get()->where(array('"OrderID" = ?' => $this->order->ID))->count();
     $numPayments--;
     $transactionId = strtoupper(i18n::get_lang_from_locale(i18n::get_locale())) . $this->order->Reference . ($numPayments > 0 ? '-' . $numPayments : '');
     if (Director::isDev()) {
         $transactionId .= Member::currentUser() ? '-' . Member::currentUserID() : '';
     }
     return array_merge($customData, array('transactionId' => $transactionId, 'firstName' => $this->order->FirstName, 'lastName' => $this->order->Surname, 'email' => $this->order->Email, 'company' => $this->order->Company, 'billingAddress1' => $billing->Address, 'billingAddress2' => $billing->AddressLine2, 'billingCity' => $billing->City, 'billingPostcode' => $billing->PostalCode, 'billingState' => $billing->State, 'billingCountry' => $billing->Country, 'billingPhone' => $billing->Phone, 'shippingAddress1' => $shipping->Address, 'shippingAddress2' => $shipping->AddressLine2, 'shippingCity' => $shipping->City, 'shippingPostcode' => $shipping->PostalCode, 'shippingState' => $shipping->State, 'shippingCountry' => $shipping->Country, 'shippingPhone' => $shipping->Phone));
 }
 /**
  * @throws ValidationException
  */
 public function setData(Order $order, array $data)
 {
     if (Member::currentUserID()) {
         return;
     }
     if (!Checkout::membership_required() && empty($data['Password'])) {
         return;
     }
     $factory = new ShopMemberFactory();
     $member = $factory->create($data);
     $member->write();
     $member->extend('onAfterMemberCreate');
     $member->logIn();
     if ($order->BillingAddressID) {
         $address = $order->getBillingAddress();
         $address->MemberID = $member->ID;
         $address->write();
         $member->DefaultBillingAddressID = $order->BillingAddressID;
     }
     if ($order->ShippingAddressID) {
         $address = $order->getShippingAddress();
         $address->MemberID = $member->ID;
         $address->write();
         $member->DefaultShippingAddressID = $order->ShippingAddressID;
     }
     if ($member->isChanged()) {
         $member->write();
     }
 }
 /**
  * Map shop data to omnipay fields
  * 
  * @param array $customData Usually user submitted data.
  * @return array
  */
 protected function getGatewayData($customData)
 {
     $shipping = $this->order->getShippingAddress();
     $billing = $this->order->getBillingAddress();
     return array_merge($customData, array('transactionId' => $this->order->Reference, 'firstName' => $this->order->FirstName, 'lastName' => $this->order->Surname, 'email' => $this->order->Email, 'company' => $this->order->Company, 'billingAddress1' => $billing->Address, 'billingAddress2' => $billing->AddressLine2, 'billingCity' => $billing->City, 'billingPostcode' => $billing->PostalCode, 'billingState' => $billing->State, 'billingCountry' => $billing->Country, 'billingPhone' => $billing->Phone, 'shippingAddress1' => $shipping->Address, 'shippingAddress2' => $shipping->AddressLine2, 'shippingCity' => $shipping->City, 'shippingPostcode' => $shipping->PostalCode, 'shippingState' => $shipping->State, 'shippingCountry' => $shipping->Country, 'shippingPhone' => $shipping->Phone));
 }
 function __construct(Order $order, Address $address = null)
 {
     $this->order = $order;
     $this->address = $address ? $address : $order->getShippingAddress();
 }