PayPal\Core\PPBaseService::call PHP Method

call() public method

public call ( $port, string $method, object $requestObject, apiContext $apiContext, array $handlers = [] )
$method string - API method to call
$requestObject object Request object
$apiContext apiContext object containing credential and SOAP headers
$handlers array Array of Handlers
    public function call($port, $method, $requestObject, $apiContext, $handlers = array())
    {
        if (!is_array($handlers)) {
            $handlers = array();
        }
        if (is_array($this->handlers)) {
            $handlers = array_merge($this->handlers, $handlers);
        }
        if ($apiContext == null) {
            $apiContext = new PPApiContext(PPConfigManager::getConfigWithDefaults($this->config));
        }
        if ($apiContext->getConfig() == null) {
            $apiContext->setConfig(PPConfigManager::getConfigWithDefaults($this->config));
        }
        $service = new PPAPIService($port, $this->serviceName, $this->serviceBinding, $apiContext, $handlers);
        $ret = $service->makeRequest($method, new PPRequest($requestObject, $this->serviceBinding));
        $this->lastRequest = $ret['request'];
        $this->lastResponse = $ret['response'];
        return $this->lastResponse;
    }

Usage Example

Ejemplo n.º 1
0
 public function testMultipleCallsDoesntIncludePreviousCallHandlers()
 {
     $firstHandler = $this->getMock('\\PayPal\\Handler\\IPPHandler');
     $firstHandler->expects($this->once())->method('handle');
     $req = new MockNVPClass();
     $ret = $this->object->call(null, 'GetInvoiceDetails', $req, null, array($firstHandler));
     $secondHandler = $this->getMock('\\PayPal\\Handler\\IPPHandler');
     $secondHandler->expects($this->once())->method('handle');
     $req = new MockNVPClass();
     $ret = $this->object->call(null, 'GetInvoiceDetails', $req, null, array($secondHandler));
 }