本文整理汇总了PHP中Call::refundTransaction方法的典型用法代码示例。如果您正苦于以下问题:PHP Call::refundTransaction方法的具体用法?PHP Call::refundTransaction怎么用?PHP Call::refundTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Call
的用法示例。
在下文中一共展示了Call::refundTransaction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hookadminOrder
/**
* @brief The merchant can cancel the order or refund the customer
*/
public function hookadminOrder($params)
{
if (!$this->active) {
return false;
}
$order = new Order($params['id_order']);
$cart = new Cart($order->id_cart);
$tokenTransaction = new TokenTransaction($cart->id);
$token = $tokenTransaction->getToken();
if ($token == null) {
return false;
}
if ($order->getCurrentState() == Configuration::get('PS_OS_CANCELED') && $tokenTransaction->getStatus() != 'CANCEL') {
$call = new Call();
try {
$result = $call->voidTransaction($token);
} catch (Exception $e) {
$this->context->smarty->assign('error', Tools::safeOutput($e->getMessage()));
}
if (isset($result->VoidResult->ApprovalStatus) && strrpos($result->VoidResult->ApprovalStatus, 'APPROVED') !== false) {
$tokenTransaction->setStatus('CANCEL');
$this->context->smarty->assign('message', $this->l('Action succeded.'));
} else {
$this->context->smarty->assign('error', isset($result->VoidResult->ApprovalStatus) ? Tools::safeOutput($result->VoidResult->ApprovalStatus) : $this->l('ERROR, please contact MerchantWare for Support assistance.'));
}
}
if ($order->getCurrentState() == Configuration::get('PS_OS_REFUND') && $tokenTransaction->getStatus() != 'REFUND') {
$call = new Call();
try {
$result = $call->refundTransaction($token, $order->total_paid_real);
} catch (Exception $e) {
$this->context->smarty->assign('error', Tools::safeOutput($e->getMessage()));
}
if (isset($result->RefundResult->ApprovalStatus) && strrpos($result->RefundResult->ApprovalStatus, 'APPROVED') !== false) {
$tokenTransaction->setStatus('REFUND');
$this->context->smarty->assign('message', $this->l('Action succeded.'));
} else {
$this->context->smarty->assign('error', isset($result->RefundResult->ApprovalStatus) ? Tools::safeOutput($result->RefundResult->ApprovalStatus) : $this->l('ERROR, please contact Merchant Warehouse for Support assistance.'));
}
}
return $this->display(__FILE__, 'tpl/adminOrder.tpl');
}