PayPal\Api\Invoice::recordPayment PHP Method

recordPayment() public method

Marks the status of a specified invoice, by ID, as paid. Include a payment detail object that defines the payment method and other details in the JSON request body.
public recordPayment ( PaymentDetail $paymentDetail, ApiContext $apiContext = null, PayPalRestCall $restCall = null ) : boolean
$paymentDetail PaymentDetail
$apiContext PayPal\Rest\ApiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
$restCall PayPal\Transport\PayPalRestCall is the Rest Call Service that is used to make rest calls
return boolean
    public function recordPayment($paymentDetail, $apiContext = null, $restCall = null)
    {
        ArgumentValidator::validate($this->getId(), "Id");
        ArgumentValidator::validate($paymentDetail, 'paymentDetail');
        $payLoad = $paymentDetail->toJSON();
        self::executeCall("/v1/invoicing/invoices/{$this->getId()}/record-payment", "POST", $payLoad, null, $apiContext, $restCall);
        return true;
    }

Usage Example

コード例 #1
0
 /**
  * @dataProvider mockProvider
  * @param Invoice $obj
  */
 public function testRecordPayment($obj, $mockApiContext)
 {
     $mockPayPalRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock();
     $mockPayPalRestCall->expects($this->any())->method('execute')->will($this->returnValue(true));
     $paymentDetail = PaymentDetailTest::getObject();
     $result = $obj->recordPayment($paymentDetail, $mockApiContext, $mockPayPalRestCall);
     $this->assertNotNull($result);
 }