当前位置: 首页>>代码示例>>PHP>>正文


PHP OJSPaymentManager::acceptGiftPayments方法代码示例

本文整理汇总了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');
 }
开发者ID:pkp,项目名称:ojs,代码行数:58,代码来源:UserHandler.inc.php


注:本文中的OJSPaymentManager::acceptGiftPayments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。