Give_Helper_Payment::create_simple_payment PHP Method

create_simple_payment() public static method

Create a simple donation payment.
Since: 1.0
public static create_simple_payment ( )
    public static function create_simple_payment()
    {
        global $give_options;
        // Enable a few options
        $give_options['enable_sequential'] = '1';
        //Not yet in use
        $give_options['sequential_prefix'] = 'GIVE-';
        //Not yet in use
        update_option('give_settings', $give_options);
        $simple_form = Give_Helper_Form::create_simple_form();
        // Generate some donations
        $user = get_userdata(1);
        $user_info = array('id' => $user->ID, 'email' => $user->user_email, 'first_name' => $user->first_name, 'last_name' => $user->last_name);
        $simple_price = get_post_meta($simple_form->ID, '_give_set_price', true);
        $purchase_data = array('price' => number_format((double) $simple_price, 2), 'give_form_title' => 'Test Donation Form', 'give_form_id' => $simple_form->ID, 'date' => date('Y-m-d H:i:s', strtotime('-1 day')), 'purchase_key' => strtolower(md5(uniqid())), 'user_email' => $user_info['email'], 'user_info' => $user_info, 'currency' => 'USD', 'status' => 'pending');
        $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
        $_SERVER['SERVER_NAME'] = 'give_virtual';
        $payment_id = give_insert_payment($purchase_data);
        $transaction_id = 'FIR3SID3';
        $payment = new Give_Payment($payment_id);
        $payment->transaction_id = $transaction_id;
        $payment->save();
        give_insert_payment_note($payment_id, sprintf(esc_html__('PayPal Transaction ID: %s', 'give'), $transaction_id));
        return $payment_id;
    }

Usage Example

Beispiel #1
0
 /**
  * Set it Up
  */
 public function setUp()
 {
     parent::setUp();
     $this->_payment_id = Give_Helper_Payment::create_simple_payment();
     //$20
     $this->_payment_id2 = Give_Helper_Payment::create_multilevel_payment();
     //$25
     give_update_payment_status($this->_payment_id);
     give_update_payment_status($this->_payment_id2);
 }
All Usage Examples Of Give_Helper_Payment::create_simple_payment