コード例 #1
0
	private function buildPayRequest( PayRequest $request , AbstractPayPalMessageFactory $factory ) {
		$this->message->addChild( $factory->createMessageField( 'actionType' , $factory->createMessagePrimitive( $request->getActionType() ) ) );
		$this->message->addChild( $factory->createMessageField( 'cancelUrl' , $factory->createMessagePrimitive( $request->getCancelUrl() ) ) );

		if ( $request->getClientDetails() != null ) {
			$this->message->addChild( $factory->createMessageField( 'clientDetails' , $this->buildClientDetails( $request->clientDetails() ) ) );
		}

		$this->message->addChild( $factory->createMessageField( 'currencyCode' , $factory->createMessagePrimitive( $request->currencyCode()->value() ) ) );

		if ( $request->getFundingConstraint() != null ) {
			$this->message->addChild( $factory->createMessageField( 'fundingConstraint' , $this->buildFundingConstraint( $request->fundingConstraint() , $factory ) ) );
		}

		if ( ( $ipnNotificationUrl = $request->getIpnNotificationUrl() ) != null ) {
			$this->message->addChild( $factory->createMessageField( 'ipnNotificationUrl' , $factory->createMessagePrimitive( $ipnNotificationUrl ) ) );
		}

		if ( ( $memo = $request->getMemo() ) != null ) {
			$this->message->addChild( $factory->createMessageField( 'memo' , $factory->createMessagePrimitive( $memo ) ) );
		}

		if ( ( $pin = $request->getPin() ) != null ) {
			$this->message->addChild( $factory->createMessageField( 'pin' , $factory->createMessagePrimitive( $pin ) ) );
		}

		if ( ( $preaprovalKey = $request->getPreaprovalKey() ) != null ) {
			$this->message->addChild( $factory->createMessageField( 'preaprovalKey' , $factory->createMessagePrimitive( $preaprovalKey ) ) );
		}

		if ( $request->receiverList()->count() > 0 ) {
			$this->message->addChild( $factory->createMessageField( 'receiverList' , $this->buildReceiverList( $request->receiverList() , $factory ) ) );
		} else {
			throw new RuntimeException( 'You are *required* to specify at least one receiver' );
		}

		$this->message->addChild( $factory->createMessageField( 'returnUrl' , $factory->createMessagePrimitive( $request->getReturnUrl() ) ) );
		$this->message->addChild( $factory->createMessageField( 'requestEnvelope' , $this->buildRequestEnvelope( $request->requestEnvelope() , $factory ) ) );

		if ( ( $reverseAllParallelPaymentsOnError = $request->getReverseAllParallelPaymentsOnError() ) != null ) {
			$this->message->addChild( $factory->createMessageField( 'reverseAllParallelPaymentsOnError' , $factory->createMessagePrimitive( $reverseAllParallelPaymentsOnError ) ) );
		}

		if ( $request->getSender() != null ) {
			$this->message->addChild( $factory->createMessageField( 'sender' , $this->buildSender( $request->sender() , $factory ) ) );
		}

		if ( ( $senderEmail = $request->getSenderEmail() ) != null ) {
			$this->message->addChild( $factory->createMessageField( 'senderEmail' , $factory->createMessagePrimitive( $senderEmail ) ) );
		}

		if ( ( $trackingId = $request->getTrackingId() ) != null ) {
			$this->message->addChild( $factory->createMessageField( 'trackingId' , $factory->createMessagePrimitive( $trackingId ) ) );
		}
	}