Skip to content

Commit

Permalink
Charge capture requests now require a body
Browse files Browse the repository at this point in the history
  • Loading branch information
Pelle-Jensen committed Nov 1, 2023
1 parent ec98907 commit a60f8a6
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/Api/RecurringPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use zaporylie\Vipps\Model\RecurringPayment\RequestCreateCharge;
use zaporylie\Vipps\Model\RecurringPayment\RequestRefundCharge;
use zaporylie\Vipps\Model\RecurringPayment\RequestUpdateAgreementBase;
use zaporylie\Vipps\Model\RecurringPayment\v3\RequestCaptureCharge;
use zaporylie\Vipps\Resource\RecurringPayment\CancelCharge;
use zaporylie\Vipps\Resource\RecurringPayment\CaptureCharge;
use zaporylie\Vipps\Resource\RecurringPayment\CreateAgreement;
Expand Down Expand Up @@ -152,9 +153,9 @@ public function cancelCharge($agreement_id, $charge_id)
/**
* {@inheritDoc}
*/
public function captureCharge($agreement_id, $charge_id)
public function captureCharge($agreement_id, $charge_id, RequestCaptureCharge $requestObject)
{
$resource = new CaptureCharge($this->app, $this->api_endpoint_version, $this->getSubscriptionKey(), $agreement_id, $charge_id);
$resource = new CaptureCharge($this->app, $this->api_endpoint_version, $this->getSubscriptionKey(), $agreement_id, $charge_id, $requestObject);
$response = $resource->call();
return $response;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Api/RecurringPaymentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use zaporylie\Vipps\Model\RecurringPayment\RequestCreateCharge;
use zaporylie\Vipps\Model\RecurringPayment\RequestRefundCharge;
use zaporylie\Vipps\Model\RecurringPayment\RequestUpdateAgreementBase;
use zaporylie\Vipps\Model\RecurringPayment\v3\RequestCaptureCharge;

/**
* Interface PaymentInterface
Expand Down Expand Up @@ -77,7 +78,7 @@ public function cancelCharge($agreement_id, $charge_id);
*
* @return string
*/
public function captureCharge($agreement_id, $charge_id);
public function captureCharge($agreement_id, $charge_id, RequestCaptureCharge $requestObject);

/**
* @param string $agreement_id
Expand Down
73 changes: 73 additions & 0 deletions src/Model/RecurringPayment/v3/RequestCaptureCharge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

namespace zaporylie\Vipps\Model\RecurringPayment\v3;

use JMS\Serializer\Annotation as Serializer;


/**
* Class RequestCaptureCharge
*
* @package Vipps\Model\RecurringPayment
*/
class RequestCaptureCharge {
/**
* @var int
* @Serializer\Type("integer")
*/
protected $amount;

/**
* @var string
* @Serializer\Type("string")
*/
protected $description;

/**
* Get the value of amount
*
* @return int
*/
public function getAmount()
{
return $this->amount;
}

/**
* Set the value of amount
*
* @param int $amount
*
* @return self
*/
public function setAmount(int $amount)
{
$this->amount = $amount;

return $this;
}

/**
* Get the value of description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}

/**
* Set the value of description
*
* @param string $description
*
* @return self
*/
public function setDescription(string $description)
{
$this->description = $description;

return $this;
}
}
10 changes: 9 additions & 1 deletion src/Resource/RecurringPayment/CaptureCharge.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use zaporylie\Vipps\Model\RecurringPayment\RequestCreateCharge;
use zaporylie\Vipps\Model\RecurringPayment\ResponseCaptureCharge;
use zaporylie\Vipps\Model\RecurringPayment\ResponseCreateCharge;
use zaporylie\Vipps\Model\RecurringPayment\v3\RequestCaptureCharge;
use zaporylie\Vipps\Resource\HttpMethod;
use zaporylie\Vipps\Resource\IdempotencyKeyFactory;
use zaporylie\Vipps\Resource\RequestIdFactory;
Expand Down Expand Up @@ -41,11 +42,18 @@ public function __construct(
$api_endpoint_version,
$subscription_key,
$agreement_id,
$charge_id
$charge_id,
RequestCaptureCharge $requestObject
) {
$this->id = $agreement_id;
$this->charge_id = $charge_id;
parent::__construct($vipps, $api_endpoint_version, $subscription_key);
$this->body = $this
->getSerializer()
->serialize(
$requestObject,
'json'
);
}

/**
Expand Down

0 comments on commit a60f8a6

Please sign in to comment.