Ejemplo n.º 1
0
 /**
  * Get notify URL
  *
  * @return string
  */
 private function get_return_url()
 {
     // @see https://bitbucket.org/Pronamic/classipress/src/bc1334736c6e/includes/theme-functions.php?at=3.2.1#cl-2381
     if (isset($this->order_values['return_url'])) {
         $url = $this->order_values['return_url'];
     } else {
         /*
          * We query the order info sometimes directly from the database,
          * if we do this the 'return_url' isn't directly available
          *
          * ClassiPress has order information about adding an advertisement,
          * but also has order information about advertisement packages.
          *
          * If the advertisement post ID is empty we know the order
          * information is about an advertisement package.
          *
          * ClassiPress is doing in similar check in the following file:
          * @see https://bitbucket.org/Pronamic/classipress/src/bc1334736c6e/includes/gateways/gateway.php?at=3.2.1#cl-31
          */
         if (Pronamic_WP_Pay_Extensions_ClassiPress_Order::is_advertisement($this->order_values)) {
             // Advertisement
             // @see https://bitbucket.org/Pronamic/classipress/src/bc1334736c6e/includes/theme-functions.php?at=3.2.1#cl-2381
             $url = add_query_arg(array('pid' => $this->order_values['txn_id'], 'aid' => $this->order_values['ad_id']), CP_ADD_NEW_CONFIRM_URL);
         } else {
             // Advertisement package
             // @see https://bitbucket.org/Pronamic/classipress/src/bc1334736c6e/includes/theme-functions.php?at=3.2.1#cl-2409
             $url = add_query_arg(array('oid' => $this->order_values['txn_id'], 'uid' => isset($this->order_values['user_id']) ? $this->order_values['user_id'] : false), CP_MEMBERSHIP_PURCHASE_CONFIRM_URL);
         }
     }
     return $url;
 }
Ejemplo n.º 2
0
 /**
  * Update lead status of the specified payment
  *
  * @param string $payment
  */
 public static function update_status(Pronamic_Pay_Payment $payment, $can_redirect = false)
 {
     if (self::SLUG === $payment->get_source()) {
         $id = $payment->get_source_id();
         $order = Pronamic_WP_Pay_Extensions_ClassiPress_ClassiPress::get_order_by_id($id);
         $data = new Pronamic_WP_Pay_Extensions_ClassiPress_PaymentData($order);
         $url = $data->get_normal_return_url();
         switch ($payment->status) {
             case Pronamic_WP_Pay_Statuses::CANCELLED:
                 break;
             case Pronamic_WP_Pay_Statuses::EXPIRED:
                 break;
             case Pronamic_WP_Pay_Statuses::FAILURE:
                 break;
             case Pronamic_WP_Pay_Statuses::SUCCESS:
                 if (!Pronamic_WP_Pay_Extensions_ClassiPress_Order::is_completed($order)) {
                     Pronamic_WP_Pay_Extensions_ClassiPress_ClassiPress::process_ad_order($id);
                     Pronamic_WP_Pay_Extensions_ClassiPress_ClassiPress::process_membership_order($order);
                     Pronamic_WP_Pay_Extensions_ClassiPress_ClassiPress::update_payment_status_by_txn_id($id, Pronamic_WP_Pay_Extensions_ClassiPress_PaymentStatuses::COMPLETED);
                 }
                 $url = $data->get_success_url();
                 break;
             case Pronamic_WP_Pay_Statuses::OPEN:
                 break;
             default:
                 break;
         }
         if ($can_redirect) {
             wp_redirect($url, 303);
             exit;
         }
     }
 }