Advertisement
BakerMan

Revised function: Event_Tickets_PRO::payment_update()

Nov 9th, 2012
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.57 KB | None | 0 0
  1. public function payment_update( $postId, $eventId, $post ) {
  2.     $paymentTypes = array('check' => '', 'cash' => '', 'invoice' => '');
  3.     $requestParams = 'event_id=' . $eventId;
  4.  
  5.     // make it accept cash if free & assign a message
  6.     if ( 2 == $post['EventBriteIsDonation'] ) {
  7.         $requestParams .= '&accept_cash=1';
  8.         $requestParams .= '&instructions_cash=' . urlencode( __( 'This event is free to attend', 'tribe-eventbrite' ) );
  9.     } else {
  10.         // otherwise loop through the payment methods as it's supposed to
  11.         foreach( $paymentTypes as $key => $val ) {
  12.             $onOff = $post['EventBritePayment_accept_' . $key];
  13.             if ( $onOff ) $requestParams .= '&accept_' . $key . '=' . $onOff;
  14.             $paymentTypes[$key] = $onOff;
  15.         }
  16.         foreach( $paymentTypes as $key => $val ) {
  17.             if ( $val ) {
  18.            $instructions = $post['EventBritePayment_instructions_'.$key];
  19.            if ( $instructions ) $requestParams .= '&instructions_' . $key . '=' . urlencode( stripslashes( $instructions ) );
  20.             }
  21.         }
  22.  
  23.     // Online payment method is either/or (not both)
  24.     $onlineMethod = $post['EventBritePayment_accept_online'];
  25.     if ( !empty( $post['EventBritePayment_accept_online'] ) ) {
  26.         switch( $onlineMethod ) {
  27.         case 'paypal':
  28.             $requestParams .= '&accept_paypal=1&paypal_email=' . $post['EventBritePayment_paypal_email'];
  29.                     break;
  30.           case 'google':
  31.             $requestParams .= '&accept_google=1&google_merchant_id=' . $post['EventBritePayment_google_merchant_id'] . '&google_merchant_key=' . $post['EventBritePayment_google_merchant_key'];
  32.            break;
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement