Changeset 1479700
- Timestamp:
- 08/20/2016 10:12:27 PM (8 years ago)
- Location:
- woocommerce-gateway-paypal-express-checkout/trunk
- Files:
-
- 4 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
woocommerce-gateway-paypal-express-checkout/trunk/includes/abstracts/abstract-wc-gateway-ppec.php
r1470867 r1479700 235 235 236 236 if ( empty( $password ) ) { 237 WC_Admin_Settings::add_error( sprintf( __( 'Error: You must enter a %s API password.' ), __( $settings->get_environment(), 'woocommerce-gateway-paypal-express-checkout' )) );237 WC_Admin_Settings::add_error( ) ); 238 238 return false; 239 239 } … … 456 456 */ 457 457 public function is_available() { 458 if ( 'yes' !== $this->enabled ) { 459 return false; 460 } 461 return true; 458 return 'yes' === $this->enabled; 462 459 } 463 460 } -
woocommerce-gateway-paypal-express-checkout/trunk/includes/class-wc-gateway-ppec-checkout-handler.php
r1470458 r1479700 407 407 } 408 408 409 410 411 412 413 414 415 409 416 protected function is_success( $response ) { 410 if ( 'Success' == $response['ACK'] || 'SuccessWithWarning' == $response['ACK'] ) {411 return true;412 } else {413 return false;414 }417 418 419 420 421 415 422 } 416 423 … … 550 557 $response = wc_gateway_ppec()->client->get_express_checkout_details( $token ); 551 558 552 if ( 'Success' == $response['ACK'] || 'SuccessWithWarning' == $response['ACK']) {559 if ( ) { 553 560 $checkout_details = new PayPal_Checkout_Details(); 554 561 $checkout_details->loadFromGetECResponse( $response ); … … 575 582 // Generate params to send to paypal, then do request 576 583 $response = wc_gateway_ppec()->client->do_express_checkout_payment( array_merge( 577 $settings->get_do_express_checkout_params(),578 584 $this->getDoExpressCheckoutParameters( $token, $payerID ), 579 array( 580 'PAYMENTREQUEST_0_INVNUM' => $settings->invoice_prefix . $order->get_order_number(), 581 ) 585 $settings->get_do_express_checkout_params( $order ) 582 586 ) ); 583 587 -
woocommerce-gateway-paypal-express-checkout/trunk/includes/class-wc-gateway-ppec-client-credential-certificate.php
r1409404 r1479700 64 64 65 65 if ( false === curl_setopt( $handle, CURLOPT_SSLCERT, $certificate_file ) ) { 66 throw new Exception( __( 'Unable to accept certificate during cURL configuration', 'woocommerce-gateway-p pec' ), WC_Gateway_PPEC_Client::INVALID_ENVIRONMENT_ERROR );66 throw new Exception( __( 'Unable to accept certificate during cURL configuration', 'woocommerce-gateway-p' ), WC_Gateway_PPEC_Client::INVALID_ENVIRONMENT_ERROR ); 67 67 } 68 68 69 69 if ( $this->_use_secure_transport() && false === curl_setopt( $handle, CURLOPT_SSLCERTPASSWD, $password ) ) { 70 throw new Exception( __( 'Unable to accept certificate password during cURL configuration', 'woocommerce-gateway-p pec' ), WC_Gateway_PPEC_Client::INVALID_ENVIRONMENT_ERROR );70 throw new Exception( __( 'Unable to accept certificate password during cURL configuration', 'woocommerce-gateway-p' ), WC_Gateway_PPEC_Client::INVALID_ENVIRONMENT_ERROR ); 71 71 } 72 72 } … … 85 85 $temp_file = tempnam( sys_get_temp_dir(), 'pptmp_' ); 86 86 if ( ! $temp_file ) { 87 throw new Exception( sprintf( __( 'Unable to write certificate file %s during cURL configuration', 'woocommerce-gateway-p pec' ), $temp_file ), WC_Gateway_PPEC_Client::INVALID_ENVIRONMENT_ERROR );87 throw new Exception( sprintf( __( 'Unable to write certificate file %s during cURL configuration', 'woocommerce-gateway-p' ), $temp_file ), WC_Gateway_PPEC_Client::INVALID_ENVIRONMENT_ERROR ); 88 88 } 89 89 … … 111 111 112 112 if ( false === $private_key ) { 113 throw new Exception( __( 'Failed to retrieve private key during cURL configuration', 'woocommerce-gateway-p pec' ), WC_Gateway_PPEC_Client::INVALID_ENVIRONMENT_ERROR );113 throw new Exception( __( 'Failed to retrieve private key during cURL configuration', 'woocommerce-gateway-p' ), WC_Gateway_PPEC_Client::INVALID_ENVIRONMENT_ERROR ); 114 114 } 115 115 116 116 if ( ! openssl_pkcs12_export_to_file( $this->_certificate, $temp_file, $private_key, $password ) ) { 117 throw new Exception( __( 'Failed to export PKCS12 file during cURL configuration', 'woocommerce-gateway-p pec' ), WC_Gateway_PPEC_Client::INVALID_ENVIRONMENT_ERROR );117 throw new Exception( __( 'Failed to export PKCS12 file during cURL configuration', 'woocommerce-gateway-p' ), WC_Gateway_PPEC_Client::INVALID_ENVIRONMENT_ERROR ); 118 118 } 119 119 } … … 131 131 protected function _maybe_create_non_secure_certificate_file( $temp_file ) { 132 132 if ( false === file_put_contents( $temp_file, $this->_certificate ) ) { 133 throw new Exception( sprintf( __( 'Unable to write certificate file %s during cURL configuration', 'woocommerce-gateway-p pec' ), $temp_file ), WC_Gateway_PPEC_Client::INVALID_ENVIRONMENT_ERROR );133 throw new Exception( sprintf( __( 'Unable to write certificate file %s during cURL configuration', 'woocommerce-gateway-p' ), $temp_file ), WC_Gateway_PPEC_Client::INVALID_ENVIRONMENT_ERROR ); 134 134 } 135 135 } -
woocommerce-gateway-paypal-express-checkout/trunk/includes/class-wc-gateway-ppec-client.php
r1470458 r1479700 119 119 // Make sure $_credential and $_environment have been configured. 120 120 if ( ! $this->_credential ) { 121 throw new Exception( __( 'Missing credential', 'woocommerce-gateway-p pec' ), self::INVALID_CREDENTIAL_ERROR );121 throw new Exception( __( 'Missing credential', 'woocommerce-gateway-p' ), self::INVALID_CREDENTIAL_ERROR ); 122 122 } 123 123 124 124 if ( ! is_a( $this->_credential, 'WC_Gateway_PPEC_Client_Credential' ) ) { 125 throw new Exception( __( 'Invalid credential object', 'woocommerce-gateway-p pec' ), self::INVALID_CREDENTIAL_ERROR );125 throw new Exception( __( 'Invalid credential object', 'woocommerce-gateway-p' ), self::INVALID_CREDENTIAL_ERROR ); 126 126 } 127 127 128 128 if ( ! in_array( $this->_environment, array( 'live', 'sandbox' ) ) ) { 129 throw new Exception( __( 'Invalid environment', 'woocommerce-gateway-p pec' ), self::INVALID_ENVIRONMENT_ERROR );129 throw new Exception( __( 'Invalid environment', 'woocommerce-gateway-p' ), self::INVALID_ENVIRONMENT_ERROR ); 130 130 } 131 131 … … 150 150 151 151 if ( is_wp_error( $resp ) ) { 152 throw new Exception( sprintf( __( 'An error occurred while trying to connect to PayPal: %s', 'woocommerce-gateway-p pec' ), $resp->get_error_message() ), self::REQUEST_ERROR );152 throw new Exception( sprintf( __( 'An error occurred while trying to connect to PayPal: %s', 'woocommerce-gateway-p' ), $resp->get_error_message() ), self::REQUEST_ERROR ); 153 153 } 154 154 … … 156 156 157 157 if ( ! array_key_exists( 'ACK', $result ) ) { 158 throw new Exception( __( 'Malformed response received from PayPal', 'woocommerce-gateway-p pec' ), self::REQUEST_ERROR );158 throw new Exception( __( 'Malformed response received from PayPal', 'woocommerce-gateway-p' ), self::REQUEST_ERROR ); 159 159 } 160 160 -
woocommerce-gateway-paypal-express-checkout/trunk/includes/class-wc-gateway-ppec-plugin.php
r1470458 r1479700 145 145 add_action( 'plugins_loaded', array( $this, 'bootstrap' ) ); 146 146 add_filter( 'allowed_redirect_hosts' , array( $this, 'whitelist_paypal_domains_for_redirect' ) ); 147 147 148 } 148 149 … … 287 288 require_once( $this->includes_path . 'class-wc-gateway-ppec-cart-handler.php' ); 288 289 require_once( $this->includes_path . 'class-wc-gateway-ppec-ips-handler.php' ); 290 291 289 292 290 293 $this->settings = new WC_Gateway_PPEC_Settings(); … … 337 340 return $domains; 338 341 } 342 343 344 345 346 347 348 349 350 339 351 } -
woocommerce-gateway-paypal-express-checkout/trunk/includes/class-wc-gateway-ppec-settings.php
r1470458 r1479700 115 115 } 116 116 117 if ( false ===apply_filters( 'woocommerce_paypal_express_checkout_allow_guests', true ) ) {117 if ( apply_filters( 'woocommerce_paypal_express_checkout_allow_guests', true ) ) { 118 118 $params['SOLUTIONTYPE'] = 'Sole'; 119 119 } … … 175 175 return $params; 176 176 } 177 public function get_do_express_checkout_params( $buckets = 1 ) { 177 178 /** 179 * Get base parameters, based on settings instance, for DoExpressCheckoutCheckout NVP call. 180 * 181 * @see https://developer.paypal.com/docs/classic/api/merchant/DoExpressCheckoutPayment_API_Operation_NVP/ 182 * 183 * @param WC_Order $order Order object 184 * @param int|array $buckets Number of buckets or list of bucket 185 * 186 * @return array DoExpressCheckoutPayment parameters 187 */ 188 public function get_do_express_checkout_params( WC_Order $order, $buckets = 1 ) { 178 189 $params = array(); 179 190 if ( ! is_array( $buckets ) ) { … … 186 197 187 198 foreach ( $buckets as $bucketNum ) { 199 188 200 $params[ 'PAYMENTREQUEST_' . $bucketNum . '_PAYMENTACTION' ] = $this->get_paymentaction(); 201 202 189 203 } 190 204 -
woocommerce-gateway-paypal-express-checkout/trunk/includes/class-wc-gateway-ppec-with-paypal.php
r1470458 r1479700 9 9 $this->id = 'ppec_paypal'; 10 10 parent::__construct(); 11 12 13 14 15 11 16 } 12 17 } -
woocommerce-gateway-paypal-express-checkout/trunk/includes/functions.php
r1470458 r1479700 64 64 65 65 $wc_ppec_logger->add( 'wc_gateway_ppec', $message ); 66 67 68 69 66 70 } -
woocommerce-gateway-paypal-express-checkout/trunk/readme.txt
r1470867 r1479700 4 4 Requires at least: 4.4 5 5 Tested up to: 4.4 6 Stable tag: 1.1. 16 Stable tag: 1.1. 7 7 License: GPLv3 8 8 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 86 86 == Changelog == 87 87 88 89 90 91 92 88 93 = 1.1.1 = 89 94 * Fixed fatal error prior to PHP 5.5 caused by passing empty() a non-variables. -
woocommerce-gateway-paypal-express-checkout/trunk/woocommerce-gateway-paypal-express-checkout.php
r1470867 r1479700 4 4 * Plugin URI: https://www.woothemes.com/products/woocommerce-gateway-paypal-express-checkout/ 5 5 * Description: A payment gateway for PayPal Express Checkout (https://www.paypal.com/us/webapps/mpp/express-checkout). 6 * Version: 1.1. 16 * Version: 1.1. 7 7 * Author: Automattic 8 8 * Author URI: https://woocommerce.com … … 37 37 require_once( 'includes/class-wc-gateway-ppec-plugin.php' ); 38 38 39 $plugin = new WC_Gateway_PPEC_Plugin( __FILE__, '1.1. 1' );39 $plugin = new WC_Gateway_PPEC_Plugin( __FILE__, '1.1.' ); 40 40 } 41 41
Note: See TracChangeset
for help on using the changeset viewer.