public function capture_payment(SI_Payment $payment) { // is this the right payment processor? does the payment still need processing? if ($payment->get_payment_method() == $this->get_payment_method() && $payment->get_status() != SI_Payment::STATUS_COMPLETE) { $data = $payment->get_data(); // Do we have a transaction ID to use for the capture? if (isset($data['api_response']['TRANSACTIONID']) && $data['api_response']['TRANSACTIONID']) { $transaction_id = $data['api_response']['TRANSACTIONID']; $post_data = $this->capture_nvp_data($transaction_id, $payment->get_amount(), $payment->get_invoice_id()); do_action('si_log', __CLASS__ . '::' . __FUNCTION__ . ' - PayPal EC DoCapture Request', $post_data); $response = wp_safe_remote_post($this->get_api_url(), array('httpversion' => '1.1', 'body' => $post_data, 'timeout' => apply_filters('http_request_timeout', 15), 'sslverify' => false)); if (!is_wp_error($response) && $response['response']['code'] == '200') { $response = wp_parse_args(wp_remote_retrieve_body($response)); do_action('si_log', __CLASS__ . '::' . __FUNCTION__ . ' - PayPal WPP DoCapture Response', $response); if (strpos($response['ACK'], 'Success') === 0) { $payment->set_status(SI_Payment::STATUS_COMPLETE); do_action('payment_complete', $payment); } else { $error = array('payment_id' => $payment->get_id(), 'response' => $response); do_action('si_error', __CLASS__ . '::' . __FUNCTION__ . ' - capture response error', $error); if ($response['L_ERRORCODE0'] == 10601 || 10602) { // authorization expired or authorization complete $payment->set_status(SI_Payment::STATUS_VOID); } } } } } }