本文整理匯總了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');
}