PayPal\Api\Order::void PHP Method

void() public method

Voids, or cancels, an order, by ID. You cannot void an order if a payment has already been partially or fully captured.
public void ( ApiContext $apiContext = null, PayPalRestCall $restCall = null ) : Order
$apiContext PayPal\Rest\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 Order
    public function void($apiContext = null, $restCall = null)
    {
        ArgumentValidator::validate($this->getId(), "Id");
        $payLoad = "";
        $json = self::executeCall("/v1/payments/orders/{$this->getId()}/do-void", "POST", $payLoad, null, $apiContext, $restCall);
        $this->fromJson($json);
        return $this;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @dataProvider mockProvider
  * @param Order $obj
  */
 public function testVoid($obj, $mockApiContext)
 {
     $mockPPRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock();
     $mockPPRestCall->expects($this->any())->method('execute')->will($this->returnValue(self::getJson()));
     $result = $obj->void($mockApiContext, $mockPPRestCall);
     $this->assertNotNull($result);
 }