/** * Executes right before payment execution is finished. * * @see Payment::finish() * * @param Payment $payment * * @return NULL */ function hook_payment_pre_finish(Payment $payment) { if (payment_status_is_or_has_ancestor($payment->getStatus()->status, PAYMENT_STATUS_SUCCESS)) { drupal_set_message(t('Your payment was successfully completed.')); } else { drupal_set_message(t('Your payment was not completed.')); } }
public function statusSuccess(\Payment $payment) { // If the webform submission is still in progress // webform_client_form_submit will set the proper redirect // otherwise we need to redirect immediately: if (!$this->form_state) { $page_num = $this->component['page_num']; $page_finished = TRUE; foreach ($this->submission->webform->componentsByType('paymethod_select') as $cid => $component) { if ($cid != $this->component['cid'] && $component['page_num'] == $page_num) { $component_finished = FALSE; if (($pid = $this->submission->valueByCid($cid)) && is_numeric($pid)) { if ($other_payment = entity_load_single('payment', $pid)) { $component_finished = payment_status_is_or_has_ancestor($other_payment->getStatus(), PAYMENT_STATUS_SUCCESS); } } if (!$component_finished) { $page_finished = FALSE; break; } } } if (!$page_finished) { drupal_set_message(t('Payment processed successfully.')); $this->reenterWebform($page_num); } else { $node = $this->submission->webform->node; $last_component = end($node->webform['components']); if ($page_num == $last_component['page_num']) { // @TODO: Store and check what the original form action was. // Only call finishWebform if it wasn't a "save as draft". $this->finishWebform(); } else { $this->reenterWebform($page_num + 1); } } } }
public function statusIsOneOf() { $statuses = func_get_args(); $status = $this->payment->getStatus()->status; foreach ($statuses as $s) { if (payment_status_is_or_has_ancestor($status, $s)) { return TRUE; } } return FALSE; }