@@ -1,12 +1,12 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly |
| 3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if (!defined('ABSPATH')) exit; |
|
| 4 | 4 | |
| 5 | -add_action( 'wpinv_worldpay_cc_form', '__return_false' ); |
|
| 5 | +add_action('wpinv_worldpay_cc_form', '__return_false'); |
|
| 6 | 6 | |
| 7 | -function wpinv_process_worldpay_payment( $purchase_data ) { |
|
| 8 | - if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) { |
|
| 9 | - wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 7 | +function wpinv_process_worldpay_payment($purchase_data) { |
|
| 8 | + if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) { |
|
| 9 | + wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | // Collect payment data |
@@ -24,120 +24,120 @@ discard block |
||
| 24 | 24 | ); |
| 25 | 25 | |
| 26 | 26 | // Record the pending payment |
| 27 | - $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] ); |
|
| 27 | + $invoice = wpinv_get_invoice($purchase_data['invoice_id']); |
|
| 28 | 28 | |
| 29 | - if ( !empty( $invoice ) ) { |
|
| 29 | + if (!empty($invoice)) { |
|
| 30 | 30 | $quantities_enabled = wpinv_item_quantities_enabled(); |
| 31 | 31 | |
| 32 | - $instId = wpinv_get_option( 'worldpay_instId', false ); |
|
| 32 | + $instId = wpinv_get_option('worldpay_instId', false); |
|
| 33 | 33 | $cartId = $invoice->get_number(); |
| 34 | - $testMode = wpinv_is_test_mode( 'worldpay' ) ? 100 : 0; |
|
| 34 | + $testMode = wpinv_is_test_mode('worldpay') ? 100 : 0; |
|
| 35 | 35 | $name = $invoice->get_user_full_name(); |
| 36 | - $address = wp_strip_all_tags( $invoice->get_address(), true ); |
|
| 36 | + $address = wp_strip_all_tags($invoice->get_address(), true); |
|
| 37 | 37 | $postcode = $invoice->zip; |
| 38 | 38 | $tel = $invoice->phone; |
| 39 | 39 | $email = $invoice->get_email(); |
| 40 | 40 | $country = $invoice->country; |
| 41 | - $amount = wpinv_sanitize_amount( $invoice->get_total() ); |
|
| 41 | + $amount = wpinv_sanitize_amount($invoice->get_total()); |
|
| 42 | 42 | $currency = wpinv_get_currency(); |
| 43 | 43 | |
| 44 | 44 | $items = array(); |
| 45 | - foreach ( $invoice->get_cart_details() as $item ) { |
|
| 45 | + foreach ($invoice->get_cart_details() as $item) { |
|
| 46 | 46 | $item_desc = $item['name']; |
| 47 | - $quantity = !empty( $item['quantity'] ) && $item['quantity'] > 0 ? $item['quantity'] : 1; |
|
| 48 | - $item_desc .= ' (' . ( $quantities_enabled ? $quantity . 'x ' : '' ) . wpinv_price( wpinv_format_amount( $item['item_price'] ) ) . ')'; |
|
| 47 | + $quantity = !empty($item['quantity']) && $item['quantity'] > 0 ? $item['quantity'] : 1; |
|
| 48 | + $item_desc .= ' (' . ($quantities_enabled ? $quantity . 'x ' : '') . wpinv_price(wpinv_format_amount($item['item_price'])) . ')'; |
|
| 49 | 49 | |
| 50 | 50 | $items[] = $item_desc; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - $desc = implode( ', ', $items ); |
|
| 54 | - if ( wpinv_use_taxes() && $invoice->get_tax() > 0 ) { |
|
| 55 | - $desc .= ', ' . wp_sprintf( __( 'Tax: %s', 'invoicing' ), $invoice->get_tax( true ) ); |
|
| 53 | + $desc = implode(', ', $items); |
|
| 54 | + if (wpinv_use_taxes() && $invoice->get_tax() > 0) { |
|
| 55 | + $desc .= ', ' . wp_sprintf(__('Tax: %s', 'invoicing'), $invoice->get_tax(true)); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $extra_params = array(); |
| 59 | 59 | $extra_params['MC_description'] = $desc; |
| 60 | - $extra_params['MC_callback'] = wpinv_get_ipn_url( 'worldpay' ); |
|
| 60 | + $extra_params['MC_callback'] = wpinv_get_ipn_url('worldpay'); |
|
| 61 | 61 | $extra_params['MC_key'] = $invoice->get_key(); |
| 62 | 62 | $extra_params['MC_invoice_id'] = $invoice->ID; |
| 63 | 63 | $extra_params['address1'] = $address; |
| 64 | 64 | $extra_params['town'] = $invoice->city; |
| 65 | 65 | $extra_params['region'] = $invoice->state; |
| 66 | - $extra_params['amountString'] = $invoice->get_total( true ); |
|
| 67 | - $extra_params['countryString'] = wpinv_country_name( $invoice->country ); |
|
| 66 | + $extra_params['amountString'] = $invoice->get_total(true); |
|
| 67 | + $extra_params['countryString'] = wpinv_country_name($invoice->country); |
|
| 68 | 68 | $extra_params['compName'] = $invoice->company; |
| 69 | 69 | |
| 70 | - $extra_params = apply_filters( 'wpinv_worldpay_form_extra_parameters', $extra_params, $invoice ); |
|
| 70 | + $extra_params = apply_filters('wpinv_worldpay_form_extra_parameters', $extra_params, $invoice); |
|
| 71 | 71 | |
| 72 | - $redirect_text = __( 'Redirecting to Worldpay site, click on button if not redirected.', 'invoicing' ); |
|
| 73 | - $redirect_text = apply_filters( 'wpinv_worldpay_redirect_text', $redirect_text, $invoice ); |
|
| 72 | + $redirect_text = __('Redirecting to Worldpay site, click on button if not redirected.', 'invoicing'); |
|
| 73 | + $redirect_text = apply_filters('wpinv_worldpay_redirect_text', $redirect_text, $invoice); |
|
| 74 | 74 | |
| 75 | 75 | // Empty the shopping cart |
| 76 | 76 | wpinv_empty_cart(); |
| 77 | 77 | ?> |
| 78 | 78 | <div class="wpi-worldpay-form" style="padding:20px;font-family:arial,sans-serif;text-align:center;color:#555"> |
| 79 | -<?php do_action( 'wpinv_worldpay_form_before', $invoice ); ?> |
|
| 80 | -<h3><?php echo $redirect_text ;?></h3> |
|
| 79 | +<?php do_action('wpinv_worldpay_form_before', $invoice); ?> |
|
| 80 | +<h3><?php echo $redirect_text; ?></h3> |
|
| 81 | 81 | <form action="<?php echo wpinv_get_worldpay_redirect(); ?>" name="wpi_worldpay_form" method="POST"> |
| 82 | - <input type="hidden" value="<?php echo $amount;?>" name="amount"> |
|
| 83 | - <input type="hidden" value="<?php echo esc_attr( $cartId );?>" name="cartId"> |
|
| 84 | - <input type="hidden" value="<?php echo $currency;?>" name="currency"> |
|
| 85 | - <input type="hidden" value="<?php echo $instId;?>" name="instId"> |
|
| 86 | - <input type="hidden" value="<?php echo $testMode;?>" name="testMode"> |
|
| 87 | - <input type="hidden" value="<?php echo esc_attr( $name );?>" name="name"> |
|
| 88 | - <input type="hidden" value="<?php echo esc_attr( $address );?>" name="address"> |
|
| 89 | - <input type="hidden" value="<?php echo esc_attr( $postcode );?>" name="postcode"> |
|
| 90 | - <input type="hidden" value="<?php echo esc_attr( $tel );?>" name="tel"> |
|
| 91 | - <input type="hidden" value="<?php echo esc_attr( $email );?>" name="email"> |
|
| 92 | - <input type="hidden" value="<?php echo esc_attr( $country );?>" name="country"> |
|
| 93 | - <input type="hidden" value="<?php echo esc_attr( $desc );?>" name="desc"> |
|
| 94 | - <?php foreach ( $extra_params as $param => $value ) { ?> |
|
| 95 | - <?php if ( !empty( $value !== false ) ) { ?> |
|
| 96 | - <input type="hidden" value="<?php echo esc_attr( $value );?>" name="<?php echo esc_attr( $param );?>"> |
|
| 82 | + <input type="hidden" value="<?php echo $amount; ?>" name="amount"> |
|
| 83 | + <input type="hidden" value="<?php echo esc_attr($cartId); ?>" name="cartId"> |
|
| 84 | + <input type="hidden" value="<?php echo $currency; ?>" name="currency"> |
|
| 85 | + <input type="hidden" value="<?php echo $instId; ?>" name="instId"> |
|
| 86 | + <input type="hidden" value="<?php echo $testMode; ?>" name="testMode"> |
|
| 87 | + <input type="hidden" value="<?php echo esc_attr($name); ?>" name="name"> |
|
| 88 | + <input type="hidden" value="<?php echo esc_attr($address); ?>" name="address"> |
|
| 89 | + <input type="hidden" value="<?php echo esc_attr($postcode); ?>" name="postcode"> |
|
| 90 | + <input type="hidden" value="<?php echo esc_attr($tel); ?>" name="tel"> |
|
| 91 | + <input type="hidden" value="<?php echo esc_attr($email); ?>" name="email"> |
|
| 92 | + <input type="hidden" value="<?php echo esc_attr($country); ?>" name="country"> |
|
| 93 | + <input type="hidden" value="<?php echo esc_attr($desc); ?>" name="desc"> |
|
| 94 | + <?php foreach ($extra_params as $param => $value) { ?> |
|
| 95 | + <?php if (!empty($value !== false)) { ?> |
|
| 96 | + <input type="hidden" value="<?php echo esc_attr($value); ?>" name="<?php echo esc_attr($param); ?>"> |
|
| 97 | 97 | <?php } ?> |
| 98 | 98 | <?php } ?> |
| 99 | - <?php do_action( 'wpinv_worldpay_form_parameters', $invoice ); ?> |
|
| 100 | - <input type="submit" name="wpi_worldpay_submit" value="<?php esc_attr_e( 'Pay by Debit/Credit Card (WorldPay)', 'invoicing' ) ;?>"> |
|
| 99 | + <?php do_action('wpinv_worldpay_form_parameters', $invoice); ?> |
|
| 100 | + <input type="submit" name="wpi_worldpay_submit" value="<?php esc_attr_e('Pay by Debit/Credit Card (WorldPay)', 'invoicing'); ?>"> |
|
| 101 | 101 | </form> |
| 102 | 102 | <script type="text/javascript">document.wpi_worldpay_form.submit();</script> |
| 103 | -<?php do_action( 'wpinv_worldpay_form_after', $invoice ); ?> |
|
| 103 | +<?php do_action('wpinv_worldpay_form_after', $invoice); ?> |
|
| 104 | 104 | </div> |
| 105 | 105 | <?php |
| 106 | 106 | } else { |
| 107 | - wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed while processing a worldpay payment. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $invoice ); |
|
| 107 | + wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed while processing a worldpay payment. Payment data: %s', 'invoicing'), json_encode($payment_data)), $invoice); |
|
| 108 | 108 | // If errors are present, send the user back to the purchase page so they can be corrected |
| 109 | - wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] ); |
|
| 109 | + wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']); |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | -add_action( 'wpinv_gateway_worldpay', 'wpinv_process_worldpay_payment' ); |
|
| 112 | +add_action('wpinv_gateway_worldpay', 'wpinv_process_worldpay_payment'); |
|
| 113 | 113 | |
| 114 | 114 | function wpinv_get_worldpay_redirect() { |
| 115 | - $redirect = wpinv_is_test_mode( 'worldpay' ) ? 'https://secure-test.worldpay.com/wcc/purchase' : 'https://secure.worldpay.com/wcc/purchase'; |
|
| 115 | + $redirect = wpinv_is_test_mode('worldpay') ? 'https://secure-test.worldpay.com/wcc/purchase' : 'https://secure.worldpay.com/wcc/purchase'; |
|
| 116 | 116 | |
| 117 | - return apply_filters( 'wpinv_worldpay_redirect', $redirect ); |
|
| 117 | + return apply_filters('wpinv_worldpay_redirect', $redirect); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | function wpinv_process_worldpay_ipn() { |
| 121 | - $request = wpinv_get_post_data( 'post' ); |
|
| 121 | + $request = wpinv_get_post_data('post'); |
|
| 122 | 122 | |
| 123 | - if ( !empty( $request['cartId'] ) && !empty( $request['transStatus'] ) && !empty( $request['installation'] ) && isset( $request['testMode'] ) && isset( $request['MC_invoice_id'] ) && isset( $request['MC_key'] ) ) { |
|
| 123 | + if (!empty($request['cartId']) && !empty($request['transStatus']) && !empty($request['installation']) && isset($request['testMode']) && isset($request['MC_invoice_id']) && isset($request['MC_key'])) { |
|
| 124 | 124 | $invoice_id = $request['MC_invoice_id']; |
| 125 | 125 | |
| 126 | - if ( $invoice_id == wpinv_get_invoice_id_by_key( $request['MC_key'] ) && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
|
| 127 | - if ( $request['transStatus'] == 'Y' ) { |
|
| 128 | - wpinv_update_payment_status( $invoice_id, 'publish' ); |
|
| 129 | - wpinv_set_payment_transaction_id( $invoice_id, $request['transId'] ); |
|
| 130 | - wpinv_insert_payment_note( $invoice_id, sprintf( __( 'Worldpay Transaction ID: %s', 'invoicing' ), $request['transId'] ) ); |
|
| 126 | + if ($invoice_id == wpinv_get_invoice_id_by_key($request['MC_key']) && $invoice = wpinv_get_invoice($invoice_id)) { |
|
| 127 | + if ($request['transStatus'] == 'Y') { |
|
| 128 | + wpinv_update_payment_status($invoice_id, 'publish'); |
|
| 129 | + wpinv_set_payment_transaction_id($invoice_id, $request['transId']); |
|
| 130 | + wpinv_insert_payment_note($invoice_id, sprintf(__('Worldpay Transaction ID: %s', 'invoicing'), $request['transId'])); |
|
| 131 | 131 | return; |
| 132 | - } else if ( $request['transStatus'] == 'C' ) { |
|
| 133 | - wpinv_update_payment_status( $invoice_id, 'failed' ); |
|
| 134 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment transaction failed while processing Worldpay payment, kindly check IPN log.', 'invoicing' ) ); |
|
| 132 | + } else if ($request['transStatus'] == 'C') { |
|
| 133 | + wpinv_update_payment_status($invoice_id, 'failed'); |
|
| 134 | + wpinv_insert_payment_note($invoice_id, __('Payment transaction failed while processing Worldpay payment, kindly check IPN log.', 'invoicing')); |
|
| 135 | 135 | |
| 136 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Payment transaction failed while processing Worldpay payment. IPN data: %s', 'invoicing' ), json_encode( $request ) ), $invoice_id ); |
|
| 136 | + wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Payment transaction failed while processing Worldpay payment. IPN data: %s', 'invoicing'), json_encode($request)), $invoice_id); |
|
| 137 | 137 | return; |
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | return; |
| 142 | 142 | } |
| 143 | -add_action( 'wpinv_verify_worldpay_ipn', 'wpinv_process_worldpay_ipn' ); |
|
| 144 | 143 | \ No newline at end of file |
| 144 | +add_action('wpinv_verify_worldpay_ipn', 'wpinv_process_worldpay_ipn'); |
|
| 145 | 145 | \ No newline at end of file |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | public function __construct($login, $transkey, $test = self::USE_PRODUCTION_SERVER) |
| 52 | 52 | { |
| 53 | - $login = trim($login); |
|
| 53 | + $login = trim($login); |
|
| 54 | 54 | $transkey = trim($transkey); |
| 55 | 55 | if (empty($login) || empty($transkey)) |
| 56 | 56 | { |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | $this->login = trim($login); |
| 61 | 61 | $this->transkey = trim($transkey); |
| 62 | - $test = (bool) $test; |
|
| 62 | + $test = (bool)$test; |
|
| 63 | 63 | |
| 64 | 64 | $subdomain = ($test) ? 'apitest' : 'api'; |
| 65 | 65 | $this->url = 'https://' . $subdomain . '.authorize.net/xml/v1/request.api'; |
@@ -73,14 +73,14 @@ discard block |
||
| 73 | 73 | private function removeResponseXMLNS($input) |
| 74 | 74 | { |
| 75 | 75 | // why remove them one at a time? all three aren't consistantly used in the response |
| 76 | - $input = str_replace(' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"','',$input); |
|
| 77 | - $input = str_replace(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"','',$input); |
|
| 78 | - return str_replace(' xmlns:xsd="http://www.w3.org/2001/XMLSchema"','',$input); |
|
| 76 | + $input = str_replace(' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"', '', $input); |
|
| 77 | + $input = str_replace(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"', '', $input); |
|
| 78 | + return str_replace(' xmlns:xsd="http://www.w3.org/2001/XMLSchema"', '', $input); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | public function __toString() |
| 82 | 82 | { |
| 83 | - $output = ''; |
|
| 83 | + $output = ''; |
|
| 84 | 84 | $output .= '<table summary="Authorize.Net Results" id="authnet">' . "\n"; |
| 85 | 85 | $output .= '<tr>' . "\n\t\t" . '<th colspan="2"><b>Class Parameters</b></th>' . "\n" . '</tr>' . "\n"; |
| 86 | 86 | $output .= '<tr>' . "\n\t\t" . '<td><b>API Login ID</b></td><td>' . $this->login . '</td>' . "\n" . '</tr>' . "\n"; |
@@ -159,9 +159,9 @@ discard block |
||
| 159 | 159 | { |
| 160 | 160 | if (is_array($value)) |
| 161 | 161 | { |
| 162 | - if(is_numeric($key)) |
|
| 162 | + if (is_numeric($key)) |
|
| 163 | 163 | { |
| 164 | - if($first === true) |
|
| 164 | + if ($first === true) |
|
| 165 | 165 | { |
| 166 | 166 | $xmlx = $xml; |
| 167 | 167 | $first = false; |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 2); |
| 201 | 201 | curl_setopt($this->ch, CURLOPT_CAINFO, dirname(__FILE__) . '/ssl/cert.pem'); |
| 202 | 202 | |
| 203 | - if(($this->response = curl_exec($this->ch)) !== false) |
|
| 203 | + if (($this->response = curl_exec($this->ch)) !== false) |
|
| 204 | 204 | { |
| 205 | 205 | $this->response_xml = @new SimpleXMLElement($this->response); |
| 206 | 206 | |
@@ -77,19 +77,19 @@ discard block |
||
| 77 | 77 | * A list of all fields in the AIM API. |
| 78 | 78 | * Used to warn user if they try to set a field not offered in the API. |
| 79 | 79 | */ |
| 80 | - private $_all_aim_fields = array("address","allow_partial_auth","amount", |
|
| 81 | - "auth_code","authentication_indicator", "bank_aba_code","bank_acct_name", |
|
| 82 | - "bank_acct_num","bank_acct_type","bank_check_number","bank_name", |
|
| 83 | - "card_code","card_num","cardholder_authentication_value","city","company", |
|
| 84 | - "country","cust_id","customer_ip","delim_char","delim_data","description", |
|
| 85 | - "duplicate_window","duty","echeck_type","email","email_customer", |
|
| 86 | - "encap_char","exp_date","fax","first_name","footer_email_receipt", |
|
| 87 | - "freight","header_email_receipt","invoice_num","last_name","line_item", |
|
| 88 | - "login","method","phone","po_num","recurring_billing","relay_response", |
|
| 89 | - "ship_to_address","ship_to_city","ship_to_company","ship_to_country", |
|
| 90 | - "ship_to_first_name","ship_to_last_name","ship_to_state","ship_to_zip", |
|
| 91 | - "split_tender_id","state","tax","tax_exempt","test_request","tran_key", |
|
| 92 | - "trans_id","type","version","zip" |
|
| 80 | + private $_all_aim_fields = array("address", "allow_partial_auth", "amount", |
|
| 81 | + "auth_code", "authentication_indicator", "bank_aba_code", "bank_acct_name", |
|
| 82 | + "bank_acct_num", "bank_acct_type", "bank_check_number", "bank_name", |
|
| 83 | + "card_code", "card_num", "cardholder_authentication_value", "city", "company", |
|
| 84 | + "country", "cust_id", "customer_ip", "delim_char", "delim_data", "description", |
|
| 85 | + "duplicate_window", "duty", "echeck_type", "email", "email_customer", |
|
| 86 | + "encap_char", "exp_date", "fax", "first_name", "footer_email_receipt", |
|
| 87 | + "freight", "header_email_receipt", "invoice_num", "last_name", "line_item", |
|
| 88 | + "login", "method", "phone", "po_num", "recurring_billing", "relay_response", |
|
| 89 | + "ship_to_address", "ship_to_city", "ship_to_company", "ship_to_country", |
|
| 90 | + "ship_to_first_name", "ship_to_last_name", "ship_to_state", "ship_to_zip", |
|
| 91 | + "split_tender_id", "state", "tax", "tax_exempt", "test_request", "tran_key", |
|
| 92 | + "trans_id", "type", "version", "zip" |
|
| 93 | 93 | ); |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | // Split Array |
| 404 | 404 | $this->response = $response; |
| 405 | 405 | if ($encap_char) { |
| 406 | - $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1)); |
|
| 406 | + $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1)); |
|
| 407 | 407 | } else { |
| 408 | 408 | $this->_response_array = explode($delimiter, $response); |
| 409 | 409 | } |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | $this->duty = $this->_response_array[33]; |
| 458 | 458 | $this->freight = $this->_response_array[34]; |
| 459 | 459 | $this->tax_exempt = $this->_response_array[35]; |
| 460 | - $this->purchase_order_number= $this->_response_array[36]; |
|
| 460 | + $this->purchase_order_number = $this->_response_array[36]; |
|
| 461 | 461 | $this->md5_hash = $this->_response_array[37]; |
| 462 | 462 | $this->card_code_response = $this->_response_array[38]; |
| 463 | 463 | $this->cavv_response = $this->_response_array[39]; |
@@ -484,10 +484,10 @@ discard block |
||
| 484 | 484 | |
| 485 | 485 | if ($this->error) { |
| 486 | 486 | $this->error_message = "AuthorizeNet Error: |
| 487 | - Response Code: ".$this->response_code." |
|
| 488 | - Response Subcode: ".$this->response_subcode." |
|
| 489 | - Response Reason Code: ".$this->response_reason_code." |
|
| 490 | - Response Reason Text: ".$this->response_reason_text." |
|
| 487 | + Response Code: ".$this->response_code . " |
|
| 488 | + Response Subcode: ".$this->response_subcode . " |
|
| 489 | + Response Reason Code: ".$this->response_reason_code . " |
|
| 490 | + Response Reason Text: ".$this->response_reason_text . " |
|
| 491 | 491 | "; |
| 492 | 492 | } |
| 493 | 493 | } else { |
@@ -96,7 +96,7 @@ |
||
| 96 | 96 | curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if (preg_match('/xml/',$post_url)) { |
|
| 99 | + if (preg_match('/xml/', $post_url)) { |
|
| 100 | 100 | curl_setopt($curl_request, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | $this->xml = @simplexml_load_string($response); |
| 30 | 30 | |
| 31 | 31 | // Remove namespaces for use with XPath. |
| 32 | - $this->xpath_xml = @simplexml_load_string(preg_replace('/ xmlns:xsi[^>]+/','',$response)); |
|
| 32 | + $this->xpath_xml = @simplexml_load_string(preg_replace('/ xmlns:xsi[^>]+/', '', $response)); |
|
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | { |
| 117 | 117 | $start = "<$elementName>"; |
| 118 | 118 | $end = "</$elementName>"; |
| 119 | - if (strpos($this->response,$start) === false || strpos($this->response,$end) === false) { |
|
| 119 | + if (strpos($this->response, $start) === false || strpos($this->response, $end) === false) { |
|
| 120 | 120 | return false; |
| 121 | 121 | } else { |
| 122 | - $start_position = strpos($this->response, $start)+strlen($start); |
|
| 122 | + $start_position = strpos($this->response, $start) + strlen($start); |
|
| 123 | 123 | $end_position = strpos($this->response, $end); |
| 124 | - return substr($this->response, $start_position, $end_position-$start_position); |
|
| 124 | + return substr($this->response, $start_position, $end_position - $start_position); |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | |
@@ -182,7 +182,7 @@ |
||
| 182 | 182 | $string = ""; |
| 183 | 183 | foreach ($array as $key => $value) { |
| 184 | 184 | if ($value) { |
| 185 | - $string .= '<input type="hidden" name="'.$key.'" value="'.$value.'">'; |
|
| 185 | + $string .= '<input type="hidden" name="' . $key . '" value="' . $value . '">'; |
|
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | return $string; |
@@ -116,7 +116,7 @@ |
||
| 116 | 116 | */ |
| 117 | 117 | protected function _setPostString() |
| 118 | 118 | { |
| 119 | - $this->_post_string =<<<XML |
|
| 119 | + $this->_post_string = <<<XML |
|
| 120 | 120 | <?xml version="1.0" encoding="utf-8"?> |
| 121 | 121 | <ARB{$this->_request_type} xmlns= "AnetApi/xml/v1/schema/AnetApiSchema.xsd"> |
| 122 | 122 | <merchantAuthentication> |
@@ -309,10 +309,10 @@ discard block |
||
| 309 | 309 | { |
| 310 | 310 | $this->_validationMode = $validationMode; |
| 311 | 311 | $this->_constructXml("validateCustomerPaymentProfileRequest"); |
| 312 | - $this->_xml->addChild("customerProfileId",$customerProfileId); |
|
| 313 | - $this->_xml->addChild("customerPaymentProfileId",$customerPaymentProfileId); |
|
| 314 | - $this->_xml->addChild("customerShippingAddressId",$customerShippingAddressId); |
|
| 315 | - $this->_xml->addChild("cardCode",$cardCode); |
|
| 312 | + $this->_xml->addChild("customerProfileId", $customerProfileId); |
|
| 313 | + $this->_xml->addChild("customerPaymentProfileId", $customerPaymentProfileId); |
|
| 314 | + $this->_xml->addChild("customerShippingAddressId", $customerShippingAddressId); |
|
| 315 | + $this->_xml->addChild("cardCode", $cardCode); |
|
| 316 | 316 | return $this->_sendRequest(); |
| 317 | 317 | } |
| 318 | 318 | |
@@ -341,13 +341,13 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | protected function _setPostString() |
| 343 | 343 | { |
| 344 | - ($this->_validationMode != "none" ? $this->_xml->addChild('validationMode',$this->_validationMode) : ""); |
|
| 344 | + ($this->_validationMode != "none" ? $this->_xml->addChild('validationMode', $this->_validationMode) : ""); |
|
| 345 | 345 | $this->_post_string = $this->_xml->asXML(); |
| 346 | 346 | |
| 347 | 347 | // Add extraOptions CDATA |
| 348 | 348 | if ($this->_extraOptions) { |
| 349 | 349 | $this->_xml->addChild("extraOptions"); |
| 350 | - $this->_post_string = str_replace("<extraOptions></extraOptions>",'<extraOptions><![CDATA[' . $this->_extraOptions . ']]></extraOptions>', $this->_xml->asXML()); |
|
| 350 | + $this->_post_string = str_replace("<extraOptions></extraOptions>", '<extraOptions><![CDATA[' . $this->_extraOptions . ']]></extraOptions>', $this->_xml->asXML()); |
|
| 351 | 351 | $this->_extraOptions = false; |
| 352 | 352 | } |
| 353 | 353 | // Blank out our validation mode, so that we don't include it in calls that |
@@ -362,12 +362,12 @@ discard block |
||
| 362 | 362 | */ |
| 363 | 363 | private function _constructXml($request_type) |
| 364 | 364 | { |
| 365 | - $string = '<?xml version="1.0" encoding="utf-8"?><'.$request_type.' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></'.$request_type.'>'; |
|
| 365 | + $string = '<?xml version="1.0" encoding="utf-8"?><' . $request_type . ' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></' . $request_type . '>'; |
|
| 366 | 366 | $this->_xml = @new SimpleXMLElement($string); |
| 367 | 367 | $merchant = $this->_xml->addChild('merchantAuthentication'); |
| 368 | - $merchant->addChild('name',$this->_api_login); |
|
| 369 | - $merchant->addChild('transactionKey',$this->_transaction_key); |
|
| 370 | - ($this->_refId ? $this->_xml->addChild('refId',$this->_refId) : ""); |
|
| 368 | + $merchant->addChild('name', $this->_api_login); |
|
| 369 | + $merchant->addChild('transactionKey', $this->_transaction_key); |
|
| 370 | + ($this->_refId ? $this->_xml->addChild('refId', $this->_refId) : ""); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | /** |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | $this->_addObject($items, $item); |
| 388 | 388 | } |
| 389 | 389 | } else { |
| 390 | - $destination->addChild($key,$value); |
|
| 390 | + $destination->addChild($key, $value); |
|
| 391 | 391 | } |
| 392 | 392 | } elseif (is_object($value) && self::_notEmpty($value)) { |
| 393 | 393 | $dest = $destination->addChild($key); |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | $this->xml = @simplexml_load_string($response); |
| 118 | 118 | // Set all fields |
| 119 | - $this->version = array_pop(array_slice(explode('"', $response), 1,1)); |
|
| 119 | + $this->version = array_pop(array_slice(explode('"', $response), 1, 1)); |
|
| 120 | 120 | $this->response_code = (string)$this->xml->ResponseCode; |
| 121 | 121 | |
| 122 | 122 | if ($this->response_code == 1) { |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | // Split Array |
| 145 | 145 | $this->response = $response; |
| 146 | 146 | if ($encap_char) { |
| 147 | - $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1)); |
|
| 147 | + $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1)); |
|
| 148 | 148 | } else { |
| 149 | 149 | $this->_response_array = explode($delimiter, $response); |
| 150 | 150 | } |
@@ -190,9 +190,9 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | if ($this->error) { |
| 192 | 192 | $this->error_message = "AuthorizeNet Error: |
| 193 | - Response Code: ".$this->response_code." |
|
| 194 | - Response Reason Code: ".$this->response_reason_code." |
|
| 195 | - Response Reason Text: ".$this->response_reason_text." |
|
| 193 | + Response Code: ".$this->response_code . " |
|
| 194 | + Response Reason Code: ".$this->response_reason_code . " |
|
| 195 | + Response Reason Text: ".$this->response_reason_text . " |
|
| 196 | 196 | "; |
| 197 | 197 | } |
| 198 | 198 | |