protected function get_receivers(APP_Escrow_Order $order) { $receiver_list = array(); $receivers = $order->get_receivers(); if (empty($receivers)) { $this->fail_order(__('PayPal was unable to verify the payment receivers. Please contact site owner.', APP_TD)); $order->log(sprintf('The following error ocurred while trying to execute the payment: "%s"', 'Receivers list is empty')); return false; } // add the primary receiver - site owner $receivers[1] = $order->get_total(); // sort the receivers - primary receiver should be the first in the list ksort($receivers); $key = 0; foreach ($receivers as $user_id => $amount) { // primary receiver is the site owner if (0 == $key) { $paypal_email = $this->options['paypal_email']; } else { // email field name from the user personal settings $email_field = self::EMAIL_META_KEY; $user = get_user_by('id', $user_id); $paypal_email = get_user_option($email_field, $user_id); $order->log(sprintf(__('Added user \'%1$s\' with email \'%2$s\' as receiver', APP_TD), $user->display_name, $paypal_email)); } $receiver_list[$key] = array('email' => $paypal_email, 'amount' => (double) $amount, 'primary' => $key == 0); $key++; } return $receiver_list; }