BxPaymentProviderOffline.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup Payment Payment
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxPaymentProviderOffline extends BxBaseModPaymentProvider implements iBxBaseModPaymentProvider
  12. {
  13. function __construct($aConfig)
  14. {
  15. $this->MODULE = 'bx_payment';
  16. parent::__construct($aConfig);
  17. }
  18. public function getCheckoutUrl($aParams = array())
  19. {
  20. return $this->_oModule->_oConfig->getUrl('URL_CHECKOUT_OFFLINE', $aParams, $this->_bUseSsl);
  21. }
  22. public function initializeCheckout($iPendingId, $aCartInfo, $sRedirect = '')
  23. {
  24. $aPending = $this->_oModule->_oDb->getOrderPending(array('type' => 'id', 'id' => $iPendingId));
  25. if(!empty($aPending['order']) || !empty($aPending['error_code']) || !empty($aPending['error_msg']) || (int)$aPending['processed'] != 0)
  26. return $this->_sLangsPrefix . 'err_already_processed';
  27. $iSellerId = (int)$aCartInfo['vendor_id'];
  28. switch($aPending['type']) {
  29. case BX_PAYMENT_TYPE_SINGLE:
  30. $aFormData = array(
  31. 'currency_code' => $aCartInfo['vendor_currency_code'],
  32. 'currency_sign' => $aCartInfo['vendor_currency_sign'],
  33. 'seller' => $iSellerId,
  34. 'amount' => (float)$aCartInfo['items_price'],
  35. 'items_count' => count($aCartInfo['items']),
  36. 'return_url' => $this->_oModule->getObjectCart()->serviceGetCartUrl($iSellerId),
  37. );
  38. $iIndex = 0;
  39. foreach($aCartInfo['items'] as $aItem) {
  40. $aFormData['item_title_' . $iIndex] = bx_process_output($aItem['title']);
  41. $aFormData['item_quantity_' . $iIndex] = $aItem['quantity'];
  42. $iIndex += 1;
  43. }
  44. $this->_oModule->_oTemplate->displayPageCodeRedirect($this->getCheckoutUrl(), $aFormData);
  45. exit;
  46. case BX_PAYMENT_TYPE_RECURRING:
  47. return array(
  48. 'code' => 1,
  49. 'message' => $this->_sLangsPrefix . 'cdt_err_not_available'
  50. );
  51. }
  52. }
  53. public function finalizeCheckout(&$aData)
  54. {
  55. return array('code' => 1, 'message' => $this->_sLangsPrefix . 'cdt_err_not_available');
  56. }
  57. public function finalizedCheckout()
  58. {
  59. return array('code' => 1, 'message' => $this->_sLangsPrefix . 'cdt_err_not_available');
  60. }
  61. }
  62. /** @} */