クラス
Capture
ソース ソース
ファイル: src/Api/Capture.php
class Capture
{
/**
* Settlement module
*
* @var LinePay
*/
private $module;
/**
* Inject `LinePay` module
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @param LinePay $module
*/
public function __construct(LinePay $module) {
$this->module = $module;
}
/**
* Capture payments for an order in `与信` state
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @param array $args
* @return array|GenericError
*/
public function capture(array $args) {
$orderId = (int)$args['orderId'];
$ometa = new OrderMeta($orderId);
$meta = $ometa->getMeta();
$payload = [
'amount' => $meta['total'],
'currency' => $meta['currency'],
];
$this->module->api->adminreq = true;
$res = $this->module->api->capture($payload, $ometa->getTransactionId());
if ($res instanceof GenericError) {
return $res;
}
$ometa->setTransactionState(new TransactionState($ometa->getTransactionId(), TransactionState::CAPTURED));
return $res;
}
}
- __construct — Inject `LinePay` module
- capture — Capture payments for an order in `与信` state