コード例 #1
0
 /**
  * @param CreditCard $card
  * @param array $data
  * @return array
  */
 protected function addDataFromCard(CreditCard $card, array $data)
 {
     if ($card->getFirstName()) {
         $data['NAME.GIVEN'] = $card->getFirstName();
     }
     if ($card->getLastName()) {
         $data['NAME.FAMILY'] = $card->getLastName();
     }
     if ($card->getSalutation()) {
         $data['NAME.SALUTATION'] = $card->getSalutation();
     }
     if ($card->getTitle()) {
         $data['NAME.TITLE'] = $card->getTitle();
     }
     if ($card->getGender()) {
         $gender = $card->getGender();
         if (CreditCard::GENDER_MALE === $gender) {
             $data['NAME.SEX'] = 'M';
         } elseif (CreditCard::GENDER_FEMALE === $gender) {
             $data['NAME.SEX'] = 'F';
         } else {
             $data['NAME.SEX'] = strtoupper(substr($gender, 0, 1));
         }
     }
     if ($card->getBirthday()) {
         $data['NAME.BIRTHDATE'] = $card->getBirthday();
     }
     if ($card->getCompany()) {
         $data['NAME.COMPANY'] = $card->getCompany();
     }
     if ($card->getCountry()) {
         $data['ADDRESS.COUNTRY'] = $card->getCountry();
     }
     if ($card->getState()) {
         $data['ADDRESS.STATE'] = $card->getState();
     }
     if ($card->getCity()) {
         $data['ADDRESS.CITY'] = $card->getCity();
     }
     if ($card->getPostcode()) {
         $data['ADDRESS.ZIP'] = $card->getPostcode();
     }
     $street = '';
     if ($card->getAddress1()) {
         $street = $card->getAddress1();
     }
     if ($card->getAddress2()) {
         $street .= "\n" . $card->getAddress2();
     }
     $street = trim($street);
     if ($street) {
         $data['ADDRESS.STREET'] = $street;
     }
     if ($card->getEmail()) {
         $data['CONTACT.EMAIL'] = $card->getEmail();
     }
     if ($card->getPhone()) {
         $data['CONTACT.PHONE'] = $card->getPhone();
     }
     if ($card->getMobile()) {
         $data['CONTACT.MOBILE'] = $card->getMobile();
     }
     if ($card->getIdentificationDocumentType() and $card->getIdentificationDocumentNumber()) {
         $data['CUSTOMER.IDENTIFICATION.PAPER'] = $card->getIdentificationDocumentType();
         $data['CUSTOMER.IDENTIFICATION.VALUE'] = $card->getIdentificationDocumentNumber();
     }
     if ($card->getShippingContactDifferences()) {
         $data = $this->addShippingDataFromCard($card, $data);
     }
     return $data;
 }
コード例 #2
0
 public function testSetSalutation()
 {
     $card = new CreditCard();
     $this->assertEmpty($card->getSalutation());
     $this->assertEmpty($card->getBillingSalutation());
     $this->assertEmpty($card->getShippingSalutation());
     $value = uniqid();
     $this->assertSame($card, $card->setSalutation($value));
     $this->assertSame($value, $card->getSalutation());
     $this->assertSame($value, $card->getBillingSalutation());
     $this->assertSame($value, $card->getShippingSalutation());
     $this->assertSame($card, $card->setSalutation(null));
     $this->assertEmpty($card->getSalutation());
     $this->assertEmpty($card->getBillingSalutation());
     $this->assertEmpty($card->getShippingSalutation());
 }