PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | libraries/adapter/payment/payment.php +131 -1 1.6.4 → 1.8.16 View file →
@@ -2,9 +2,9 @@
2 2 /**
3 3 * @package VikWP - Libraries
4 4 * @subpackage adapter.payment
5 5 * @author E4J s.r.l.
6 - * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved.
6 + * @copyright Copyright (C) 2023 E4J s.r.l. All Rights Reserved.
7 7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 8 * @link https://vikwp.com
9 9 */
10 10
@@ -801,8 +801,138 @@
801 801 protected function doDirectCharge(JPaymentStatus $status)
802 802 {
803 803 // do nothing as a plugin may
804 804 // not support direct charges
805 + }
806 +
807 + /**
808 + * Checks whether the payment method allows off-session capturing.
809 + *
810 + * @return boolean
811 + *
812 + * @since 10.1.63
813 + */
814 + public function isOffSessionCaptureSupported()
815 + {
816 + // not supported by default
817 + return false;
818 + }
819 +
820 + /**
821 + * Performs the off-session capture transaction.
822 + *
823 + * This method triggers the ACTION below to manipulate the payment details
824 + * before they are used to execute the capture:
825 + * - payment_before_offsession_capture
826 + *
827 + * This method triggers the ACTION below to manipulate the
828 + * response evaluated by the capture:
829 + * - payment_after_offsession_capture
830 + *
831 + * @return mixed An object describing the status of the transaction.
832 + *
833 + * @uses isOffSessionCaptureSupported()
834 + * @uses doOffSessionCapture()
835 + *
836 + * @since 10.1.63
837 + */
838 + public function offSessionCapture()
839 + {
840 + // make sure off-session capturing is supported
841 + if (!$this->isOffSessionCaptureSupported())
842 + {
843 + // not supported
844 + throw new Exception('Off session capturing not supported', 405);
845 + }
846 +
847 + $status = new JPaymentStatus();
848 +
849 + /**
850 + * Plugins can manipulate the properties of this object.
851 + * Fires before the off-session capturing is made.
852 + * Global hook accessible by any drivers.
853 + *
854 + * @param self A reference to this object.
855 + *
856 + * @since 10.1.63
857 + */
858 + do_action($this->getHook('payment_before_offsession_capture'), array($this));
859 +
860 + /**
861 + * Plugins can manipulate the properties of this object.
862 + * Fires before the off-session capturing is made.
863 + * Hook specific for the current driver.
864 + *
865 + * @param self A reference to this object.
866 + *
867 + * @since 10.1.63
868 + */
869 + do_action($this->getDriverHook('payment_before_offsession_capture'), array($this));
870 +
871 + // children payments will perform the off-session capturing
872 + $this->doOffSessionCapture($status);
873 +
874 + $response = null;
875 +
876 + /**
877 + * Plugins can manipulate the response object to return.
878 + * By filling the &$response variable, this method will return
879 + * it instead of the default &$status one.
880 + * Fires after completing the off-session capturing.
881 + * Hook specific for the current driver.
882 + *
883 + * @param self A reference to this object.
884 + * @param JPaymentStatus A reference to the status object.
885 + * @param mixed A reference to the final response (null by default).
886 + *
887 + * @since 10.1.63
888 + */
889 + do_action_ref_array($this->getDriverHook('payment_after_offsession_capture'), array($this, $status, &$response));
890 +
891 + /**
892 + * Plugins can manipulate the response object to return.
893 + * By filling the &$response variable, this method will return
894 + * it instead of the default &$status one.
895 + * Fires after completing the off-session capturing.
896 + * Global hook accessible by any drivers.
897 + *
898 + * @param self A reference to this object.
899 + * @param JPaymentStatus A reference to the status object.
900 + * @param mixed A reference to the final response (null by default).
901 + *
902 + * @since 10.1.63
903 + */
904 + do_action_ref_array($this->getHook('payment_after_offsession_capture'), array($this, $status, &$response));
905 +
906 + if (is_null($response))
907 + {
908 + // no hook fired, the response will be equal to the status object
909 + $response = $status;
910 + }
911 +
912 + return $response;
913 + }
914 +
915 + /**
916 + * Off-session capturing implementor.
917 + * Children classes can inherit this method to use the API of the
918 + * payment in order to perform an off-session capturing.
919 + *
920 + * @param JPaymentStatus $status The status object. In case the capturing was
921 + * successful, you should invoke: $status->verified().
922 + *
923 + * @return void
924 + *
925 + * @see JPaymentStatus
926 + *
927 + * @see Visibility must be public.
928 + *
929 + * @since 10.1.63
930 + */
931 + public function doOffSessionCapture(JPaymentStatus $status)
932 + {
933 + // do nothing as a plugin may
934 + // not support off-session capturing
805 935 }
806 936
807 937 /**
808 938 * Returns the final hook that will be used for actions