Skip to content

Commit

Permalink
Merge pull request #23 from Payum/api-useraction
Browse files Browse the repository at this point in the history
Api useraction
  • Loading branch information
makasim committed Nov 18, 2013
2 parents bc52317 + 3aee1ee commit f4572b7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Payum/Paypal/ExpressCheckout/Nvp/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ class Api
'return_url' => null,
'cancel_url' => null,
'sandbox' => null,
'useraction' => null,
);

public function __construct(ClientInterface $client, array $options)
Expand Down Expand Up @@ -472,11 +473,13 @@ public function getAuthorizeTokenUrl($token)
{
$host = $this->options['sandbox'] ? 'www.sandbox.paypal.com' : 'www.paypal.com';

return sprintf(
'https://%s/cgi-bin/webscr?cmd=_express-checkout&token=%s',
$host,
$token
);
$query = array_filter(array(
'useraction' => $this->options['useraction'],
'cmd' => '_express-checkout',
'token' => $token,
));

return sprintf('https://%s/cgi-bin/webscr?%s', $host, http_build_query($query));
}

/**
Expand Down
20 changes: 20 additions & 0 deletions tests/Payum/Paypal/ExpressCheckout/Nvp/Tests/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,26 @@ public function shouldGetSandboxAuthorizeUrlIfSandboxTrue()
);
}

/**
* @test
*/
public function shouldAllowGetAuthorizeUrlWithCustomUserAction()
{
$api = new Api($this->createClientMock(), array(
'username' => 'a_username',
'password' => 'a_password',
'signature' => 'a_signature',
'sandbox' => true,
'useraction' => 'commit',
));

$this->assertEquals(
'https://www.sandbox.paypal.com/cgi-bin/webscr?useraction=commit&cmd=_express-checkout&token=theToken',
$api->getAuthorizeTokenUrl('theToken')
);
}


/**
* @test
*/
Expand Down

0 comments on commit f4572b7

Please sign in to comment.