Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Api/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function cancelPayment($order_id, $text)
/**
* {@inheritdoc}
*/
public function capturePayment($order_id, $text, $amount = 0)
public function capturePayment($order_id, $text, $amount = 0, $request_id = null)
{
// Build request object from data passed to method.
$request = (new RequestCapturePayment())
Expand All @@ -120,6 +120,7 @@ public function capturePayment($order_id, $text, $amount = 0)
$request->getTransaction()->setAmount($amount);
}
$resource = new CapturePayment($this->app, $this->getSubscriptionKey(), $order_id, $request);
$resource->setRequestID($request_id);
$resource->setPath(str_replace('ecomm', $this->customPath, $resource->getPath()));
/** @var \zaporylie\Vipps\Model\Payment\ResponseCapturePayment $response */
$response = $resource->call();
Expand Down
3 changes: 2 additions & 1 deletion src/Api/PaymentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ public function cancelPayment($order_id, $text);
* @param string $order_id
* @param string $text
* @param int $amount
* @param string $request_id
*
* @return \zaporylie\Vipps\Model\Payment\ResponseCapturePayment
*/
public function capturePayment($order_id, $text, $amount = 0);
public function capturePayment($order_id, $text, $amount = 0, $request_id = null);

/**
* @param string $order_id
Expand Down
15 changes: 14 additions & 1 deletion src/Resource/Payment/PaymentResourceBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,22 @@ public function __construct(\zaporylie\Vipps\VippsInterface $vipps, $subscriptio
$this->headers['Content-Type'] = 'application/json';

// By default RequestID is different for each Resource object.
$this->headers['X-Request-Id'] = RequestIdFactory::generate();
$this->setRequestID(RequestIdFactory::generate());

// Timestamp is equal to current DateTime.
$this->headers['X-TimeStamp'] = (new \DateTime())->format(\DateTime::ISO8601);
}

/**
* set specific request ID
* @param string $request_id
* @return $this
*/
public function setRequestID($request_id)
{
if (!empty($request_id)) {
$this->headers['X-Request-Id'] = $request_id;
}
return $this;
}
}