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)); } }
/** * Source column */ public static function source_text($text, Pronamic_WP_Pay_Payment $payment) { $text = ''; $text .= __('Formidable', 'pronamic_ideal') . '<br />'; $text .= sprintf('<a href="%s">%s</a>', add_query_arg(array('page' => 'formidable-entries', 'frm_action' => 'show', 'id' => $payment->get_source_id()), admin_url('admin.php')), sprintf(__('Entry #%s', 'pronamic_ideal'), $payment->get_source_id())); return $text; }
/** * Payment redirect URL filter. * * @param string $url * @param Pronamic_WP_Pay_Payment $payment * @return string */ public static function redirect_url($url, $payment) { switch ($payment->get_status()) { case Pronamic_WP_Pay_Statuses::CANCELLED: $url = give_get_failed_transaction_uri(); break; case Pronamic_WP_Pay_Statuses::FAILURE: $url = give_get_failed_transaction_uri(); break; case Pronamic_WP_Pay_Statuses::SUCCESS: $url = give_get_success_page_uri(); break; } return $url; }
/** * 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 { $confirmation = array('redirect' => $this->payment->get_pay_redirect_url()); } 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; }
/** * Payment redirect URL filter. * * @param string $url * @param Pronamic_WP_Pay_Payment $payment * @return string */ public static function redirect_url($url, $payment) { $source_id = $payment->get_source_id(); $data = new Pronamic_WP_Pay_Extensions_EDD_PaymentData($source_id, array()); $url = $data->get_normal_return_url(); switch ($payment->get_status()) { case Pronamic_WP_Pay_Statuses::CANCELLED: $url = $data->get_cancel_url(); break; case Pronamic_WP_Pay_Statuses::EXPIRED: $url = $data->get_error_url(); break; case Pronamic_WP_Pay_Statuses::FAILURE: $url = $data->get_error_url(); break; case Pronamic_WP_Pay_Statuses::SUCCESS: $url = $data->get_success_url(); break; case Pronamic_WP_Pay_Statuses::OPEN: // Nothing to do? break; } return $url; }
/** * 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; }
/** * Source column */ public static function source_text($text, Pronamic_WP_Pay_Payment $payment) { $text = ''; $text .= __('WP e-Commerce', 'pronamic_ideal') . '<br />'; $text .= sprintf('<a href="%s">%s</a>', add_query_arg(array('page' => 'wpsc-sales-logs', 'purchaselog_id' => $payment->get_source_id()), admin_url('index.php')), sprintf(__('Purchase #%s', 'pronamic_ideal'), $payment->get_source_id())); return $text; }
/** * Payment redirect URL filter. * * @param string $url * @param Pronamic_WP_Pay_Payment $payment * @return string */ public static function redirect_url($url, $payment) { $donation_id = $payment->get_source_id(); $donation = new Charitable_Donation($donation_id); $url = self::get_return_url($donation); switch ($payment->get_status()) { case Pronamic_WP_Pay_Statuses::SUCCESS: $url = charitable_get_permalink('donation_receipt_page', array('donation_id' => $donation_id)); break; } return $url; }
/** * Payment redirect URL filter. * * @since unreleased * @param string $url * @param Pronamic_WP_Pay_Payment $payment * @return string */ public function redirect_url($url, $payment) { $lead_id = $payment->get_source_id(); $lead = RGFormsModel::get_lead($lead_id); if (!$lead) { return $url; } $form_id = $lead['form_id']; $form = RGFormsModel::get_form($form_id); $feed = get_pronamic_gf_pay_feed_by_entry_id($lead_id); if (!$feed) { return $url; } $data = new Pronamic_WP_Pay_Extensions_GravityForms_PaymentData($form, $lead, $feed); switch ($payment->status) { case Pronamic_WP_Pay_Statuses::CANCELLED: $url = $data->get_cancel_url(); break; case Pronamic_WP_Pay_Statuses::EXPIRED: $url = $feed->get_url(Pronamic_WP_Pay_Extensions_GravityForms_Links::EXPIRED); break; case Pronamic_WP_Pay_Statuses::FAILURE: $url = $data->get_error_url(); break; case Pronamic_WP_Pay_Statuses::SUCCESS: $url = $data->get_success_url(); break; case Pronamic_WP_Pay_Statuses::OPEN: default: $url = $data->get_normal_return_url(); break; } // Process Gravity Forms confirmations if link type is confirmation $link = Pronamic_WP_Pay_Extensions_GravityForms_Links::transform_status($payment->status); if (isset($feed->links[$link], $feed->links[$link]['type']) && Pronamic_WP_Pay_Extensions_GravityForms_PayFeed::LINK_TYPE_CONFIRMATION === $feed->links[$link]['type']) { $confirmation = $this->get_confirmation($lead, $payment->status); if (!empty($confirmation)) { if (is_array($confirmation) && isset($confirmation['redirect'])) { $url = $confirmation['redirect']; } else { $url = add_query_arg(array('pay_confirmation' => $payment->get_id(), '_wpnonce' => wp_create_nonce('gf_confirmation_payment_' . $payment->get_id())), $lead['source_url']); } } } return $url; }
/** * Payment redirect URL filter. * * @param string $url * @param Pronamic_WP_Pay_Payment $payment * @return string */ public static function redirect_url($url, $payment) { // @see https://github.com/wp-plugins/membership/blob/4.0.0.2/app/model/class-ms-model-pages.php#L492-L530 if (Pronamic_WP_Pay_Class::method_exists('MS_Model_Pages', 'get_page_url')) { // @see https://github.com/wp-plugins/membership/blob/4.0.0.2/app/model/class-ms-model-pages.php#L44-L55 $url = MS_Model_Pages::get_page_url(MS_Model_Pages::MS_PAGE_REGISTER); } elseif (function_exists('M_get_returnurl_permalink')) { // @see https://github.com/wp-plugins/membership/blob/3.4.4.3/membershipincludes/includes/functions.php#L598-L622 $url = M_get_returnurl_permalink(); } switch ($payment->get_status()) { case Pronamic_WP_Pay_Statuses::SUCCESS: // @see https://github.com/wp-plugins/membership/blob/4.0.0.2/app/model/class-ms-model-pages.php#L492-L530 if (Pronamic_WP_Pay_Class::method_exists('MS_Model_Pages', 'get_page_url')) { $invoice_id = get_post_meta($payment->get_id(), '_pronamic_payment_membership_invoice_id', true); $invoice = MS_Factory::load('MS_Model_Invoice', $invoice_id); $subscription = $invoice->get_subscription(); // @see https://github.com/wp-plugins/membership/blob/4.0.0.2/app/model/class-ms-model-pages.php#L44-L55 $url = add_query_arg('ms_relationship_id', $subscription->id, MS_Model_Pages::get_page_url(MS_Model_Pages::MS_PAGE_REG_COMPLETE)); } elseif (function_exists('M_get_registrationcompleted_permalink')) { // @see https://github.com/wp-plugins/membership/blob/3.4.4.3/membershipincludes/includes/functions.php#L576-L598 $url = M_get_registrationcompleted_permalink(); } break; } return $url; }