Payum\Paypal\ExpressCheckout\Nvp\Api::setExpressCheckout PHP Method

setExpressCheckout() public method

Require: PAYMENTREQUEST_0_AMT
public setExpressCheckout ( array $fields ) : array
$fields array
return array
    public function setExpressCheckout(array $fields)
    {
        if (false == isset($fields['RETURNURL'])) {
            if (false == $this->options['return_url']) {
                throw new RuntimeException('The return_url must be set either to FormRequest or to options.');
            }
            $fields['RETURNURL'] = $this->options['return_url'];
        }
        if (false == isset($fields['CANCELURL'])) {
            if (false == $this->options['cancel_url']) {
                throw new RuntimeException('The cancel_url must be set either to FormRequest or to options.');
            }
            $fields['CANCELURL'] = $this->options['cancel_url'];
        }
        $fields['METHOD'] = 'SetExpressCheckout';
        $this->addVersionField($fields);
        $this->addAuthorizeFields($fields);
        return $this->doRequest($fields);
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @test
  */
 public function shouldUseSandboxApiEndpointIfSandboxTrue()
 {
     $testCase = $this;
     $clientMock = $this->createClientMock();
     $clientMock->expects($this->once())->method('send')->will($this->returnCallback(function (FormRequest $request, Response $response) use($testCase) {
         $testCase->assertEquals('https://api-3t.sandbox.paypal.com/nvp', $request->getUrl());
         $response->setHeaders(array('HTTP/1.1 200 OK'));
         $response->setContent('ACK=Success');
         $response->setContent(http_build_query($request->getFields()));
     }));
     $api = new Api(array('username' => 'a_username', 'password' => 'a_password', 'signature' => 'a_signature', 'sandbox' => true, 'return_url' => 'optionReturnUrl', 'cancel_url' => 'optionCancelUrl'), $clientMock);
     $api->setExpressCheckout(array());
 }
All Usage Examples Of Payum\Paypal\ExpressCheckout\Nvp\Api::setExpressCheckout