コード例 #1
0
ファイル: ReceiverTest.php プロジェクト: dindigital/nfe-focus
 public function testValidEmail()
 {
     $email = '*****@*****.**';
     $receiver = new Receiver();
     $receiver->setEmail($email);
     $this->assertEquals($email, $receiver->getEmail());
 }
コード例 #2
0
	private function buildReceiver( Receiver $receiver , AbstractPayPalMessageFactory $factory ) {
		$receiverAmount = $receiver->getAmount();
		$receiverEmail = $receiver->getEmail();
		$receiverInvoiceId = $receiver->getInvoiceId();
		$receiverPaymentType = $receiver->getPaymentType();
		$receiverPaymentSubType = $receiver->getPaymentSubType();
		$receiverPhone = $receiver->getPhone();
		$receiverPrimary = $receiver->isPrimary();

		if ( $receiverEmail == null && $receiverPhone == null ) {
			throw new RuntimeException( 'You are *required* to specify the Receiver\'s email or the phone number.' );
		} else {
			$receiverElement = $factory->createMessageElement();
			$receiverElement->addChild( $factory->createMessageField( 'amount' , $factory->createMessagePrimitive( $receiverAmount ) ) );

			if ( $receiverEmail != null ) {
				$receiverElement->addChild( $factory->createMessageField( 'email' , $factory->createMessagePrimitive( $receiverEmail ) ) );
			}

			if ( $receiverInvoiceId != null ) {
				$receiverElement->addChild( $factory->createMessageField( 'invoiceId' , $factory->createMessagePrimitive( $receiverInvoiceId ) ) );
			}

			if ( $receiverPaymentType != null ) {
				$receiverElement->addChild( $factory->createMessageField( 'paymentType' , $factory->createMessagePrimitive( $receiverPaymentType ) ) );
			}

			if ( $receiverPaymentSubType != null ) {
				$receiverElement->addChild( $factory->createMessageField( 'paymentSubType' , $factory->createMessagePrimitive( $receiverPaymentSubType ) ) );
			}

			if ( $receiverPhone != null ) {
				$receiverElement->addChild( $factory->createMessageField( 'phone' , $this->buildPhoneNumber( $receiverPhone , $factory ) ) );
			}

			if ( $receiverPrimary != null ) {
				$receiverElement->addChild( $factory->createMessageField( 'primary' , $factory->createMessagePrimitive( $receiverPrimary ) ) );
			}

			return $receiverElement;
		}
	}