/** * Setup the DoCapture request * * @link https://developer.paypal.com/webapps/developer/docs/classic/api/merchant/DoCapture_API_Operation_NVP/ * @link https://developer.paypal.com/webapps/developer/docs/classic/admin/auth-capture/ * * @since 3.0.0 * @param WC_Order $order order object */ public function do_capture(WC_Order $order) { $this->set_method('DoCapture'); $this->add_parameters(array('AUTHORIZATIONID' => $order->paypal_express_transaction_id, 'AMT' => $order->capture_total, 'CURRENCYCODE' => $order->get_order_currency(), 'COMPLETETYPE' => 'Complete', 'INVNUM' => $order->paypal_express_invoice_prefix . SV_WC_Helper::str_to_ascii(ltrim($order->get_order_number(), _x('#', 'hash before the order number', WC_PayPal_Express::TEXT_DOMAIN))), 'NOTE' => $order->description)); }
/** * Add the credit credit card charge or auth elements * * Note: It's important that these elements appear in the expected order, * otherwise there will be parsing errors returned from the QBMS API * * @since 1.0 * @param string $request_type one of CustomerCreditCardChargeRq or CustomerCreditCardAuthRq * @param WC_Order $order the order object */ private function credit_card_charge_auth_request($request_type, $order) { // store the order object for later use $this->order = $order; $this->init_document(); // <QBMSXMLMsgsRq> $this->startElement('QBMSXMLMsgsRq'); // this is the only difference between cc charge/auth requests // <CustomerCreditCardChargeRq>|<CustomerCreditCardAuthRq> $this->startElement($request_type); $this->writeElement('TransRequestID', $order->trans_request_id); if (isset($order->payment->token) && $order->payment->token) { $this->writeElement('WalletEntryID', $order->payment->token); $this->writeElement('CustomerID', $order->customer_id); $this->writeElement('Amount', $order->payment_total); $this->writeElement('IsECommerce', true); } else { $this->writeElement('CreditCardNumber', substr($order->payment->account_number, 0, 19)); $this->writeElement('ExpirationMonth', substr($order->payment->exp_month, 0, 12)); $this->writeElement('ExpirationYear', $order->payment->exp_year); $this->writeElement('IsECommerce', true); $this->writeElement('Amount', $order->payment_total); $this->writeElement('NameOnCard', substr(isset($order->intuit_qbms_test_condition) ? 'configid=' . $order->intuit_qbms_test_condition : SV_WC_Helper::str_to_ascii($order->billing_first_name . ' ' . $order->billing_last_name), 0, 30)); $this->writeElement('CreditCardAddress', substr(SV_WC_Helper::str_to_ascii(empty($order->billing_address_2) ? $order->billing_address_1 : $order->billing_address_1 . ' ' . $order->billing_address_2), 0, 30)); $this->writeElement('CreditCardCity', substr(SV_WC_Helper::str_to_ascii($order->billing_city), 0, 50)); $this->writeElement('CreditCardState', substr(SV_WC_Helper::str_to_ascii($order->billing_state), 0, 20)); $this->writeElement('CreditCardPostalCode', substr(SV_WC_Helper::str_to_ascii(str_replace('-', '', $order->billing_postcode)), 0, 9)); } $this->writeElement('SalesTaxAmount', number_format($order->get_total_tax(), 2, '.', '')); if (isset($order->payment->csc)) { $this->writeElement('CardSecurityCode', substr($order->payment->csc, 0, 4)); } $this->writeElement('InvoiceID', substr(SV_WC_Helper::str_to_ascii(ltrim($order->get_order_number(), _x('#', 'hash before order number', 'woocommerce-gateway-intuit-qbms'))), 0, 100)); // customer identifier for non-guest transactions if (isset($order->customer_id) && $order->customer_id) { $this->writeElement('UserID', substr($order->customer_id, 0, 100)); } // Set the request comment to the order note by default $comment = $order->customer_note; /** * Filter the request comment sent to Intuit. * * @since 1.7.2 * @param string $comment The request comment. * @param object $order The WooCommerce order. */ $comment = (string) apply_filters('wc_payment_gateway_intuit_qbms_credit_card_request_comment', $comment, $order); // Optionally add the comment to the request if ($comment) { // Format the comment for the API $comment = SV_WC_Helper::str_truncate(SV_WC_Helper::str_to_ascii($comment), 4000); $this->writeElement('Comment', $comment); } // root element <GeoLocationInfo> $this->startElement('GeoLocationInfo'); $this->writeElement('IPAddress', substr($_SERVER['REMOTE_ADDR'], 0, 15)); // </GeoLocationInfo> $this->endElement(); // </CustomerCreditCardChargeRq> | </CustomerCreditCardAuthRq> $this->endElement(); // </QBMSXMLMsgsRq> $this->endElement(); $this->close_document(); }