PayPal\Api\Order::capture PHP Метод

capture() публичный Метод

Captures a payment for an order, by ID. To use this call, the original payment call must specify an intent of order. In the JSON request body, include the payment amount and indicate whether this capture is the final capture for the authorization.
public capture ( Capture $capture, ApiContext $apiContext = null, PayPalRestCall $restCall = null ) : Capture
$capture Capture
$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
Результат Capture
    public function capture($capture, $apiContext = null, $restCall = null)
    {
        ArgumentValidator::validate($this->getId(), "Id");
        ArgumentValidator::validate($capture, 'capture');
        $payLoad = $capture->toJSON();
        $json = self::executeCall("/v1/payments/orders/{$this->getId()}/capture", "POST", $payLoad, null, $apiContext, $restCall);
        $ret = new Capture();
        $ret->fromJson($json);
        return $ret;
    }

Usage Example

Пример #1
0
 /**
  * @dataProvider mockProvider
  * @param Order $obj
  */
 public function testCapture($obj, $mockApiContext)
 {
     $mockPPRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock();
     $mockPPRestCall->expects($this->any())->method('execute')->will($this->returnValue(CaptureTest::getJson()));
     $capture = CaptureTest::getObject();
     $result = $obj->capture($capture, $mockApiContext, $mockPPRestCall);
     $this->assertNotNull($result);
 }