public authorize ( |
||
$authorization | Authorization Object with Amount value to be authorized | |
$apiContext | is the APIContext for this call. It can be used to pass dynamic configuration and credentials. | |
$restCall | PayPalRestCall | is the Rest Call Service that is used to make rest calls |
return |
public function authorize($authorization, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
ArgumentValidator::validate($authorization, 'Authorization');
$payLoad = $authorization->toJSON();
$json = self::executeCall("/v1/payments/orders/{$this->getId()}/authorize", "POST", $payLoad, null, $apiContext, $restCall);
$ret = new Authorization();
$ret->fromJson($json);
return $ret;
}
/** * @dataProvider mockProvider * @param Order $obj */ public function testAuthorize($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock(); $mockPPRestCall->expects($this->any())->method('execute')->will($this->returnValue(AuthorizationTest::getJson())); $authorization = new Authorization(); $result = $obj->authorize($authorization, $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); }