function pronamic_wp_pay_update_payment(Pronamic_WP_Pay_Payment $payment) { $post_id = $payment->get_id(); // Meta $prefix = '_pronamic_payment_'; $meta = array_merge(array('transaction_id' => $payment->get_transaction_id(), 'action_url' => $payment->get_action_url(), 'status' => $payment->status, 'consumer_name' => $payment->consumer_name, 'consumer_account_number' => $payment->consumer_account_number, 'consumer_iban' => $payment->consumer_iban, 'consumer_bic' => $payment->consumer_bic, 'consumer_city' => $payment->consumer_city), $payment->meta); foreach ($meta as $key => $value) { if (!empty($value)) { $meta_key = $prefix . $key; update_post_meta($post_id, $meta_key, $value); } } $status = get_post_meta($post_id, '_pronamic_payment_status', true); $post_status = null; switch ($status) { case Pronamic_WP_Pay_Statuses::CANCELLED: $post_status = 'payment_cancelled'; break; case Pronamic_WP_Pay_Statuses::EXPIRED: $post_status = 'payment_expired'; break; case Pronamic_WP_Pay_Statuses::FAILURE: $post_status = 'payment_failed'; break; case Pronamic_WP_Pay_Statuses::OPEN: $post_status = 'payment_pending'; break; case Pronamic_WP_Pay_Statuses::SUCCESS: $post_status = 'payment_completed'; break; } if (null !== $post_status) { wp_update_post(array('ID' => $payment->post->ID, 'post_status' => $post_status)); } }
/** * Confirmation * * @see http://www.gravityhelp.com/documentation/page/Gform_confirmation */ public function confirmation($confirmation, $form, $lead, $ajax) { if ($this->is_processing($form) && $this->gateway && $this->payment && $this->payment->get_amount() > 0) { if (is_wp_error($this->error)) { $html = ''; $html .= '<ul>'; $html .= '<li>' . Pronamic_WP_Pay_Plugin::get_default_error_message() . '</li>'; foreach ($this->error->get_error_messages() as $message) { $html .= '<li>' . $message . '</li>'; } $html .= '</ul>'; $confirmation = $html; } else { if ($this->gateway->is_http_redirect()) { // Redirect user to the issuer $confirmation = array('redirect' => $this->payment->get_action_url()); } if ($this->gateway->is_html_form()) { $auto_submit = true; if ($ajax) { // On AJAX enabled forms we can't auto submit, this will auto submit in a hidden iframe $auto_submit = false; } // HTML $html = ''; $html .= '<div id="gforms_confirmation_message">'; $html .= GFCommon::replace_variables($form['confirmation']['message'], $form, $lead, false, true, true); $html .= $this->gateway->get_form_html($this->payment, $auto_submit); $html .= '</div>'; // Extend the confirmation with the iDEAL form $confirmation = $html; } } if ((headers_sent() || $ajax) && is_array($confirmation) && isset($confirmation['redirect'])) { $url = $confirmation['redirect']; // Using esc_js() and esc_url() on the URL is causing problems, the & in the URL is modified to & or & $confirmation = sprintf('<script>function gformRedirect(){document.location.href = %s;}', json_encode($url)); if (!$ajax) { $confirmation .= 'gformRedirect();'; } $confirmation .= '</script>'; } } return $confirmation; }