當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。