Example #1
0
 /**
  * Fulfill order
  *
  * @param array $entry
  */
 public function fulfill_order($entry)
 {
     $feed = get_pronamic_gf_pay_feed_by_entry_id(rgar($entry, 'id'));
     if (null !== $feed) {
         $this->maybe_update_user_role($entry, $feed);
         $form = RGFormsModel::get_form_meta($entry['form_id']);
         // Delay post creation
         // @see https://github.com/gravityforms/gravityforms/blob/1.8.20.5/forms_model.php#L2383
         // @see https://github.com/gravityforms/gravityformspaypal/blob/1.10.3/paypal.php#L2411-L2415
         if ($feed->delay_post_creation) {
             RGFormsModel::create_post($form, $entry);
         }
         // Delay Aweber
         // @see https://github.com/gravityforms/gravityformsaweber/blob/1.4.2/aweber.php#L1167-L1197
         if ($feed->delay_aweber_subscription && Pronamic_WP_Pay_Class::method_exists('GFAWeber', 'export')) {
             call_user_func(array('GFAWeber', 'export'), $entry, $form, false);
             // @since 1.3.0
             // @see https://github.com/gravityforms/gravityformsaweber/blob/2.2.1/aweber.php#L48-L50
             // @see https://github.com/gravityforms/gravityforms/blob/1.9.10.15/includes/addon/class-gf-feed-addon.php#L43
             if (function_exists('gf_aweber')) {
                 $addon = gf_aweber();
                 if (method_exists($addon, 'maybe_process_feed')) {
                     $addon->maybe_process_feed($entry, $form);
                 }
             }
         }
         // Delay Campaign Monitor
         if ($feed->delay_campaignmonitor_subscription) {
             // @see https://github.com/gravityforms/gravityformscampaignmonitor/blob/2.5.1/campaignmonitor.php#L1184
             if (Pronamic_WP_Pay_Class::method_exists('GFCampaignMonitor', 'export')) {
                 call_user_func(array('GFCampaignMonitor', 'export'), $entry, $form, false);
             }
             // @since 1.3.0
             // @see https://github.com/gravityforms/gravityformscampaignmonitor/blob/3.3.2/campaignmonitor.php#L48-L50
             // @see https://github.com/gravityforms/gravityforms/blob/1.9.10.15/includes/addon/class-gf-feed-addon.php#L43
             if (function_exists('gf_campaignmonitor')) {
                 $addon = gf_campaignmonitor();
                 if (method_exists($addon, 'maybe_process_feed')) {
                     $addon->maybe_process_feed($entry, $form);
                 }
             }
         }
         // Delay Mailchimp
         if ($feed->delay_mailchimp_subscription) {
             // @see https://github.com/gravityforms/gravityformsmailchimp/blob/2.4.5/mailchimp.php#L1512
             if (Pronamic_WP_Pay_Class::method_exists('GFMailChimp', 'export')) {
                 call_user_func(array('GFMailChimp', 'export'), $entry, $form, false);
             }
             // @since 1.3.0
             // @see https://github.com/gravityforms/gravityformsmailchimp/blob/3.6.3/mailchimp.php#L48-L50
             // @see https://github.com/gravityforms/gravityforms/blob/1.9.10.15/includes/addon/class-gf-feed-addon.php#L43
             if (function_exists('gf_mailchimp')) {
                 $addon = gf_mailchimp();
                 if (method_exists($addon, 'maybe_process_feed')) {
                     $addon->maybe_process_feed($entry, $form);
                 }
             }
         }
         // Delay Zapier
         // @see https://github.com/gravityforms/gravityformszapier/blob/1.4.2/zapier.php#L469-L533
         if ($feed->delay_zapier && Pronamic_WP_Pay_Class::method_exists('GFZapier', 'send_form_data_to_zapier')) {
             call_user_func(array('GFZapier', 'send_form_data_to_zapier'), $entry, $form);
         }
         // Delay user registration
         // @see https://github.com/gravityforms/gravityformsuserregistration/blob/2.0/userregistration.php#L2133
         if ($feed->delay_user_registration && Pronamic_WP_Pay_Class::method_exists('GFUser', 'gf_create_user')) {
             call_user_func(array('GFUser', 'gf_create_user'), $entry, $form, false);
         }
         // Delay notifications
         // Determine if the feed has Gravity Form 1.7 Feed IDs
         if ($feed->has_delayed_notifications()) {
             // @see https://bitbucket.org/Pronamic/gravityforms/src/42773f75ad7ad9ac9c31ce149510ff825e4aa01f/common.php?at=1.7.8#cl-1512
             GFCommon::send_notifications($feed->delay_notification_ids, $form, $entry, true, 'form_submission');
         }
         if ($feed->delay_admin_notification && Pronamic_WP_Pay_Class::method_exists('GFCommon', 'send_admin_notification')) {
             // https://github.com/gravityforms/gravityforms/blob/1.8.9/common.php#L1265-L1270
             GFCommon::send_admin_notification($form, $entry);
         }
         if ($feed->delay_user_notification && Pronamic_WP_Pay_Class::method_exists('GFCommon', 'send_user_notification')) {
             // https://github.com/gravityforms/gravityforms/blob/1.8.9/common.php#L1258-L1263
             GFCommon::send_user_notification($form, $entry);
         }
     }
     // The Gravity Forms PayPal Add-On executes the 'gform_paypal_fulfillment' action
     do_action('gform_ideal_fulfillment', $entry, $feed);
 }
 /**
  * Get confirmations for lead based on payment status.
  *
  * @param $lead
  *
  * @param string $payment_status
  *
  * @return mixed
  */
 public function get_confirmation($lead, $payment_status = Pronamic_WP_Pay_Statuses::OPEN)
 {
     $form = GFAPI::get_form($lead['form_id']);
     $feed = get_pronamic_gf_pay_feed_by_entry_id($lead['id']);
     $link = Pronamic_WP_Pay_Extensions_GravityForms_Links::transform_status($payment_status);
     if (!class_exists('GFFormDisplay')) {
         require_once GFCommon::get_base_path() . '/form_display.php';
     }
     // Use only link confirmation if set
     if (isset($feed->links[$link]['confirmation_id']) && !empty($feed->links[$link]['confirmation_id'])) {
         $confirmation_id = $feed->links[$link]['confirmation_id'];
         if (isset($form['confirmations'][$confirmation_id])) {
             $form['confirmations'] = array_intersect_key($form['confirmations'], array($confirmation_id => true));
         }
     }
     return GFFormDisplay::handle_confirmation($form, $lead, false);
 }