本文整理汇总了PHP中OJSPaymentManager::acceptGiftPayments方法的典型用法代码示例。如果您正苦于以下问题:PHP OJSPaymentManager::acceptGiftPayments方法的具体用法?PHP OJSPaymentManager::acceptGiftPayments怎么用?PHP OJSPaymentManager::acceptGiftPayments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OJSPaymentManager
的用法示例。
在下文中一共展示了OJSPaymentManager::acceptGiftPayments方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: redeemGift
/**
* User redeems a gift
* @param $args array
* @param $request PKPRequest
*/
function redeemGift($args, $request)
{
$this->validate();
if (empty($args)) {
$request->redirect(null, 'dashboard');
}
$journal = $request->getJournal();
if (!$journal) {
$request->redirect(null, 'dashboard');
}
// Ensure gift payments are enabled
import('classes.payment.ojs.OJSPaymentManager');
$paymentManager = new OJSPaymentManager($request);
$acceptGiftPayments = $paymentManager->acceptGiftPayments();
if (!$acceptGiftPayments) {
$request->redirect(null, 'dashboard');
}
$journalId = $journal->getId();
$user = $request->getUser();
$userId = $user->getId();
$giftId = isset($args[0]) ? (int) $args[0] : 0;
// Try to redeem the gift
$giftDao = DAORegistry::getDAO('GiftDAO');
$status = $giftDao->redeemGift(ASSOC_TYPE_JOURNAL, $journalId, $userId, $giftId);
// Report redeem status to user
import('classes.notification.NotificationManager');
$notificationManager = new NotificationManager();
switch ($status) {
case GIFT_REDEEM_STATUS_SUCCESS:
$notificationType = NOTIFICATION_TYPE_GIFT_REDEEM_STATUS_SUCCESS;
break;
case GIFT_REDEEM_STATUS_ERROR_NO_GIFT_TO_REDEEM:
$notificationType = NOTIFICATION_TYPE_GIFT_REDEEM_STATUS_ERROR_NO_GIFT_TO_REDEEM;
break;
case GIFT_REDEEM_STATUS_ERROR_GIFT_ALREADY_REDEEMED:
$notificationType = NOTIFICATION_TYPE_GIFT_REDEEM_STATUS_ERROR_GIFT_ALREADY_REDEEMED;
break;
case GIFT_REDEEM_STATUS_ERROR_GIFT_INVALID:
$notificationType = NOTIFICATION_TYPE_GIFT_REDEEM_STATUS_ERROR_GIFT_INVALID;
break;
case GIFT_REDEEM_STATUS_ERROR_SUBSCRIPTION_TYPE_INVALID:
$notificationType = NOTIFICATION_TYPE_GIFT_REDEEM_STATUS_ERROR_SUBSCRIPTION_TYPE_INVALID;
break;
case GIFT_REDEEM_STATUS_ERROR_SUBSCRIPTION_NON_EXPIRING:
$notificationType = NOTIFICATION_TYPE_GIFT_REDEEM_STATUS_ERROR_SUBSCRIPTION_NON_EXPIRING;
break;
default:
$notificationType = NOTIFICATION_TYPE_NO_GIFT_TO_REDEEM;
}
$user = $request->getUser();
$notificationManager->createTrivialNotification($user->getId(), $notificationType);
$request->redirect(null, 'user', 'gifts');
}