diff --git a/includes/admin/meta-boxes/views/html-order-item-meta.php b/includes/admin/meta-boxes/views/html-order-item-meta.php index 8b8c524e14c..89f6c5ab92e 100644 --- a/includes/admin/meta-boxes/views/html-order-item-meta.php +++ b/includes/admin/meta-boxes/views/html-order-item-meta.php @@ -1,94 +1,94 @@
- has_meta( $item_id ) ) { - echo ''; - foreach ( $metadata as $meta ) { + if ( $metadata = $order->has_meta( $item_id ) ) { + echo '
'; + foreach ( $metadata as $meta ) { - // Skip hidden core fields - if ( in_array( $meta['meta_key'], apply_filters( 'woocommerce_hidden_order_itemmeta', array( - '_qty', - '_tax_class', - '_product_id', - '_variation_id', - '_line_subtotal', - '_line_subtotal_tax', - '_line_total', - '_line_tax', - 'method_id', - 'cost' - ) ) ) ) { - continue; - } + // Skip hidden core fields + if ( in_array( $meta['meta_key'], apply_filters( 'woocommerce_hidden_order_itemmeta', array( + '_qty', + '_tax_class', + '_product_id', + '_variation_id', + '_line_subtotal', + '_line_subtotal_tax', + '_line_total', + '_line_tax', + 'method_id', + 'cost' + ) ) ) ) { + continue; + } - // Skip serialised meta - if ( is_serialized( $meta['meta_value'] ) ) { - continue; - } + // Skip serialised meta + if ( is_serialized( $meta['meta_value'] ) ) { + continue; + } - // Get attribute data - if ( taxonomy_exists( wc_sanitize_taxonomy_name( $meta['meta_key'] ) ) ) { - $term = get_term_by( 'slug', $meta['meta_value'], wc_sanitize_taxonomy_name( $meta['meta_key'] ) ); - $meta['meta_key'] = wc_attribute_label( wc_sanitize_taxonomy_name( $meta['meta_key'] ) ); - $meta['meta_value'] = isset( $term->name ) ? $term->name : $meta['meta_value']; - } else { - $meta['meta_key'] = wc_attribute_label( $meta['meta_key'], $_product ); - } + // Get attribute data + if ( taxonomy_exists( wc_sanitize_taxonomy_name( $meta['meta_key'] ) ) ) { + $term = get_term_by( 'slug', $meta['meta_value'], wc_sanitize_taxonomy_name( $meta['meta_key'] ) ); + $meta['meta_key'] = wc_attribute_label( wc_sanitize_taxonomy_name( $meta['meta_key'] ) ); + $meta['meta_value'] = isset( $term->name ) ? $term->name : $meta['meta_value']; + } else { + $meta['meta_key'] = wc_attribute_label( $meta['meta_key'], $_product ); + } - echo ''; - } - echo '
' . wp_kses_post( rawurldecode( $meta['meta_key'] ) ) . ':' . wp_kses_post( wpautop( make_clickable( rawurldecode( $meta['meta_value'] ) ) ) ) . '
'; - } - ?> + echo '' . wp_kses_post( rawurldecode( $meta['meta_key'] ) ) . ':' . wp_kses_post( wpautop( make_clickable( rawurldecode( $meta['meta_value'] ) ) ) ) . ''; + } + echo ''; + } + ?>
diff --git a/includes/admin/views/html-notice-custom.php b/includes/admin/views/html-notice-custom.php index 4a020d7afdf..a0ef2a9fa71 100644 --- a/includes/admin/views/html-notice-custom.php +++ b/includes/admin/views/html-notice-custom.php @@ -9,6 +9,6 @@ if ( ! defined( 'ABSPATH' ) ) { ?>
- +
diff --git a/includes/admin/views/html-notice-simplify-commerce.php b/includes/admin/views/html-notice-simplify-commerce.php index 2c47838892c..8664b6b270a 100644 --- a/includes/admin/views/html-notice-simplify-commerce.php +++ b/includes/admin/views/html-notice-simplify-commerce.php @@ -16,7 +16,7 @@ if ( current_user_can( 'install_plugins' ) ) { } ?>
- +

The Simplify Commerce payment gateway is deprecated – Please install our new free Simplify Commerce plugin from WordPress.org. Simplify Commerce will be removed from WooCommerce core in a future update.', 'woocommerce' ); ?>

diff --git a/includes/class-wc-download-handler.php b/includes/class-wc-download-handler.php index a1448809cf3..2dd8d286427 100644 --- a/includes/class-wc-download-handler.php +++ b/includes/class-wc-download-handler.php @@ -326,9 +326,9 @@ class WC_Download_Handler { header( "Content-Disposition: attachment; filename=\"" . $filename . "\";" ); header( "Content-Transfer-Encoding: binary" ); - if ( $size = @filesize( $file_path ) ) { - header( "Content-Length: " . $size ); - } + if ( $size = @filesize( $file_path ) ) { + header( "Content-Length: " . $size ); + } } /** diff --git a/includes/class-wc-integrations.php b/includes/class-wc-integrations.php index aeea80693a1..32bdc72a58b 100644 --- a/includes/class-wc-integrations.php +++ b/includes/class-wc-integrations.php @@ -24,10 +24,10 @@ class WC_Integrations { */ public $integrations = array(); - /** - * Initialize integrations. - */ - public function __construct() { + /** + * Initialize integrations. + */ + public function __construct() { do_action( 'woocommerce_integrations_init' ); diff --git a/includes/class-wc-product-grouped.php b/includes/class-wc-product-grouped.php index 4ae862c1b9b..90bdb96ce8f 100644 --- a/includes/class-wc-product-grouped.php +++ b/includes/class-wc-product-grouped.php @@ -49,22 +49,22 @@ class WC_Product_Grouped extends WC_Product { */ public function get_children() { if ( ! is_array( $this->children ) || empty( $this->children ) ) { - $transient_name = 'wc_product_children_' . $this->id; + $transient_name = 'wc_product_children_' . $this->id; $this->children = array_filter( array_map( 'absint', (array) get_transient( $transient_name ) ) ); - if ( empty( $this->children ) ) { + if ( empty( $this->children ) ) { - $args = apply_filters( 'woocommerce_grouped_children_args', array( - 'post_parent' => $this->id, - 'post_type' => 'product', - 'orderby' => 'menu_order', - 'order' => 'ASC', - 'fields' => 'ids', - 'post_status' => 'publish', - 'numberposts' => -1, - ) ); + $args = apply_filters( 'woocommerce_grouped_children_args', array( + 'post_parent' => $this->id, + 'post_type' => 'product', + 'orderby' => 'menu_order', + 'order' => 'ASC', + 'fields' => 'ids', + 'post_status' => 'publish', + 'numberposts' => -1, + ) ); - $this->children = get_posts( $args ); + $this->children = get_posts( $args ); set_transient( $transient_name, $this->children, DAY_IN_SECONDS * 30 ); } diff --git a/includes/class-wc-shipping.php b/includes/class-wc-shipping.php index 70a068fbbb0..1bd54dd501b 100644 --- a/includes/class-wc-shipping.php +++ b/includes/class-wc-shipping.php @@ -89,10 +89,10 @@ class WC_Shipping { } } - /** - * Initialize shipping. - */ - public function init() { + /** + * Initialize shipping. + */ + public function init() { do_action( 'woocommerce_shipping_init' ); } diff --git a/includes/class-wc-validation.php b/includes/class-wc-validation.php index 42ead78e7c4..1154ee459b7 100644 --- a/includes/class-wc-validation.php +++ b/includes/class-wc-validation.php @@ -79,8 +79,8 @@ class WC_Validation { case 'US' : $valid = (bool) preg_match( '/^([0-9]{5})(-[0-9]{4})?$/i', $postcode ); break; - case 'CA' : - // CA Postal codes cannot contain D,F,I,O,Q,U and cannot start with W or Z. https://en.wikipedia.org/wiki/Postal_codes_in_Canada#Number_of_possible_postal_codes + case 'CA' : + // CA Postal codes cannot contain D,F,I,O,Q,U and cannot start with W or Z. https://en.wikipedia.org/wiki/Postal_codes_in_Canada#Number_of_possible_postal_codes $valid = (bool) preg_match( '/^([ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ])([\ ])?(\d[ABCEGHJKLMNPRSTVWXYZ]\d)$/i', $postcode ); break; diff --git a/includes/emails/class-wc-email-failed-order.php b/includes/emails/class-wc-email-failed-order.php index b8f385066c7..c7f53078970 100644 --- a/includes/emails/class-wc-email-failed-order.php +++ b/includes/emails/class-wc-email-failed-order.php @@ -49,7 +49,7 @@ class WC_Email_Failed_Order extends WC_Email { */ public function trigger( $order_id ) { if ( $order_id ) { - $this->object = wc_get_order( $order_id ); + $this->object = wc_get_order( $order_id ); $this->find['order-date'] = '{order_date}'; $this->find['order-number'] = '{order_number}'; $this->replace['order-date'] = date_i18n( wc_date_format(), strtotime( $this->object->order_date ) ); diff --git a/includes/gateways/cheque/class-wc-gateway-cheque.php b/includes/gateways/cheque/class-wc-gateway-cheque.php index 0d6c96dbb7d..83a4f3c5647 100644 --- a/includes/gateways/cheque/class-wc-gateway-cheque.php +++ b/includes/gateways/cheque/class-wc-gateway-cheque.php @@ -17,9 +17,9 @@ if ( ! defined( 'ABSPATH' ) ) { */ class WC_Gateway_Cheque extends WC_Payment_Gateway { - /** - * Constructor for the gateway. - */ + /** + * Constructor for the gateway. + */ public function __construct() { $this->id = 'cheque'; $this->icon = apply_filters( 'woocommerce_cheque_icon', '' ); @@ -38,18 +38,18 @@ class WC_Gateway_Cheque extends WC_Payment_Gateway { // Actions add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); - add_action( 'woocommerce_thankyou_cheque', array( $this, 'thankyou_page' ) ); + add_action( 'woocommerce_thankyou_cheque', array( $this, 'thankyou_page' ) ); - // Customer Emails - add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 3 ); - } + // Customer Emails + add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 3 ); + } - /** - * Initialise Gateway Settings Form Fields. - */ - public function init_form_fields() { + /** + * Initialise Gateway Settings Form Fields. + */ + public function init_form_fields() { - $this->form_fields = array( + $this->form_fields = array( 'enabled' => array( 'title' => __( 'Enable/Disable', 'woocommerce' ), 'type' => 'checkbox', @@ -78,36 +78,36 @@ class WC_Gateway_Cheque extends WC_Payment_Gateway { 'desc_tip' => true, ), ); - } - - /** - * Output for the order received page. - */ - public function thankyou_page() { - if ( $this->instructions ) - echo wpautop( wptexturize( $this->instructions ) ); } - /** - * Add content to the WC emails. - * - * @access public - * @param WC_Order $order - * @param bool $sent_to_admin - * @param bool $plain_text - */ + /** + * Output for the order received page. + */ + public function thankyou_page() { + if ( $this->instructions ) + echo wpautop( wptexturize( $this->instructions ) ); + } + + /** + * Add content to the WC emails. + * + * @access public + * @param WC_Order $order + * @param bool $sent_to_admin + * @param bool $plain_text + */ public function email_instructions( $order, $sent_to_admin, $plain_text = false ) { - if ( $this->instructions && ! $sent_to_admin && 'cheque' === $order->payment_method && $order->has_status( 'on-hold' ) ) { + if ( $this->instructions && ! $sent_to_admin && 'cheque' === $order->payment_method && $order->has_status( 'on-hold' ) ) { echo wpautop( wptexturize( $this->instructions ) ) . PHP_EOL; } } - /** - * Process the payment and return the result. - * - * @param int $order_id - * @return array - */ + /** + * Process the payment and return the result. + * + * @param int $order_id + * @return array + */ public function process_payment( $order_id ) { $order = wc_get_order( $order_id ); diff --git a/includes/gateways/cod/class-wc-gateway-cod.php b/includes/gateways/cod/class-wc-gateway-cod.php index 68167610672..2f3300b2f17 100644 --- a/includes/gateways/cod/class-wc-gateway-cod.php +++ b/includes/gateways/cod/class-wc-gateway-cod.php @@ -17,9 +17,9 @@ if ( ! defined( 'ABSPATH' ) ) { */ class WC_Gateway_COD extends WC_Payment_Gateway { - /** - * Constructor for the gateway. - */ + /** + * Constructor for the gateway. + */ public function __construct() { $this->id = 'cod'; $this->icon = apply_filters( 'woocommerce_cod_icon', '' ); @@ -41,22 +41,22 @@ class WC_Gateway_COD extends WC_Payment_Gateway { add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); add_action( 'woocommerce_thankyou_cod', array( $this, 'thankyou_page' ) ); - // Customer Emails - add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 3 ); + // Customer Emails + add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 3 ); } - /** - * Initialise Gateway Settings Form Fields. - */ - public function init_form_fields() { - $shipping_methods = array(); + /** + * Initialise Gateway Settings Form Fields. + */ + public function init_form_fields() { + $shipping_methods = array(); - if ( is_admin() ) - foreach ( WC()->shipping()->load_shipping_methods() as $method ) { - $shipping_methods[ $method->id ] = $method->get_title(); - } + if ( is_admin() ) + foreach ( WC()->shipping()->load_shipping_methods() as $method ) { + $shipping_methods[ $method->id ] = $method->get_title(); + } - $this->form_fields = array( + $this->form_fields = array( 'enabled' => array( 'title' => __( 'Enable COD', 'woocommerce' ), 'label' => __( 'Enable Cash on Delivery', 'woocommerce' ), @@ -104,8 +104,8 @@ class WC_Gateway_COD extends WC_Payment_Gateway { 'type' => 'checkbox', 'default' => 'yes' ) - ); - } + ); + } /** * Check If The Gateway Is Available For Use. @@ -189,12 +189,12 @@ class WC_Gateway_COD extends WC_Payment_Gateway { } - /** - * Process the payment and return the result. - * - * @param int $order_id - * @return array - */ + /** + * Process the payment and return the result. + * + * @param int $order_id + * @return array + */ public function process_payment( $order_id ) { $order = wc_get_order( $order_id ); @@ -214,23 +214,23 @@ class WC_Gateway_COD extends WC_Payment_Gateway { ); } - /** - * Output for the order received page. - */ + /** + * Output for the order received page. + */ public function thankyou_page() { if ( $this->instructions ) { - echo wpautop( wptexturize( $this->instructions ) ); + echo wpautop( wptexturize( $this->instructions ) ); } } - /** - * Add content to the WC emails. - * - * @access public - * @param WC_Order $order - * @param bool $sent_to_admin - * @param bool $plain_text - */ + /** + * Add content to the WC emails. + * + * @access public + * @param WC_Order $order + * @param bool $sent_to_admin + * @param bool $plain_text + */ public function email_instructions( $order, $sent_to_admin, $plain_text = false ) { if ( $this->instructions && ! $sent_to_admin && 'cod' === $order->payment_method ) { echo wpautop( wptexturize( $this->instructions ) ) . PHP_EOL; diff --git a/includes/gateways/simplify-commerce/includes/Simplify.php b/includes/gateways/simplify-commerce/includes/Simplify.php index 586ad560146..925bb51f29b 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify.php +++ b/includes/gateways/simplify-commerce/includes/Simplify.php @@ -2,27 +2,27 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ @@ -30,31 +30,31 @@ require_once(dirname(__FILE__) . '/Simplify/Constants.php'); class Simplify { - /** - * @var string $publicKey public API key used to authenticate requests. - */ - public static $publicKey; + /** + * @var string $publicKey public API key used to authenticate requests. + */ + public static $publicKey; - /** - * @var string $privateKey private API key used to authenticate requests. - */ - public static $privateKey; + /** + * @var string $privateKey private API key used to authenticate requests. + */ + public static $privateKey; - /** - * @var string $apiBaseLiveUrl URL of the live API endpoint - */ - public static $apiBaseLiveUrl = Simplify_Constants::API_BASE_LIVE_URL; + /** + * @var string $apiBaseLiveUrl URL of the live API endpoint + */ + public static $apiBaseLiveUrl = Simplify_Constants::API_BASE_LIVE_URL; - /** - * @var string $apiBaseSandboxUrl URL of the sandbox API endpoint - */ - public static $apiBaseSandboxUrl = Simplify_Constants::API_BASE_SANDBOX_URL; + /** + * @var string $apiBaseSandboxUrl URL of the sandbox API endpoint + */ + public static $apiBaseSandboxUrl = Simplify_Constants::API_BASE_SANDBOX_URL; - /** - * @var string $userAgent User-agent string send with requests. - */ - public static $userAgent = null; + /** + * @var string $userAgent User-agent string send with requests. + */ + public static $userAgent = null; } diff --git a/includes/gateways/simplify-commerce/includes/Simplify/AccessToken.php b/includes/gateways/simplify-commerce/includes/Simplify/AccessToken.php index c47559439d3..c372a61508a 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/AccessToken.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/AccessToken.php @@ -2,27 +2,27 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ @@ -31,93 +31,93 @@ */ class Simplify_AccessToken extends Simplify_Object { - public function __construct($hash) { - $this->setAll($hash); - } + public function __construct($hash) { + $this->setAll($hash); + } - /** - * Creates an OAuth access token - * @param $code - the authorisation code returned from the GET on /oauth/authorize - * @param $redirect_uri = this must be the redirect_uri set in the apps configuration - * @param $authentication - Authentication information to access the API. If not value is passed the global key Simplify::$publicKey and Simplify::$privateKey are used - * @return Simplify_AccessToken - */ - public static function create($code, $redirect_uri, $authentication = null) { + /** + * Creates an OAuth access token + * @param $code - the authorisation code returned from the GET on /oauth/authorize + * @param $redirect_uri = this must be the redirect_uri set in the apps configuration + * @param $authentication - Authentication information to access the API. If not value is passed the global key Simplify::$publicKey and Simplify::$privateKey are used + * @return Simplify_AccessToken + */ + public static function create($code, $redirect_uri, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 3); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 3); - $props = 'code='.$code.'&redirect_uri='.$redirect_uri.'&grant_type=authorization_code'; - $resp = Simplify_AccessToken::sendRequest($props, "token", $authentication); + $props = 'code='.$code.'&redirect_uri='.$redirect_uri.'&grant_type=authorization_code'; + $resp = Simplify_AccessToken::sendRequest($props, "token", $authentication); - return new Simplify_AccessToken($resp); - } + return new Simplify_AccessToken($resp); + } - /** - * Refreshes the current token. The access_token and refresh_token values will be updated. - * @param $authentication - Authentication information to access the API. If not value is passed the global key Simplify::$publicKey and Simplify::$privateKey are used - * @return Simplify_AccessToken - * @throws InvalidArgumentException - */ - public function refresh($authentication = null) { + /** + * Refreshes the current token. The access_token and refresh_token values will be updated. + * @param $authentication - Authentication information to access the API. If not value is passed the global key Simplify::$publicKey and Simplify::$privateKey are used + * @return Simplify_AccessToken + * @throws InvalidArgumentException + */ + public function refresh($authentication = null) { - $refresh_token = $this->refresh_token; - if (empty($refresh_token)){ - throw new InvalidArgumentException('Cannot refresh access token; refresh token is invalid'); - } + $refresh_token = $this->refresh_token; + if (empty($refresh_token)){ + throw new InvalidArgumentException('Cannot refresh access token; refresh token is invalid'); + } - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); - $props = 'refresh_token='.$refresh_token.'&grant_type=refresh_token'; - $resp = Simplify_AccessToken::sendRequest($props, "token", $authentication); + $props = 'refresh_token='.$refresh_token.'&grant_type=refresh_token'; + $resp = Simplify_AccessToken::sendRequest($props, "token", $authentication); - $this->setAll($resp); + $this->setAll($resp); - return $this; - } + return $this; + } - /** - *

Revokes a token from further use. - * @param $authentication - Authentication information to access the API. If not value is passed the global key Simplify::$publicKey and Simplify::$privateKey are used - * @return Simplify_AccessToken - * @throws InvalidArgumentException - */ - public function revoke($authentication = null) { + /** + *

Revokes a token from further use. + * @param $authentication - Authentication information to access the API. If not value is passed the global key Simplify::$publicKey and Simplify::$privateKey are used + * @return Simplify_AccessToken + * @throws InvalidArgumentException + */ + public function revoke($authentication = null) { - $access_token = $this->access_token; - if (empty($access_token)){ - throw new InvalidArgumentException('Cannot revoke access token; access token is invalid'); - } + $access_token = $this->access_token; + if (empty($access_token)){ + throw new InvalidArgumentException('Cannot revoke access token; access token is invalid'); + } - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $props = 'token='.$access_token.''; + $props = 'token='.$access_token.''; - Simplify_AccessToken::sendRequest($props, "revoke", $authentication); + Simplify_AccessToken::sendRequest($props, "revoke", $authentication); - $this->access_token = null; - $this->refresh_token = null; - $this->redirect_uri = null; + $this->access_token = null; + $this->refresh_token = null; + $this->redirect_uri = null; - return $this; - } + return $this; + } - private static function sendRequest($props, $context, $authentication){ + private static function sendRequest($props, $context, $authentication){ - $url = Simplify_Constants::OAUTH_BASE_URL.'/'.$context; - $http = new Simplify_HTTP(); - $resp = $http->oauthRequest($url, $props, $authentication); + $url = Simplify_Constants::OAUTH_BASE_URL.'/'.$context; + $http = new Simplify_HTTP(); + $resp = $http->oauthRequest($url, $props, $authentication); - return $resp; - } + return $resp; + } - /** - * @ignore - */ - static public function getClazz() { - return "AccessToken"; - } + /** + * @ignore + */ + static public function getClazz() { + return "AccessToken"; + } } diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Authentication.php b/includes/gateways/simplify-commerce/includes/Simplify/Authentication.php index 64859579723..d5fa97e51f7 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Authentication.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Authentication.php @@ -2,27 +2,27 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ @@ -35,36 +35,36 @@ */ class Simplify_Authentication { - public $privateKey; - public $publicKey; - public $accessToken; + public $privateKey; + public $publicKey; + public $accessToken; - function __construct() { - $args = func_get_args(); - switch( func_num_args() ) { - case 1: - self::__construct1( $args[0] ); - break; - case 2: - self::__construct2( $args[0], $args[1] ); - break; - case 3: - self::__construct3( $args[0], $args[1], $args[2] ); - } - } + function __construct() { + $args = func_get_args(); + switch( func_num_args() ) { + case 1: + self::__construct1( $args[0] ); + break; + case 2: + self::__construct2( $args[0], $args[1] ); + break; + case 3: + self::__construct3( $args[0], $args[1], $args[2] ); + } + } - function __construct1($accessToken) { - $this->accessToken = $accessToken; - } + function __construct1($accessToken) { + $this->accessToken = $accessToken; + } - function __construct2($publicKey, $privateKey) { - $this->publicKey = $publicKey; - $this->privateKey = $privateKey; - } + function __construct2($publicKey, $privateKey) { + $this->publicKey = $publicKey; + $this->privateKey = $privateKey; + } - function __construct3($publicKey, $privateKey, $accessToken) { - $this->publicKey = $publicKey; - $this->privateKey = $privateKey; - $this->accessToken = $accessToken; - } -} \ No newline at end of file + function __construct3($publicKey, $privateKey, $accessToken) { + $this->publicKey = $publicKey; + $this->privateKey = $privateKey; + $this->accessToken = $accessToken; + } +} diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Authorization.php b/includes/gateways/simplify-commerce/includes/Simplify/Authorization.php index 78b8b654bfb..f309a657c4f 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Authorization.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Authorization.php @@ -2,137 +2,137 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ class Simplify_Authorization extends Simplify_Object { - /** - * Creates an Simplify_Authorization object - * @param array $hash a map of parameters; valid keys are:

- *
amount
Amount of the payment (in the smallest unit of your currency). Example: 100 = $1.00USD required
- *
card.addressCity
City of the cardholder. [max length: 50, min length: 2]
- *
card.addressCountry
Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2]
- *
card.addressLine1
Address of the cardholder. [max length: 255]
- *
card.addressLine2
Address of the cardholder if needed. [max length: 255]
- *
card.addressState
State of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, min length: 2]
- *
card.addressZip
Postal code of the cardholder. The postal code size is between 5 and 9 characters in length and only contains numbers or letters. [max length: 9, min length: 3]
- *
card.cvc
CVC security code of the card. This is the code on the back of the card. Example: 123
- *
card.expMonth
Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] required
- *
card.expYear
Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] required
- *
card.name
Name as it appears on the card. [max length: 50, min length: 2]
- *
card.number
Card number as it appears on the card. [max length: 19, min length: 13] required
- *
currency
Currency code (ISO-4217) for the transaction. Must match the currency associated with your account. [default: USD] required
- *
customer
ID of customer. If specified, card on file of customer will be used.
- *
description
Free form text field to be used as a description of the payment. This field is echoed back with the payment on any find or list operations. [max length: 1024]
- *
reference
Custom reference field to be used with outside systems.
- *
replayId
An identifier that can be sent to uniquely identify a payment request to facilitate retries due to I/O related issues. This identifier must be unique for your account (sandbox or live) across all of your payments. If supplied, we will check for a payment on your account that matches this identifier, and if one is found we will attempt to return an identical response of the original request. [max length: 50, min length: 1]
- *
statementDescription.name
Merchant name required
- *
statementDescription.phoneNumber
Merchant contact phone number.
- *
token
If specified, card associated with card token will be used. [max length: 255]
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Authorization a Authorization object. - */ - static public function createAuthorization($hash, $authentication = null) { + /** + * Creates an Simplify_Authorization object + * @param array $hash a map of parameters; valid keys are:
+ *
amount
Amount of the payment (in the smallest unit of your currency). Example: 100 = $1.00USD required
+ *
card.addressCity
City of the cardholder. [max length: 50, min length: 2]
+ *
card.addressCountry
Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2]
+ *
card.addressLine1
Address of the cardholder. [max length: 255]
+ *
card.addressLine2
Address of the cardholder if needed. [max length: 255]
+ *
card.addressState
State of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, min length: 2]
+ *
card.addressZip
Postal code of the cardholder. The postal code size is between 5 and 9 characters in length and only contains numbers or letters. [max length: 9, min length: 3]
+ *
card.cvc
CVC security code of the card. This is the code on the back of the card. Example: 123
+ *
card.expMonth
Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] required
+ *
card.expYear
Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] required
+ *
card.name
Name as it appears on the card. [max length: 50, min length: 2]
+ *
card.number
Card number as it appears on the card. [max length: 19, min length: 13] required
+ *
currency
Currency code (ISO-4217) for the transaction. Must match the currency associated with your account. [default: USD] required
+ *
customer
ID of customer. If specified, card on file of customer will be used.
+ *
description
Free form text field to be used as a description of the payment. This field is echoed back with the payment on any find or list operations. [max length: 1024]
+ *
reference
Custom reference field to be used with outside systems.
+ *
replayId
An identifier that can be sent to uniquely identify a payment request to facilitate retries due to I/O related issues. This identifier must be unique for your account (sandbox or live) across all of your payments. If supplied, we will check for a payment on your account that matches this identifier, and if one is found we will attempt to return an identical response of the original request. [max length: 50, min length: 1]
+ *
statementDescription.name
Merchant name required
+ *
statementDescription.phoneNumber
Merchant contact phone number.
+ *
token
If specified, card associated with card token will be used. [max length: 255]
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Authorization a Authorization object. + */ + static public function createAuthorization($hash, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $instance = new Simplify_Authorization(); - $instance->setAll($hash); + $instance = new Simplify_Authorization(); + $instance->setAll($hash); - $object = Simplify_PaymentsApi::createObject($instance, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } - /** - * Deletes an Simplify_Authorization object. - * - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - */ - public function deleteAuthorization($authentication = null) { + /** + * Deletes an Simplify_Authorization object. + * + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + */ + public function deleteAuthorization($authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); - $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); - $this->properties = null; - return true; - } + $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); + $this->properties = null; + return true; + } - /** - * Retrieve Simplify_Authorization objects. - * @param array criteria a map of parameters; valid keys are:
- *
filter
Filters to apply to the list.
- *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
- *
offset
Used in pagination of the list. This is the start offset of the page. [min value: 0, default: 0]
- *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated amount id description paymentDate.
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Authorization objects and the total - * number of Authorization objects available for the given criteria. - * @see ResourceList - */ - static public function listAuthorization($criteria = null, $authentication = null) { + /** + * Retrieve Simplify_Authorization objects. + * @param array criteria a map of parameters; valid keys are:
+ *
filter
Filters to apply to the list.
+ *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
+ *
offset
Used in pagination of the list. This is the start offset of the page. [min value: 0, default: 0]
+ *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated amount id description paymentDate.
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Authorization objects and the total + * number of Authorization objects available for the given criteria. + * @see ResourceList + */ + static public function listAuthorization($criteria = null, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Authorization(); - $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + $val = new Simplify_Authorization(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); - return $list; - } + return $list; + } - /** - * Retrieve a Simplify_Authorization object from the API - * - * @param string id the id of the Authorization object to retrieve - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Authorization a Authorization object - */ - static public function findAuthorization($id, $authentication = null) { + /** + * Retrieve a Simplify_Authorization object from the API + * + * @param string id the id of the Authorization object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Authorization a Authorization object + */ + static public function findAuthorization($id, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Authorization(); - $val->id = $id; + $val = new Simplify_Authorization(); + $val->id = $id; - $obj = Simplify_PaymentsApi::findObject($val, $authentication); + $obj = Simplify_PaymentsApi::findObject($val, $authentication); - return $obj; - } + return $obj; + } - /** - * @ignore - */ - public function getClazz() { - return "Authorization"; - } -} \ No newline at end of file + /** + * @ignore + */ + public function getClazz() { + return "Authorization"; + } +} diff --git a/includes/gateways/simplify-commerce/includes/Simplify/CardToken.php b/includes/gateways/simplify-commerce/includes/Simplify/CardToken.php index 4661405e2b3..dfdf681995c 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/CardToken.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/CardToken.php @@ -2,89 +2,89 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ class Simplify_CardToken extends Simplify_Object { - /** - * Creates an Simplify_CardToken object - * @param array $hash a map of parameters; valid keys are:
- *
callback
The URL callback for the cardtoken
- *
card.addressCity
City of the cardholder. [max length: 50, min length: 2]
- *
card.addressCountry
Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2]
- *
card.addressLine1
Address of the cardholder. [max length: 255]
- *
card.addressLine2
Address of the cardholder if needed. [max length: 255]
- *
card.addressState
State of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, min length: 2]
- *
card.addressZip
Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. [max length: 9, min length: 3]
- *
card.cvc
CVC security code of the card. This is the code on the back of the card. Example: 123
- *
card.expMonth
Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] required
- *
card.expYear
Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] required
- *
card.name
Name as appears on the card. [max length: 50, min length: 2]
- *
card.number
Card number as it appears on the card. [max length: 19, min length: 13] required
- *
key
Key used to create the card token.
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return CardToken a CardToken object. - */ - static public function createCardToken($hash, $authentication = null) { + /** + * Creates an Simplify_CardToken object + * @param array $hash a map of parameters; valid keys are:
+ *
callback
The URL callback for the cardtoken
+ *
card.addressCity
City of the cardholder. [max length: 50, min length: 2]
+ *
card.addressCountry
Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2]
+ *
card.addressLine1
Address of the cardholder. [max length: 255]
+ *
card.addressLine2
Address of the cardholder if needed. [max length: 255]
+ *
card.addressState
State of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, min length: 2]
+ *
card.addressZip
Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. [max length: 9, min length: 3]
+ *
card.cvc
CVC security code of the card. This is the code on the back of the card. Example: 123
+ *
card.expMonth
Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] required
+ *
card.expYear
Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] required
+ *
card.name
Name as appears on the card. [max length: 50, min length: 2]
+ *
card.number
Card number as it appears on the card. [max length: 19, min length: 13] required
+ *
key
Key used to create the card token.
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return CardToken a CardToken object. + */ + static public function createCardToken($hash, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $instance = new Simplify_CardToken(); - $instance->setAll($hash); + $instance = new Simplify_CardToken(); + $instance->setAll($hash); - $object = Simplify_PaymentsApi::createObject($instance, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } - /** - * Retrieve a Simplify_CardToken object from the API - * - * @param string id the id of the CardToken object to retrieve - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return CardToken a CardToken object - */ - static public function findCardToken($id, $authentication = null) { + /** + * Retrieve a Simplify_CardToken object from the API + * + * @param string id the id of the CardToken object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return CardToken a CardToken object + */ + static public function findCardToken($id, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_CardToken(); - $val->id = $id; + $val = new Simplify_CardToken(); + $val->id = $id; - $obj = Simplify_PaymentsApi::findObject($val, $authentication); + $obj = Simplify_PaymentsApi::findObject($val, $authentication); - return $obj; - } + return $obj; + } - /** - * @ignore - */ - public function getClazz() { - return "CardToken"; - } -} \ No newline at end of file + /** + * @ignore + */ + public function getClazz() { + return "CardToken"; + } +} diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Chargeback.php b/includes/gateways/simplify-commerce/includes/Simplify/Chargeback.php index 361fb10c5b5..b9ead82de39 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Chargeback.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Chargeback.php @@ -2,81 +2,81 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ class Simplify_Chargeback extends Simplify_Object { - /** - * Retrieve Simplify_Chargeback objects. - * @param array criteria a map of parameters; valid keys are:
- *
filter
Filters to apply to the list.
- *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
- *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
- *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: id amount description dateCreated.
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Chargeback objects and the total - * number of Chargeback objects available for the given criteria. - * @see ResourceList - */ - static public function listChargeback($criteria = null, $authentication = null) { + /** + * Retrieve Simplify_Chargeback objects. + * @param array criteria a map of parameters; valid keys are:
+ *
filter
Filters to apply to the list.
+ *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
+ *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
+ *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: id amount description dateCreated.
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Chargeback objects and the total + * number of Chargeback objects available for the given criteria. + * @see ResourceList + */ + static public function listChargeback($criteria = null, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Chargeback(); - $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + $val = new Simplify_Chargeback(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); - return $list; - } + return $list; + } - /** - * Retrieve a Simplify_Chargeback object from the API - * - * @param string id the id of the Chargeback object to retrieve - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Chargeback a Chargeback object - */ - static public function findChargeback($id, $authentication = null) { + /** + * Retrieve a Simplify_Chargeback object from the API + * + * @param string id the id of the Chargeback object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Chargeback a Chargeback object + */ + static public function findChargeback($id, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Chargeback(); - $val->id = $id; + $val = new Simplify_Chargeback(); + $val->id = $id; - $obj = Simplify_PaymentsApi::findObject($val, $authentication); + $obj = Simplify_PaymentsApi::findObject($val, $authentication); - return $obj; - } + return $obj; + } - /** - * @ignore - */ - public function getClazz() { - return "Chargeback"; - } -} \ No newline at end of file + /** + * @ignore + */ + public function getClazz() { + return "Chargeback"; + } +} diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Constants.php b/includes/gateways/simplify-commerce/includes/Simplify/Constants.php index 900bf4a5c35..e24a838160a 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Constants.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Constants.php @@ -32,23 +32,23 @@ */ class Simplify_Constants { - /** - * @var string VERSION SDK version information. - */ - const VERSION = '1.2.0'; + /** + * @var string VERSION SDK version information. + */ + const VERSION = '1.2.0'; - /** - * @var string API_BASE_LIVE_URL URL for the live API endpoint - */ - const API_BASE_LIVE_URL = 'https://api.simplify.com/v1/api'; + /** + * @var string API_BASE_LIVE_URL URL for the live API endpoint + */ + const API_BASE_LIVE_URL = 'https://api.simplify.com/v1/api'; - /** - * @var string API_BASE_SANDBOX_URL URL for the sandbox API endpoint - */ - const API_BASE_SANDBOX_URL = 'https://sandbox.simplify.com/v1/api'; + /** + * @var string API_BASE_SANDBOX_URL URL for the sandbox API endpoint + */ + const API_BASE_SANDBOX_URL = 'https://sandbox.simplify.com/v1/api'; - /** - * @var string OAUTH_BASE_URL URL for the oauth enpoint - */ - const OAUTH_BASE_URL = 'https://www.simplify.com/commerce/oauth'; + /** + * @var string OAUTH_BASE_URL URL for the oauth enpoint + */ + const OAUTH_BASE_URL = 'https://www.simplify.com/commerce/oauth'; } diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Coupon.php b/includes/gateways/simplify-commerce/includes/Simplify/Coupon.php index 295ba13fc31..f99198599fc 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Coupon.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Coupon.php @@ -2,146 +2,146 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ class Simplify_Coupon extends Simplify_Object { - /** - * Creates an Simplify_Coupon object - * @param array $hash a map of parameters; valid keys are:
- *
amountOff
Amount off of the price of the product in the smallest units of the currency of the merchant. While this field is optional, you must provide either amountOff or percentOff for a coupon. Example: 100 = $1.00USD [min value: 1]
- *
couponCode
Code that identifies the coupon to be used. [min length: 2] required
- *
description
A brief section that describes the coupon.
- *
durationInMonths
DEPRECATED - Duration in months that the coupon will be applied after it has first been selected. [min value: 1, max value: 9999]
- *
endDate
Last date of the coupon in UTC millis that the coupon can be applied to a subscription. This ends at 23:59:59 of the merchant timezone.
- *
maxRedemptions
Maximum number of redemptions allowed for the coupon. A redemption is defined as when the coupon is applied to the subscription for the first time. [min value: 1]
- *
numTimesApplied
The number of times a coupon will be applied on a customer's subscription. [min value: 1, max value: 9999]
- *
percentOff
Percentage off of the price of the product. While this field is optional, you must provide either amountOff or percentOff for a coupon. The percent off is a whole number. [min value: 1, max value: 100]
- *
startDate
First date of the coupon in UTC millis that the coupon can be applied to a subscription. This starts at midnight of the merchant timezone. required
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Coupon a Coupon object. - */ - static public function createCoupon($hash, $authentication = null) { + /** + * Creates an Simplify_Coupon object + * @param array $hash a map of parameters; valid keys are:
+ *
amountOff
Amount off of the price of the product in the smallest units of the currency of the merchant. While this field is optional, you must provide either amountOff or percentOff for a coupon. Example: 100 = $1.00USD [min value: 1]
+ *
couponCode
Code that identifies the coupon to be used. [min length: 2] required
+ *
description
A brief section that describes the coupon.
+ *
durationInMonths
DEPRECATED - Duration in months that the coupon will be applied after it has first been selected. [min value: 1, max value: 9999]
+ *
endDate
Last date of the coupon in UTC millis that the coupon can be applied to a subscription. This ends at 23:59:59 of the merchant timezone.
+ *
maxRedemptions
Maximum number of redemptions allowed for the coupon. A redemption is defined as when the coupon is applied to the subscription for the first time. [min value: 1]
+ *
numTimesApplied
The number of times a coupon will be applied on a customer's subscription. [min value: 1, max value: 9999]
+ *
percentOff
Percentage off of the price of the product. While this field is optional, you must provide either amountOff or percentOff for a coupon. The percent off is a whole number. [min value: 1, max value: 100]
+ *
startDate
First date of the coupon in UTC millis that the coupon can be applied to a subscription. This starts at midnight of the merchant timezone. required
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Coupon a Coupon object. + */ + static public function createCoupon($hash, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $instance = new Simplify_Coupon(); - $instance->setAll($hash); + $instance = new Simplify_Coupon(); + $instance->setAll($hash); - $object = Simplify_PaymentsApi::createObject($instance, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } - /** - * Deletes an Simplify_Coupon object. - * - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - */ - public function deleteCoupon($authentication = null) { + /** + * Deletes an Simplify_Coupon object. + * + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + */ + public function deleteCoupon($authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); - $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); - $this->properties = null; - return true; - } + $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); + $this->properties = null; + return true; + } - /** - * Retrieve Simplify_Coupon objects. - * @param array criteria a map of parameters; valid keys are:
- *
filter
Filters to apply to the list.
- *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
- *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
- *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated maxRedemptions timesRedeemed id startDate endDate percentOff couponCode durationInMonths numTimesApplied amountOff.
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Coupon objects and the total - * number of Coupon objects available for the given criteria. - * @see ResourceList - */ - static public function listCoupon($criteria = null, $authentication = null) { + /** + * Retrieve Simplify_Coupon objects. + * @param array criteria a map of parameters; valid keys are:
+ *
filter
Filters to apply to the list.
+ *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
+ *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
+ *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated maxRedemptions timesRedeemed id startDate endDate percentOff couponCode durationInMonths numTimesApplied amountOff.
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Coupon objects and the total + * number of Coupon objects available for the given criteria. + * @see ResourceList + */ + static public function listCoupon($criteria = null, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Coupon(); - $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + $val = new Simplify_Coupon(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); - return $list; - } + return $list; + } - /** - * Retrieve a Simplify_Coupon object from the API - * - * @param string id the id of the Coupon object to retrieve - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Coupon a Coupon object - */ - static public function findCoupon($id, $authentication = null) { + /** + * Retrieve a Simplify_Coupon object from the API + * + * @param string id the id of the Coupon object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Coupon a Coupon object + */ + static public function findCoupon($id, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Coupon(); - $val->id = $id; + $val = new Simplify_Coupon(); + $val->id = $id; - $obj = Simplify_PaymentsApi::findObject($val, $authentication); + $obj = Simplify_PaymentsApi::findObject($val, $authentication); - return $obj; - } + return $obj; + } - /** - * Updates an Simplify_Coupon object. - * - * The properties that can be updated: - *
- *
endDate
The ending date in UTC millis for the coupon. This must be after the starting date of the coupon.
- *
maxRedemptions
Maximum number of redemptions allowed for the coupon. A redemption is defined as when the coupon is applied to the subscription for the first time. [min value: 1]
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Coupon a Coupon object. - */ - public function updateCoupon($authentication = null) { + /** + * Updates an Simplify_Coupon object. + * + * The properties that can be updated: + *
+ *
endDate
The ending date in UTC millis for the coupon. This must be after the starting date of the coupon.
+ *
maxRedemptions
Maximum number of redemptions allowed for the coupon. A redemption is defined as when the coupon is applied to the subscription for the first time. [min value: 1]
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Coupon a Coupon object. + */ + public function updateCoupon($authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); - $object = Simplify_PaymentsApi::updateObject($this, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::updateObject($this, $authentication); + return $object; + } - /** - * @ignore - */ - public function getClazz() { - return "Coupon"; - } -} \ No newline at end of file + /** + * @ignore + */ + public function getClazz() { + return "Coupon"; + } +} diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Customer.php b/includes/gateways/simplify-commerce/includes/Simplify/Customer.php index 822929280a8..694ee744e43 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Customer.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Customer.php @@ -2,179 +2,179 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ class Simplify_Customer extends Simplify_Object { - /** - * Creates an Simplify_Customer object - * @param array $hash a map of parameters; valid keys are:
- *
card.addressCity
City of the cardholder. required
- *
card.addressCountry
Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. required
- *
card.addressLine1
Address of the cardholder required
- *
card.addressLine2
Address of the cardholder if needed. required
- *
card.addressState
State of residence of the cardholder. For the US, this is a 2-digit USPS code. required
- *
card.addressZip
Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. required
- *
card.cvc
CVC security code of the card. This is the code on the back of the card. Example: 123 required
- *
card.expMonth
Expiration month of the card. Format is MM. Example: January = 01 required
- *
card.expYear
Expiration year of the card. Format is YY. Example: 2013 = 13 required
- *
card.id
ID of card. Unused during customer create.
- *
card.name
Name as appears on the card. required
- *
card.number
Card number as it appears on the card. [max length: 19, min length: 13]
- *
email
Email address of the customer required
- *
name
Customer name [min length: 2] required
- *
reference
Reference field for external applications use.
- *
subscriptions.amount
Amount of payment in the smallest unit of your currency. Example: 100 = $1.00USD
- *
subscriptions.billingCycle
How the plan is billed to the customer. Values must be AUTO (indefinitely until the customer cancels) or FIXED (a fixed number of billing cycles). [default: AUTO]
- *
subscriptions.billingCycleLimit
The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4
- *
subscriptions.coupon
Coupon associated with the subscription for the customer.
- *
subscriptions.currency
Currency code (ISO-4217). Must match the currency associated with your account. [default: USD]
- *
subscriptions.customer
The customer ID to create the subscription for. Do not supply this when creating a customer.
- *
subscriptions.frequency
Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY".
- *
subscriptions.frequencyPeriod
Period of frequency of payment for the plan. Example: if the frequency is weekly, and periodFrequency is 2, then the subscription is billed bi-weekly.
- *
subscriptions.name
Name describing subscription
- *
subscriptions.plan
The plan ID that the subscription should be created from.
- *
subscriptions.quantity
Quantity of the plan for the subscription. [min value: 1]
- *
subscriptions.renewalReminderLeadDays
If set, how many days before the next billing cycle that a renewal reminder is sent to the customer. If null, then no emails are sent. Minimum value is 7 if set.
- *
token
If specified, card associated with card token will be used
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Customer a Customer object. - */ - static public function createCustomer($hash, $authentication = null) { + /** + * Creates an Simplify_Customer object + * @param array $hash a map of parameters; valid keys are:
+ *
card.addressCity
City of the cardholder. required
+ *
card.addressCountry
Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. required
+ *
card.addressLine1
Address of the cardholder required
+ *
card.addressLine2
Address of the cardholder if needed. required
+ *
card.addressState
State of residence of the cardholder. For the US, this is a 2-digit USPS code. required
+ *
card.addressZip
Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. required
+ *
card.cvc
CVC security code of the card. This is the code on the back of the card. Example: 123 required
+ *
card.expMonth
Expiration month of the card. Format is MM. Example: January = 01 required
+ *
card.expYear
Expiration year of the card. Format is YY. Example: 2013 = 13 required
+ *
card.id
ID of card. Unused during customer create.
+ *
card.name
Name as appears on the card. required
+ *
card.number
Card number as it appears on the card. [max length: 19, min length: 13]
+ *
email
Email address of the customer required
+ *
name
Customer name [min length: 2] required
+ *
reference
Reference field for external applications use.
+ *
subscriptions.amount
Amount of payment in the smallest unit of your currency. Example: 100 = $1.00USD
+ *
subscriptions.billingCycle
How the plan is billed to the customer. Values must be AUTO (indefinitely until the customer cancels) or FIXED (a fixed number of billing cycles). [default: AUTO]
+ *
subscriptions.billingCycleLimit
The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4
+ *
subscriptions.coupon
Coupon associated with the subscription for the customer.
+ *
subscriptions.currency
Currency code (ISO-4217). Must match the currency associated with your account. [default: USD]
+ *
subscriptions.customer
The customer ID to create the subscription for. Do not supply this when creating a customer.
+ *
subscriptions.frequency
Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY".
+ *
subscriptions.frequencyPeriod
Period of frequency of payment for the plan. Example: if the frequency is weekly, and periodFrequency is 2, then the subscription is billed bi-weekly.
+ *
subscriptions.name
Name describing subscription
+ *
subscriptions.plan
The plan ID that the subscription should be created from.
+ *
subscriptions.quantity
Quantity of the plan for the subscription. [min value: 1]
+ *
subscriptions.renewalReminderLeadDays
If set, how many days before the next billing cycle that a renewal reminder is sent to the customer. If null, then no emails are sent. Minimum value is 7 if set.
+ *
token
If specified, card associated with card token will be used
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Customer a Customer object. + */ + static public function createCustomer($hash, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $instance = new Simplify_Customer(); - $instance->setAll($hash); + $instance = new Simplify_Customer(); + $instance->setAll($hash); - $object = Simplify_PaymentsApi::createObject($instance, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } - /** - * Deletes an Simplify_Customer object. - * - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - */ - public function deleteCustomer($authentication = null) { + /** + * Deletes an Simplify_Customer object. + * + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + */ + public function deleteCustomer($authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); - $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); - $this->properties = null; - return true; - } + $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); + $this->properties = null; + return true; + } - /** - * Retrieve Simplify_Customer objects. - * @param array criteria a map of parameters; valid keys are:
- *
filter
Filters to apply to the list.
- *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
- *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
- *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated id name email reference.
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Customer objects and the total - * number of Customer objects available for the given criteria. - * @see ResourceList - */ - static public function listCustomer($criteria = null, $authentication = null) { + /** + * Retrieve Simplify_Customer objects. + * @param array criteria a map of parameters; valid keys are:
+ *
filter
Filters to apply to the list.
+ *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
+ *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
+ *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated id name email reference.
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Customer objects and the total + * number of Customer objects available for the given criteria. + * @see ResourceList + */ + static public function listCustomer($criteria = null, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Customer(); - $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + $val = new Simplify_Customer(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); - return $list; - } + return $list; + } - /** - * Retrieve a Simplify_Customer object from the API - * - * @param string id the id of the Customer object to retrieve - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Customer a Customer object - */ - static public function findCustomer($id, $authentication = null) { + /** + * Retrieve a Simplify_Customer object from the API + * + * @param string id the id of the Customer object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Customer a Customer object + */ + static public function findCustomer($id, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Customer(); - $val->id = $id; + $val = new Simplify_Customer(); + $val->id = $id; - $obj = Simplify_PaymentsApi::findObject($val, $authentication); + $obj = Simplify_PaymentsApi::findObject($val, $authentication); - return $obj; - } + return $obj; + } - /** - * Updates an Simplify_Customer object. - * - * The properties that can be updated: - *
- *
card.addressCity
City of the cardholder. required
- *
card.addressCountry
Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. required
- *
card.addressLine1
Address of the cardholder. required
- *
card.addressLine2
Address of the cardholder if needed. required
- *
card.addressState
State of residence of the cardholder. For the US, this is a 2-digit USPS code. required
- *
card.addressZip
Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. required
- *
card.cvc
CVC security code of the card. This is the code on the back of the card. Example: 123 required
- *
card.expMonth
Expiration month of the card. Format is MM. Example: January = 01 required
- *
card.expYear
Expiration year of the card. Format is YY. Example: 2013 = 13 required
- *
card.id
ID of card. If present, card details for the customer will not be updated. If not present, the customer will be updated with the supplied card details.
- *
card.name
Name as appears on the card. required
- *
card.number
Card number as it appears on the card. [max length: 19, min length: 13]
- *
email
Email address of the customer required
- *
name
Customer name [min length: 2] required
- *
reference
Reference field for external applications use.
- *
token
If specified, card associated with card token will be added to the customer
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Customer a Customer object. - */ - public function updateCustomer($authentication = null) { + /** + * Updates an Simplify_Customer object. + * + * The properties that can be updated: + *
+ *
card.addressCity
City of the cardholder. required
+ *
card.addressCountry
Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. required
+ *
card.addressLine1
Address of the cardholder. required
+ *
card.addressLine2
Address of the cardholder if needed. required
+ *
card.addressState
State of residence of the cardholder. For the US, this is a 2-digit USPS code. required
+ *
card.addressZip
Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. required
+ *
card.cvc
CVC security code of the card. This is the code on the back of the card. Example: 123 required
+ *
card.expMonth
Expiration month of the card. Format is MM. Example: January = 01 required
+ *
card.expYear
Expiration year of the card. Format is YY. Example: 2013 = 13 required
+ *
card.id
ID of card. If present, card details for the customer will not be updated. If not present, the customer will be updated with the supplied card details.
+ *
card.name
Name as appears on the card. required
+ *
card.number
Card number as it appears on the card. [max length: 19, min length: 13]
+ *
email
Email address of the customer required
+ *
name
Customer name [min length: 2] required
+ *
reference
Reference field for external applications use.
+ *
token
If specified, card associated with card token will be added to the customer
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Customer a Customer object. + */ + public function updateCustomer($authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); - $object = Simplify_PaymentsApi::updateObject($this, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::updateObject($this, $authentication); + return $object; + } - /** - * @ignore - */ - public function getClazz() { - return "Customer"; - } -} \ No newline at end of file + /** + * @ignore + */ + public function getClazz() { + return "Customer"; + } +} diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Deposit.php b/includes/gateways/simplify-commerce/includes/Simplify/Deposit.php index ab2c7b8e9a7..e0ca1aaf548 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Deposit.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Deposit.php @@ -2,81 +2,81 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ class Simplify_Deposit extends Simplify_Object { - /** - * Retrieve Simplify_Deposit objects. - * @param array criteria a map of parameters; valid keys are:
- *
filter
Filters to apply to the list.
- *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
- *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
- *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: amount dateCreated depositDate.
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Deposit objects and the total - * number of Deposit objects available for the given criteria. - * @see ResourceList - */ - static public function listDeposit($criteria = null, $authentication = null) { + /** + * Retrieve Simplify_Deposit objects. + * @param array criteria a map of parameters; valid keys are:
+ *
filter
Filters to apply to the list.
+ *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
+ *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
+ *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: amount dateCreated depositDate.
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Deposit objects and the total + * number of Deposit objects available for the given criteria. + * @see ResourceList + */ + static public function listDeposit($criteria = null, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Deposit(); - $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + $val = new Simplify_Deposit(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); - return $list; - } + return $list; + } - /** - * Retrieve a Simplify_Deposit object from the API - * - * @param string id the id of the Deposit object to retrieve - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Deposit a Deposit object - */ - static public function findDeposit($id, $authentication = null) { + /** + * Retrieve a Simplify_Deposit object from the API + * + * @param string id the id of the Deposit object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Deposit a Deposit object + */ + static public function findDeposit($id, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Deposit(); - $val->id = $id; + $val = new Simplify_Deposit(); + $val->id = $id; - $obj = Simplify_PaymentsApi::findObject($val, $authentication); + $obj = Simplify_PaymentsApi::findObject($val, $authentication); - return $obj; - } + return $obj; + } - /** - * @ignore - */ - public function getClazz() { - return "Deposit"; - } -} \ No newline at end of file + /** + * @ignore + */ + public function getClazz() { + return "Deposit"; + } +} diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Event.php b/includes/gateways/simplify-commerce/includes/Simplify/Event.php index 9f5e5bfe1f0..98546751f9d 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Event.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Event.php @@ -2,63 +2,63 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ class Simplify_Event extends Simplify_Object { - /** - * Creates an Event object - * @param array $hash A map of parameters; valid keys are: - *
paylod
The raw JWS payload.
required - *
url
The URL for the webhook. If present it must match the URL registered for the webhook.
- * @param $authentication Object that contains the API public and private keys. If null the values of the static - * Simplify::$publicKey and Simplify::$privateKey will be used. - * @return Payments_Event an Event object. - * @throws InvalidArgumentException - */ - static public function createEvent($hash, $authentication = null) { + /** + * Creates an Event object + * @param array $hash A map of parameters; valid keys are: + *
paylod
The raw JWS payload.
required + *
url
The URL for the webhook. If present it must match the URL registered for the webhook.
+ * @param $authentication Object that contains the API public and private keys. If null the values of the static + * Simplify::$publicKey and Simplify::$privateKey will be used. + * @return Payments_Event an Event object. + * @throws InvalidArgumentException + */ + static public function createEvent($hash, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $paymentsApi = new Simplify_PaymentsApi(); + $paymentsApi = new Simplify_PaymentsApi(); - $jsonObject = $paymentsApi->jwsDecode($hash, $authentication); + $jsonObject = $paymentsApi->jwsDecode($hash, $authentication); - if ($jsonObject['event'] == null) { - throw new InvalidArgumentException("Incorect data in webhook event"); - } + if ($jsonObject['event'] == null) { + throw new InvalidArgumentException("Incorect data in webhook event"); + } - return $paymentsApi->convertFromHashToObject($jsonObject['event'], self::getClazz()); - } + return $paymentsApi->convertFromHashToObject($jsonObject['event'], self::getClazz()); + } - /** - * @ignore - */ - static public function getClazz() { - return "Event"; - } -} \ No newline at end of file + /** + * @ignore + */ + static public function getClazz() { + return "Event"; + } +} diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Exceptions.php b/includes/gateways/simplify-commerce/includes/Simplify/Exceptions.php index 590b58dc6ab..a8031626e11 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Exceptions.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Exceptions.php @@ -2,27 +2,27 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ @@ -35,82 +35,82 @@ class Simplify_ApiException extends Exception { - protected $errorData; - protected $status; - protected $errorCode; - protected $reference; + protected $errorData; + protected $status; + protected $errorCode; + protected $reference; - /** - * @ignore - */ - function __construct($message, $status = null, $errorData = null) { - parent::__construct($message); + /** + * @ignore + */ + function __construct($message, $status = null, $errorData = null) { + parent::__construct($message); - $this->status = $status; - $this->errorCode = null; - $this->reference = null; + $this->status = $status; + $this->errorCode = null; + $this->reference = null; - if ($errorData != null) { - - $this->reference = $errorData['reference']; - $this->errorData = $errorData; + if ($errorData != null) { - $error = $errorData['error']; - if ($error != null) { - - $m = $error['message']; - if ($m != null) { - $this->message = $m; - } + $this->reference = $errorData['reference']; + $this->errorData = $errorData; - $this->errorCode = $error['code']; - } - } - } - - /** - * Returns a map of all error data returned by the API. - * @return array a map containing API error data. - */ - function getErrorData() { - return $this->errorData; - } + $error = $errorData['error']; + if ($error != null) { - /** - * Returns the HTTP status for the request. - * @return string HTTP status code (or null if there is no status). - */ - function getStatus() { - return $this->status; - } - - /** - * Returns unique reference for the API error. - * @return string a reference (or null if there is no reference). - */ - function getReference() { - return $this->reference; - } + $m = $error['message']; + if ($m != null) { + $this->message = $m; + } - /** - * Returns an code for the API error. - * @return string the error code. - */ - function getErrorCode() { - return $this->errorCode; - } + $this->errorCode = $error['code']; + } + } + } - /** - * Returns a description of the error. - * @return string Description of the error. - */ - function describe() { - return get_class($this) . ": \"" - . $this->getMessage() . "\" (status: " - . $this->getStatus() . ", error code: " - . $this->getErrorCode() . ", reference: " - . $this->getReference() . ")"; - } + /** + * Returns a map of all error data returned by the API. + * @return array a map containing API error data. + */ + function getErrorData() { + return $this->errorData; + } + + /** + * Returns the HTTP status for the request. + * @return string HTTP status code (or null if there is no status). + */ + function getStatus() { + return $this->status; + } + + /** + * Returns unique reference for the API error. + * @return string a reference (or null if there is no reference). + */ + function getReference() { + return $this->reference; + } + + /** + * Returns an code for the API error. + * @return string the error code. + */ + function getErrorCode() { + return $this->errorCode; + } + + /** + * Returns a description of the error. + * @return string Description of the error. + */ + function describe() { + return get_class($this) . ": \"" + . $this->getMessage() . "\" (status: " + . $this->getStatus() . ", error code: " + . $this->getErrorCode() . ", reference: " + . $this->getReference() . ")"; + } } @@ -120,12 +120,12 @@ class Simplify_ApiException extends Exception */ class Simplify_ApiConnectionException extends Simplify_ApiException { - /** - * @ignore - */ - function __construct($message, $status = null, $errorData = null) { - parent::__construct($message, $status, $errorData); - } + /** + * @ignore + */ + function __construct($message, $status = null, $errorData = null) { + parent::__construct($message, $status, $errorData); + } } /** @@ -133,12 +133,12 @@ class Simplify_ApiConnectionException extends Simplify_ApiException { */ class Simplify_AuthenticationException extends Simplify_ApiException { - /** - * @ignore - */ - function __construct($message, $status = null, $errorData = null) { - parent::__construct($message, $status, $errorData); - } + /** + * @ignore + */ + function __construct($message, $status = null, $errorData = null) { + parent::__construct($message, $status, $errorData); + } } /** @@ -146,57 +146,57 @@ class Simplify_AuthenticationException extends Simplify_ApiException { */ class Simplify_BadRequestException extends Simplify_ApiException { - protected $fieldErrors; + protected $fieldErrors; - /** - * @ignore - */ - function __construct($message, $status = null, $errorData = null) { - parent::__construct($message, $status, $errorData); + /** + * @ignore + */ + function __construct($message, $status = null, $errorData = null) { + parent::__construct($message, $status, $errorData); - $fieldErrors = array(); + $fieldErrors = array(); - if ($errorData != null) { - $error = $errorData['error']; - if ($error != null) { - $fieldErrors = $error['fieldErrors']; - if ($fieldErrors != null) { - $this->fieldErrors = array(); - foreach ($fieldErrors as $fieldError) { - array_push($this->fieldErrors, new Simplify_FieldError($fieldError)); - } - } - } - } - } + if ($errorData != null) { + $error = $errorData['error']; + if ($error != null) { + $fieldErrors = $error['fieldErrors']; + if ($fieldErrors != null) { + $this->fieldErrors = array(); + foreach ($fieldErrors as $fieldError) { + array_push($this->fieldErrors, new Simplify_FieldError($fieldError)); + } + } + } + } + } - /** - * Returns a boolean indicating whether there are any field errors. - * @return boolean true if there are field errors; false otherwise. - */ - function hasFieldErrors() { - return count($this->fieldErrors) > 0; - } + /** + * Returns a boolean indicating whether there are any field errors. + * @return boolean true if there are field errors; false otherwise. + */ + function hasFieldErrors() { + return count($this->fieldErrors) > 0; + } - /** - * Returns a list containing all field errors. - * @return array list of field errors. - */ - function getFieldErrors() { - return $this->fieldErrors; - } + /** + * Returns a list containing all field errors. + * @return array list of field errors. + */ + function getFieldErrors() { + return $this->fieldErrors; + } - /** - * Returns a description of the error. - * @return string description of the error. - */ - function describe() { - $s = parent::describe(); - foreach ($this->getFieldErrors() as $fieldError) { - $s = $s . "\n" . (string) $fieldError; - } - return $s . "\n"; - } + /** + * Returns a description of the error. + * @return string description of the error. + */ + function describe() { + $s = parent::describe(); + foreach ($this->getFieldErrors() as $fieldError) { + $s = $s . "\n" . (string) $fieldError; + } + return $s . "\n"; + } } @@ -205,48 +205,48 @@ class Simplify_BadRequestException extends Simplify_ApiException { */ class Simplify_FieldError { - protected $field; - protected $code; - protected $message; + protected $field; + protected $code; + protected $message; - /** - * @ignore - */ - function __construct($errorData) { - - $this->field = $errorData['field']; - $this->code = $errorData['code']; - $this->message = $errorData['message']; - } + /** + * @ignore + */ + function __construct($errorData) { - /** - * Returns the name of the field with the error. - * @return string the field name. - */ - function getFieldName() { - return $this->field; - } + $this->field = $errorData['field']; + $this->code = $errorData['code']; + $this->message = $errorData['message']; + } - /** - * Returns the code for the error. - * @return string the error code. - */ - function getErrorCode() { - return $this->code; - } + /** + * Returns the name of the field with the error. + * @return string the field name. + */ + function getFieldName() { + return $this->field; + } - /** - * Returns a description of the error. - * @return string description of the error. - */ - function getMessage() { - return $this->message; - } + /** + * Returns the code for the error. + * @return string the error code. + */ + function getErrorCode() { + return $this->code; + } + + /** + * Returns a description of the error. + * @return string description of the error. + */ + function getMessage() { + return $this->message; + } - function __toString() { - return "Field error: " . $this->getFieldName() . "\"" . $this->getMessage() . "\" (" . $this->getErrorCode() . ")"; - } + function __toString() { + return "Field error: " . $this->getFieldName() . "\"" . $this->getMessage() . "\" (" . $this->getErrorCode() . ")"; + } } @@ -255,12 +255,12 @@ class Simplify_FieldError { */ class Simplify_ObjectNotFoundException extends Simplify_ApiException { - /** - * @ignore - */ - function __construct($message, $status = null, $errorData = null) { - parent::__construct($message, $status, $errorData); - } + /** + * @ignore + */ + function __construct($message, $status = null, $errorData = null) { + parent::__construct($message, $status, $errorData); + } } /** @@ -268,12 +268,12 @@ class Simplify_ObjectNotFoundException extends Simplify_ApiException { */ class Simplify_NotAllowedException extends Simplify_ApiException { - /** - * @ignore - */ - function __construct($message, $status = null, $errorData = null) { - parent::__construct($message, $status, $errorData); - } + /** + * @ignore + */ + function __construct($message, $status = null, $errorData = null) { + parent::__construct($message, $status, $errorData); + } } /** @@ -281,10 +281,10 @@ class Simplify_NotAllowedException extends Simplify_ApiException { */ class Simplify_SystemException extends Simplify_ApiException { - /** - * @ignore - */ - function __construct($message, $status = null, $errorData = null) { - parent::__construct($message, $status, $errorData); - } + /** + * @ignore + */ + function __construct($message, $status = null, $errorData = null) { + parent::__construct($message, $status, $errorData); + } } diff --git a/includes/gateways/simplify-commerce/includes/Simplify/FraudCheck.php b/includes/gateways/simplify-commerce/includes/Simplify/FraudCheck.php index 01236b9fe52..8ade3f49663 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/FraudCheck.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/FraudCheck.php @@ -2,117 +2,117 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ class Simplify_FraudCheck extends Simplify_Object { - /** - * Creates an Simplify_FraudCheck object - * @param array $hash a map of parameters; valid keys are:
- *
amount
Amount of the transaction to be checked for fraud (in the smallest unit of your currency). Example: 100 = $1.00USD
- *
card.addressCity
City of the cardholder. [max length: 50, min length: 2]
- *
card.addressCountry
Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2]
- *
card.addressLine1
Address of the cardholder. [max length: 255]
- *
card.addressLine2
Address of the cardholder if needed. [max length: 255]
- *
card.addressState
State of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, min length: 2]
- *
card.addressZip
Postal code of the cardholder. The postal code size is between 5 and 9 characters in length and only contains numbers or letters. [max length: 9, min length: 3]
- *
card.cvc
CVC security code of the card. This is the code on the back of the card. Example: 123
- *
card.expMonth
Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] required
- *
card.expYear
Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] required
- *
card.name
Name as it appears on the card. [max length: 50, min length: 2]
- *
card.number
Card number as it appears on the card. [max length: 19, min length: 13] required
- *
currency
Currency code (ISO-4217) for the transaction to be checked for fraud.
- *
description
- Description of the fraud check.
- *
mode
Fraud check mode. “simple” only does an AVS and CVC check; “advanced” does a complete fraud check, running the input against the set up rules. [valid values: simple, advanced, full] required
- *
sessionId
Session ID usd during data collection. [max length: 255]
- *
token
Description
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return FraudCheck a FraudCheck object. - */ - static public function createFraudCheck($hash, $authentication = null) { + /** + * Creates an Simplify_FraudCheck object + * @param array $hash a map of parameters; valid keys are:
+ *
amount
Amount of the transaction to be checked for fraud (in the smallest unit of your currency). Example: 100 = $1.00USD
+ *
card.addressCity
City of the cardholder. [max length: 50, min length: 2]
+ *
card.addressCountry
Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2]
+ *
card.addressLine1
Address of the cardholder. [max length: 255]
+ *
card.addressLine2
Address of the cardholder if needed. [max length: 255]
+ *
card.addressState
State of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, min length: 2]
+ *
card.addressZip
Postal code of the cardholder. The postal code size is between 5 and 9 characters in length and only contains numbers or letters. [max length: 9, min length: 3]
+ *
card.cvc
CVC security code of the card. This is the code on the back of the card. Example: 123
+ *
card.expMonth
Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] required
+ *
card.expYear
Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] required
+ *
card.name
Name as it appears on the card. [max length: 50, min length: 2]
+ *
card.number
Card number as it appears on the card. [max length: 19, min length: 13] required
+ *
currency
Currency code (ISO-4217) for the transaction to be checked for fraud.
+ *
description
- Description of the fraud check.
+ *
mode
Fraud check mode. “simple” only does an AVS and CVC check; “advanced” does a complete fraud check, running the input against the set up rules. [valid values: simple, advanced, full] required
+ *
sessionId
Session ID usd during data collection. [max length: 255]
+ *
token
Description
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return FraudCheck a FraudCheck object. + */ + static public function createFraudCheck($hash, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $instance = new Simplify_FraudCheck(); - $instance->setAll($hash); + $instance = new Simplify_FraudCheck(); + $instance->setAll($hash); - $object = Simplify_PaymentsApi::createObject($instance, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } - /** - * Retrieve Simplify_FraudCheck objects. - * @param array criteria a map of parameters; valid keys are:
- *
filter
Allows for ascending or descending sorting of the list.
- *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
- *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
- *
sorting
Used in paging of the list. This is the start offset of the page. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: .
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of FraudCheck objects and the total - * number of FraudCheck objects available for the given criteria. - * @see ResourceList - */ - static public function listFraudCheck($criteria = null, $authentication = null) { + /** + * Retrieve Simplify_FraudCheck objects. + * @param array criteria a map of parameters; valid keys are:
+ *
filter
Allows for ascending or descending sorting of the list.
+ *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
+ *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
+ *
sorting
Used in paging of the list. This is the start offset of the page. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: .
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of FraudCheck objects and the total + * number of FraudCheck objects available for the given criteria. + * @see ResourceList + */ + static public function listFraudCheck($criteria = null, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_FraudCheck(); - $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + $val = new Simplify_FraudCheck(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); - return $list; - } + return $list; + } - /** - * Retrieve a Simplify_FraudCheck object from the API - * - * @param string id the id of the FraudCheck object to retrieve - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return FraudCheck a FraudCheck object - */ - static public function findFraudCheck($id, $authentication = null) { + /** + * Retrieve a Simplify_FraudCheck object from the API + * + * @param string id the id of the FraudCheck object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return FraudCheck a FraudCheck object + */ + static public function findFraudCheck($id, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_FraudCheck(); - $val->id = $id; + $val = new Simplify_FraudCheck(); + $val->id = $id; - $obj = Simplify_PaymentsApi::findObject($val, $authentication); + $obj = Simplify_PaymentsApi::findObject($val, $authentication); - return $obj; - } + return $obj; + } - /** - * @ignore - */ - public function getClazz() { - return "FraudCheck"; - } -} \ No newline at end of file + /** + * @ignore + */ + public function getClazz() { + return "FraudCheck"; + } +} diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Http.php b/includes/gateways/simplify-commerce/includes/Simplify/Http.php index b7d73d506e4..da85d12c645 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Http.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Http.php @@ -29,379 +29,379 @@ class Simplify_HTTP { - const DELETE = "DELETE"; - const GET = "GET"; - const POST = "POST"; - const PUT = "PUT"; - - const HTTP_SUCCESS = 200; - const HTTP_REDIRECTED = 302; - const HTTP_UNAUTHORIZED = 401; - const HTTP_NOT_FOUND = 404; - const HTTP_NOT_ALLOWED = 405; - const HTTP_BAD_REQUEST = 400; - - - const JWS_NUM_HEADERS = 7; - const JWS_ALGORITHM = 'HS256'; - const JWS_TYPE = 'JWS'; - const JWS_HDR_UNAME = 'uname'; - const JWS_HDR_URI = 'api.simplifycommerce.com/uri'; - const JWS_HDR_TIMESTAMP = 'api.simplifycommerce.com/timestamp'; - const JWS_HDR_NONCE = 'api.simplifycommerce.com/nonce'; - const JWS_HDR_TOKEN = 'api.simplifycommerce.com/token'; - const JWS_MAX_TIMESTAMP_DIFF = 300; // 5 minutes in seconds - - static private $_validMethods = array( - "post" => self::POST, - "put" => self::PUT, - "get" => self::GET, - "delete" => self::DELETE); - - private function request($url, $method, $authentication, $payload = '') - { - if ($authentication->publicKey == null) { - throw new InvalidArgumentException('Must have a valid public key to connect to the API'); - } - - if ($authentication->privateKey == null) { - throw new InvalidArgumentException('Must have a valid API key to connect to the API'); - } - - if (!array_key_exists(strtolower($method), self::$_validMethods)) { - throw new InvalidArgumentException('Invalid method: '.strtolower($method)); - } - - $method = self::$_validMethods[strtolower($method)]; - - $curl = curl_init(); - - $options = array(); - - $options[CURLOPT_URL] = $url; - $options[CURLOPT_CUSTOMREQUEST] = $method; - $options[CURLOPT_RETURNTRANSFER] = true; - $options[CURLOPT_FAILONERROR] = false; - - $signature = $this->jwsEncode($authentication, $url, $payload, $method == self::POST || $method == self::PUT); - - if ($method == self::POST || $method == self::PUT) { - $headers = array( - 'Content-type: application/json' - ); - $options[CURLOPT_POSTFIELDS] = $signature; - } else { - $headers = array( - 'Authorization: JWS ' . $signature - ); - } - - array_push($headers, 'Accept: application/json'); - $user_agent = 'PHP-SDK/' . Simplify_Constants::VERSION; - if (Simplify::$userAgent != null) { - $user_agent = $user_agent . ' ' . Simplify::$userAgent; - } - array_push($headers, 'User-Agent: ' . $user_agent); - - $options[CURLOPT_HTTPHEADER] = $headers; - - curl_setopt_array($curl, $options); - - $data = curl_exec($curl); - $errno = curl_errno($curl); - $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); - - if ($data == false || $errno != CURLE_OK) { - throw new Simplify_ApiConnectionException(curl_error($curl)); - } - - $object = json_decode($data, true); - //'typ' => self::JWS_TYPE, - $response = array('status' => $status, 'object' => $object); - - return $response; - curl_close($curl); - } - - /** - * Handles Simplify API requests - * - * @param $url - * @param $method - * @param $authentication - * @param string $payload - * @return mixed - * @throws Simplify_AuthenticationException - * @throws Simplify_ObjectNotFoundException - * @throws Simplify_BadRequestException - * @throws Simplify_NotAllowedException - * @throws Simplify_SystemException - */ - public function apiRequest($url, $method, $authentication, $payload = ''){ - - $response = $this->request($url, $method, $authentication, $payload); - - $status = $response['status']; - $object = $response['object']; - - if ($status == self::HTTP_SUCCESS) { - return $object; - } - - if ($status == self::HTTP_REDIRECTED) { - throw new Simplify_BadRequestException("Unexpected response code returned from the API, have you got the correct URL?", $status, $object); - } else if ($status == self::HTTP_BAD_REQUEST) { - throw new Simplify_BadRequestException("Bad request", $status, $object); - } else if ($status == self::HTTP_UNAUTHORIZED) { - throw new Simplify_AuthenticationException("You are not authorized to make this request. Are you using the correct API keys?", $status, $object); - } else if ($status == self::HTTP_NOT_FOUND) { - throw new Simplify_ObjectNotFoundException("Object not found", $status, $object); - } else if ($status == self::HTTP_NOT_ALLOWED) { - throw new Simplify_NotAllowedException("Operation not allowed", $status, $object); - } else if ($status < 500) { - throw new Simplify_BadRequestException("Bad request", $status, $object); - } - throw new Simplify_SystemException("An unexpected error has been raised. Looks like there's something wrong at our end." , $status, $object); - } - - /** - * Handles Simplify OAuth requests - * - * @param $url - * @param $payload - * @param $authentication - * @return mixed - * @throws Simplify_AuthenticationException - * @throws Simplify_ObjectNotFoundException - * @throws Simplify_BadRequestException - * @throws Simplify_NotAllowedException - * @throws Simplify_SystemException - */ - public function oauthRequest($url, $payload, $authentication){ - - $response = $this->request($url, Simplify_HTTP::POST, $authentication, $payload); - - $status = $response['status']; - $object = $response['object']; - - if ($status == self::HTTP_SUCCESS) { - return $object; - } - - $error = $object['error']; - $error_description = $object['error_description']; - - if ($status == self::HTTP_REDIRECTED) { - throw new Simplify_BadRequestException("Unexpected response code returned from the API, have you got the correct URL?", $status, $object); - } else if ($status == self::HTTP_BAD_REQUEST) { - - if ( $error == 'invalid_request'){ - throw new Simplify_BadRequestException("", $status, $this->buildOauthError('Error during OAuth request', $error, $error_description)); - }else if ($error == 'unsupported_grant_type'){ - throw new Simplify_BadRequestException("", $status, $this->buildOauthError('Unsupported grant type in OAuth request', $error, $error_description)); - }else if ($error == 'invalid_scope'){ - throw new Simplify_BadRequestException("", $status, $this->buildOauthError('Invalid scope in OAuth request', $error, $error_description)); - }else{ - throw new Simplify_BadRequestException("", $status, $this->buildOauthError('Unknown OAuth error', $error, $error_description)); - } - - //TODO: build BadRequestException error JSON - - } else if ($status == self::HTTP_UNAUTHORIZED){ - - if ($error == 'access_denied'){ - throw new Simplify_AuthenticationException("", $status, $this->buildOauthError('Access denied for OAuth request', $error, $error_description)); - }else if ($error == 'invalid_client'){ - throw new Simplify_AuthenticationException("", $status, $this->buildOauthError('Invalid client ID in OAuth request', $error, $error_description)); - }else if ($error == 'unauthorized_client'){ - throw new Simplify_AuthenticationException("", $status, $this->buildOauthError('Unauthorized client in OAuth request', $error, $error_description)); - }else{ - throw new Simplify_AuthenticationException("", $status, $this->buildOauthError('Unknown authentication error', $error, $error_description)); - } - - } else if ($status < 500) { - throw new Simplify_BadRequestException("Bad request", $status, $object); - } - throw new Simplify_SystemException("An unexpected error has been raised. Looks like there's something wrong at our end." , $status, $object); - } - - public function jwsDecode($authentication, $hash) - { - if ($authentication->publicKey == null) { - throw new InvalidArgumentException('Must have a valid public key to connect to the API'); - } - - if ($authentication->privateKey == null) { - throw new InvalidArgumentException('Must have a valid API key to connect to the API'); - } - - if (!isset($hash['payload'])) { - throw new InvalidArgumentException('Event data is Missing payload'); - } - $payload = trim($hash['payload']); - - - try { - $parts = explode('.', $payload); - if (count($parts) != 3) { - $this->jwsAuthError("Incorrectly formatted JWS message"); - } - - $headerStr = $this->jwsUrlSafeDecode64($parts[0]); - $bodyStr = $this->jwsUrlSafeDecode64($parts[1]); - $sigStr = $parts[2]; - - $url = null; - if (isset($hash['url'])) { - $url = $hash['url']; - } - $this->jwsVerifyHeader($headerStr, $url, $authentication->publicKey); - - $msg = $parts[0] . "." . $parts[1]; - if (!$this->jwsVerifySignature($authentication->privateKey, $msg, $sigStr)) { - $this->jwsAuthError("JWS signature does not match"); - } - - return $bodyStr; - - } catch (ApiException $e) { - throw $e; - } catch (Exception $e) { - $this->jwsAuthError("Exception during JWS decoding: " . $e); - } - } - - private function jwsEncode($authentication, $url, $payload, $hasPayload) - { - // TODO - better seeding of RNG - $jws_hdr = array('typ' => self::JWS_TYPE, - 'alg' => self::JWS_ALGORITHM, - 'kid' => $authentication->publicKey, - self::JWS_HDR_URI => $url, - self::JWS_HDR_TIMESTAMP => sprintf("%u000", round(microtime(true))), - self::JWS_HDR_NONCE => sprintf("%u", mt_rand()), - ); - - // add oauth token if provided - if ( !empty($authentication->accessToken) ){ - $jws_hdr[self::JWS_HDR_TOKEN] = $authentication->accessToken; - } - - $header = $this->jwsUrlSafeEncode64(json_encode($jws_hdr)); - - if ($hasPayload) { - $payload = $this->jwsUrlSafeEncode64($payload); - } else { - $payload = ''; - } - - $msg = $header . "." . $payload; - return $msg . "." . $this->jwsSign($authentication->privateKey, $msg); - } - - private function jwsSign($privateKey, $msg) { - $decodedPrivateKey = $this->jwsUrlSafeDecode64($privateKey); - $sig = hash_hmac('sha256', $msg, $decodedPrivateKey, true); - - return $this->jwsUrlSafeEncode64($sig); - } - - private function jwsVerifyHeader($header, $url, $publicKey) { - - $hdr = json_decode($header, true); - - if (count($hdr) != self::JWS_NUM_HEADERS) { - $this->jwsAuthError("Incorrect number of JWS header parameters - found " . count($hdr) . " required " . self::JWS_NUM_HEADERS); - } - - if ($hdr['alg'] != self::JWS_ALGORITHM) { - $this->jwsAuthError("Incorrect algorithm - found " . $hdr['alg'] . " required " . self::WS_ALGORITHM); - } - - if ($hdr['typ'] != self::JWS_TYPE) { - $this->jwsAuthError("Incorrect type - found " . $hdr['typ'] . " required " . self::JWS_TYPE); - } - - if ($hdr['kid'] == null) { - $this->jwsAuthError("Missing Key ID"); - } - - if ($hdr['kid'] != $publicKey) { - if ($this->isLiveKey($publicKey)) { - $this->jwsAuthError("Invalid Key ID"); - } - } - - if ($hdr[self::JWS_HDR_URI] == null) { - $this->jwsAuthError("Missing URI"); - } - - if ($url != null && $hdr[self::JWS_HDR_URI] != $url) { - $this->jwsAuthError("Incorrect URL - found " . $hdr[self::JWS_HDR_URI] . " required " . $url); - } - - - if ($hdr[self::JWS_HDR_TIMESTAMP] == null) { - $this->jwsAuthError("Missing timestamp"); - } - - if (!$this->jwsVerifyTimestamp($hdr[self::JWS_HDR_TIMESTAMP])) { - $this->jwsAuthError("Invalid timestamp"); - } - - if ($hdr[self::JWS_HDR_NONCE] == null) { - $this->jwsAuthError("Missing nonce"); - } - - if ($hdr[self::JWS_HDR_UNAME] == null) { - $this->jwsAuthError("Missing username"); - } - } - - - private function jwsVerifySignature($privateKey, $msg, $expectedSig) { - return $this->jwsSign($privateKey, $msg) == $expectedSig; - } - - private function jwsAuthError($reason) { - throw new Simplify_AuthenticationException("JWS authentication failure: " . $reason); - } - - private function jwsVerifyTimestamp($ts) { - $now = round(microtime(true)); // Seconds - return abs($now - $ts / 1000) < self::JWS_MAX_TIMESTAMP_DIFF; - } - - private function isLiveKey($k) { - return strpos($k, "lvpb") === 0; - } - - private function jwsUrlSafeEncode64($s) { - return str_replace(array('+', '/', '='), - array('-', '_', ''), - base64_encode($s)); - } + const DELETE = "DELETE"; + const GET = "GET"; + const POST = "POST"; + const PUT = "PUT"; + + const HTTP_SUCCESS = 200; + const HTTP_REDIRECTED = 302; + const HTTP_UNAUTHORIZED = 401; + const HTTP_NOT_FOUND = 404; + const HTTP_NOT_ALLOWED = 405; + const HTTP_BAD_REQUEST = 400; + + + const JWS_NUM_HEADERS = 7; + const JWS_ALGORITHM = 'HS256'; + const JWS_TYPE = 'JWS'; + const JWS_HDR_UNAME = 'uname'; + const JWS_HDR_URI = 'api.simplifycommerce.com/uri'; + const JWS_HDR_TIMESTAMP = 'api.simplifycommerce.com/timestamp'; + const JWS_HDR_NONCE = 'api.simplifycommerce.com/nonce'; + const JWS_HDR_TOKEN = 'api.simplifycommerce.com/token'; + const JWS_MAX_TIMESTAMP_DIFF = 300; // 5 minutes in seconds + + static private $_validMethods = array( + "post" => self::POST, + "put" => self::PUT, + "get" => self::GET, + "delete" => self::DELETE); + + private function request($url, $method, $authentication, $payload = '') + { + if ($authentication->publicKey == null) { + throw new InvalidArgumentException('Must have a valid public key to connect to the API'); + } + + if ($authentication->privateKey == null) { + throw new InvalidArgumentException('Must have a valid API key to connect to the API'); + } + + if (!array_key_exists(strtolower($method), self::$_validMethods)) { + throw new InvalidArgumentException('Invalid method: '.strtolower($method)); + } + + $method = self::$_validMethods[strtolower($method)]; + + $curl = curl_init(); + + $options = array(); + + $options[CURLOPT_URL] = $url; + $options[CURLOPT_CUSTOMREQUEST] = $method; + $options[CURLOPT_RETURNTRANSFER] = true; + $options[CURLOPT_FAILONERROR] = false; + + $signature = $this->jwsEncode($authentication, $url, $payload, $method == self::POST || $method == self::PUT); + + if ($method == self::POST || $method == self::PUT) { + $headers = array( + 'Content-type: application/json' + ); + $options[CURLOPT_POSTFIELDS] = $signature; + } else { + $headers = array( + 'Authorization: JWS ' . $signature + ); + } + + array_push($headers, 'Accept: application/json'); + $user_agent = 'PHP-SDK/' . Simplify_Constants::VERSION; + if (Simplify::$userAgent != null) { + $user_agent = $user_agent . ' ' . Simplify::$userAgent; + } + array_push($headers, 'User-Agent: ' . $user_agent); + + $options[CURLOPT_HTTPHEADER] = $headers; + + curl_setopt_array($curl, $options); + + $data = curl_exec($curl); + $errno = curl_errno($curl); + $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); + + if ($data == false || $errno != CURLE_OK) { + throw new Simplify_ApiConnectionException(curl_error($curl)); + } + + $object = json_decode($data, true); + //'typ' => self::JWS_TYPE, + $response = array('status' => $status, 'object' => $object); + + return $response; + curl_close($curl); + } + + /** + * Handles Simplify API requests + * + * @param $url + * @param $method + * @param $authentication + * @param string $payload + * @return mixed + * @throws Simplify_AuthenticationException + * @throws Simplify_ObjectNotFoundException + * @throws Simplify_BadRequestException + * @throws Simplify_NotAllowedException + * @throws Simplify_SystemException + */ + public function apiRequest($url, $method, $authentication, $payload = ''){ + + $response = $this->request($url, $method, $authentication, $payload); + + $status = $response['status']; + $object = $response['object']; + + if ($status == self::HTTP_SUCCESS) { + return $object; + } + + if ($status == self::HTTP_REDIRECTED) { + throw new Simplify_BadRequestException("Unexpected response code returned from the API, have you got the correct URL?", $status, $object); + } else if ($status == self::HTTP_BAD_REQUEST) { + throw new Simplify_BadRequestException("Bad request", $status, $object); + } else if ($status == self::HTTP_UNAUTHORIZED) { + throw new Simplify_AuthenticationException("You are not authorized to make this request. Are you using the correct API keys?", $status, $object); + } else if ($status == self::HTTP_NOT_FOUND) { + throw new Simplify_ObjectNotFoundException("Object not found", $status, $object); + } else if ($status == self::HTTP_NOT_ALLOWED) { + throw new Simplify_NotAllowedException("Operation not allowed", $status, $object); + } else if ($status < 500) { + throw new Simplify_BadRequestException("Bad request", $status, $object); + } + throw new Simplify_SystemException("An unexpected error has been raised. Looks like there's something wrong at our end." , $status, $object); + } + + /** + * Handles Simplify OAuth requests + * + * @param $url + * @param $payload + * @param $authentication + * @return mixed + * @throws Simplify_AuthenticationException + * @throws Simplify_ObjectNotFoundException + * @throws Simplify_BadRequestException + * @throws Simplify_NotAllowedException + * @throws Simplify_SystemException + */ + public function oauthRequest($url, $payload, $authentication){ + + $response = $this->request($url, Simplify_HTTP::POST, $authentication, $payload); + + $status = $response['status']; + $object = $response['object']; + + if ($status == self::HTTP_SUCCESS) { + return $object; + } + + $error = $object['error']; + $error_description = $object['error_description']; + + if ($status == self::HTTP_REDIRECTED) { + throw new Simplify_BadRequestException("Unexpected response code returned from the API, have you got the correct URL?", $status, $object); + } else if ($status == self::HTTP_BAD_REQUEST) { + + if ( $error == 'invalid_request'){ + throw new Simplify_BadRequestException("", $status, $this->buildOauthError('Error during OAuth request', $error, $error_description)); + }else if ($error == 'unsupported_grant_type'){ + throw new Simplify_BadRequestException("", $status, $this->buildOauthError('Unsupported grant type in OAuth request', $error, $error_description)); + }else if ($error == 'invalid_scope'){ + throw new Simplify_BadRequestException("", $status, $this->buildOauthError('Invalid scope in OAuth request', $error, $error_description)); + }else{ + throw new Simplify_BadRequestException("", $status, $this->buildOauthError('Unknown OAuth error', $error, $error_description)); + } + + //TODO: build BadRequestException error JSON + + } else if ($status == self::HTTP_UNAUTHORIZED){ + + if ($error == 'access_denied'){ + throw new Simplify_AuthenticationException("", $status, $this->buildOauthError('Access denied for OAuth request', $error, $error_description)); + }else if ($error == 'invalid_client'){ + throw new Simplify_AuthenticationException("", $status, $this->buildOauthError('Invalid client ID in OAuth request', $error, $error_description)); + }else if ($error == 'unauthorized_client'){ + throw new Simplify_AuthenticationException("", $status, $this->buildOauthError('Unauthorized client in OAuth request', $error, $error_description)); + }else{ + throw new Simplify_AuthenticationException("", $status, $this->buildOauthError('Unknown authentication error', $error, $error_description)); + } + + } else if ($status < 500) { + throw new Simplify_BadRequestException("Bad request", $status, $object); + } + throw new Simplify_SystemException("An unexpected error has been raised. Looks like there's something wrong at our end." , $status, $object); + } + + public function jwsDecode($authentication, $hash) + { + if ($authentication->publicKey == null) { + throw new InvalidArgumentException('Must have a valid public key to connect to the API'); + } + + if ($authentication->privateKey == null) { + throw new InvalidArgumentException('Must have a valid API key to connect to the API'); + } + + if (!isset($hash['payload'])) { + throw new InvalidArgumentException('Event data is Missing payload'); + } + $payload = trim($hash['payload']); + + + try { + $parts = explode('.', $payload); + if (count($parts) != 3) { + $this->jwsAuthError("Incorrectly formatted JWS message"); + } + + $headerStr = $this->jwsUrlSafeDecode64($parts[0]); + $bodyStr = $this->jwsUrlSafeDecode64($parts[1]); + $sigStr = $parts[2]; + + $url = null; + if (isset($hash['url'])) { + $url = $hash['url']; + } + $this->jwsVerifyHeader($headerStr, $url, $authentication->publicKey); + + $msg = $parts[0] . "." . $parts[1]; + if (!$this->jwsVerifySignature($authentication->privateKey, $msg, $sigStr)) { + $this->jwsAuthError("JWS signature does not match"); + } + + return $bodyStr; + + } catch (ApiException $e) { + throw $e; + } catch (Exception $e) { + $this->jwsAuthError("Exception during JWS decoding: " . $e); + } + } + + private function jwsEncode($authentication, $url, $payload, $hasPayload) + { + // TODO - better seeding of RNG + $jws_hdr = array('typ' => self::JWS_TYPE, + 'alg' => self::JWS_ALGORITHM, + 'kid' => $authentication->publicKey, + self::JWS_HDR_URI => $url, + self::JWS_HDR_TIMESTAMP => sprintf("%u000", round(microtime(true))), + self::JWS_HDR_NONCE => sprintf("%u", mt_rand()), + ); + + // add oauth token if provided + if ( !empty($authentication->accessToken) ){ + $jws_hdr[self::JWS_HDR_TOKEN] = $authentication->accessToken; + } + + $header = $this->jwsUrlSafeEncode64(json_encode($jws_hdr)); + + if ($hasPayload) { + $payload = $this->jwsUrlSafeEncode64($payload); + } else { + $payload = ''; + } + + $msg = $header . "." . $payload; + return $msg . "." . $this->jwsSign($authentication->privateKey, $msg); + } + + private function jwsSign($privateKey, $msg) { + $decodedPrivateKey = $this->jwsUrlSafeDecode64($privateKey); + $sig = hash_hmac('sha256', $msg, $decodedPrivateKey, true); + + return $this->jwsUrlSafeEncode64($sig); + } + + private function jwsVerifyHeader($header, $url, $publicKey) { + + $hdr = json_decode($header, true); + + if (count($hdr) != self::JWS_NUM_HEADERS) { + $this->jwsAuthError("Incorrect number of JWS header parameters - found " . count($hdr) . " required " . self::JWS_NUM_HEADERS); + } + + if ($hdr['alg'] != self::JWS_ALGORITHM) { + $this->jwsAuthError("Incorrect algorithm - found " . $hdr['alg'] . " required " . self::WS_ALGORITHM); + } + + if ($hdr['typ'] != self::JWS_TYPE) { + $this->jwsAuthError("Incorrect type - found " . $hdr['typ'] . " required " . self::JWS_TYPE); + } + + if ($hdr['kid'] == null) { + $this->jwsAuthError("Missing Key ID"); + } + + if ($hdr['kid'] != $publicKey) { + if ($this->isLiveKey($publicKey)) { + $this->jwsAuthError("Invalid Key ID"); + } + } + + if ($hdr[self::JWS_HDR_URI] == null) { + $this->jwsAuthError("Missing URI"); + } + + if ($url != null && $hdr[self::JWS_HDR_URI] != $url) { + $this->jwsAuthError("Incorrect URL - found " . $hdr[self::JWS_HDR_URI] . " required " . $url); + } + + + if ($hdr[self::JWS_HDR_TIMESTAMP] == null) { + $this->jwsAuthError("Missing timestamp"); + } + + if (!$this->jwsVerifyTimestamp($hdr[self::JWS_HDR_TIMESTAMP])) { + $this->jwsAuthError("Invalid timestamp"); + } + + if ($hdr[self::JWS_HDR_NONCE] == null) { + $this->jwsAuthError("Missing nonce"); + } + + if ($hdr[self::JWS_HDR_UNAME] == null) { + $this->jwsAuthError("Missing username"); + } + } + + + private function jwsVerifySignature($privateKey, $msg, $expectedSig) { + return $this->jwsSign($privateKey, $msg) == $expectedSig; + } + + private function jwsAuthError($reason) { + throw new Simplify_AuthenticationException("JWS authentication failure: " . $reason); + } + + private function jwsVerifyTimestamp($ts) { + $now = round(microtime(true)); // Seconds + return abs($now - $ts / 1000) < self::JWS_MAX_TIMESTAMP_DIFF; + } + + private function isLiveKey($k) { + return strpos($k, "lvpb") === 0; + } + + private function jwsUrlSafeEncode64($s) { + return str_replace(array('+', '/', '='), + array('-', '_', ''), + base64_encode($s)); + } - private function jwsUrlSafeDecode64($s) { - - switch (strlen($s) % 4) { - case 0: break; - case 2: $s = $s . "=="; - break; - case 3: $s = $s . "="; - break; - default: throw new InvalidArgumentException('incorrecly formatted JWS payload'); - } - return base64_decode(str_replace(array('-', '_'), array('+', '/'), $s)); - } + private function jwsUrlSafeDecode64($s) { + + switch (strlen($s) % 4) { + case 0: break; + case 2: $s = $s . "=="; + break; + case 3: $s = $s . "="; + break; + default: throw new InvalidArgumentException('incorrecly formatted JWS payload'); + } + return base64_decode(str_replace(array('-', '_'), array('+', '/'), $s)); + } - private function buildOauthError($msg, $error, $error_description){ - - return array( - 'error' => array( - 'code' => 'oauth_error', - 'message' => $msg.', error code: '.$error.', description: '.$error_description.'' - ) - ); - } + private function buildOauthError($msg, $error, $error_description){ + + return array( + 'error' => array( + 'code' => 'oauth_error', + 'message' => $msg.', error code: '.$error.', description: '.$error_description.'' + ) + ); + } } diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Invoice.php b/includes/gateways/simplify-commerce/includes/Simplify/Invoice.php index 854811506e6..5075748107d 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Invoice.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Invoice.php @@ -2,223 +2,223 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ class Simplify_Invoice extends Simplify_Object { - /** - * Creates an Simplify_Invoice object - * @param array $hash a map of parameters; valid keys are:
- *
billingAddress.city
Billing address city of the location where the goods or services were supplied. [max length: 255, min length: 2]
- *
billingAddress.country
Billing address country of the location where the goods or services were supplied. [max length: 2, min length: 2]
- *
billingAddress.line1
Billing address line 1 of the location where the goods or services were supplied. [max length: 255]
- *
billingAddress.line2
Billing address line 2 of the location where the goods or services were supplied. [max length: 255]
- *
billingAddress.name
Billing address name of the location where the goods or services were supplied. Will use the customer name if not provided. [max length: 255]
- *
billingAddress.state
Billing address state of the location where the goods or services were supplied. [max length: 255]
- *
billingAddress.zip
Billing address zip of the location where the goods or services were supplied. [max length: 32]
- *
businessAddress.city
Address city of the business that is sending the invoice. [max length: 255, min length: 2]
- *
businessAddress.country
Address country of the business that is sending the invoice. [max length: 2, min length: 2]
- *
businessAddress.line1
Address line 1 of the business that is sending the invoice. [max length: 255]
- *
businessAddress.line2
Address line 2 of the business that is sending the invoice. [max length: 255]
- *
businessAddress.name
The name of the business that is sending the invoice. [max length: 255]
- *
businessAddress.state
Address state of the business that is sending the invoice. [max length: 255]
- *
businessAddress.zip
Address zip of the business that is sending the invoice. [max length: 32]
- *
currency
Currency code (ISO-4217). Must match the currency associated with your account. [max length: 3, min length: 3, default: USD]
- *
customer
The customer ID of the customer we are invoicing. This is optional if invoiceToCopy or a name and email are provided
- *
customerTaxNo
The tax number or VAT id of the person to whom the goods or services were supplied. [max length: 255]
- *
discountRate
The discount percent as a decimal e.g. 12.5. This is used to calculate the discount amount which is subtracted from the total amount due before any tax is applied. [max length: 6]
- *
dueDate
The date invoice payment is due. If a late fee is provided this will be added to the invoice total is the due date has past.
- *
email
The email of the customer we are invoicing. This is optional if customer or invoiceToCopy is provided. A new customer will be created using the the name and email.
- *
invoiceId
User defined invoice id. If not provided the system will generate a numeric id. [max length: 255]
- *
invoiceToCopy
The id of an existing invoice to be copied. This is optional if customer or a name and email are provided
- *
items.amount
Amount of the invoice item (the smallest unit of your currency). Example: 100 = $1.00USD [min value: -9999900, max value: 9999900] required
- *
items.description
The description of the invoice item. [max length: 1024]
- *
items.invoice
The ID of the invoice this item belongs to.
- *
items.product
The product this invoice item refers to.
- *
items.quantity
Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999, default: 1]
- *
items.reference
User defined reference field. [max length: 255]
- *
items.tax
The tax ID of the tax charge in the invoice item.
- *
lateFee
The late fee amount that will be added to the invoice total is the due date is past due. Value provided must be in the smallest unit of your currency. Example: 100 = $1.00USD [max value: 9999900]
- *
memo
A memo that is displayed to the customer on the invoice payment screen. [max length: 4000]
- *
name
The name of the customer we are invoicing. This is optional if customer or invoiceToCopy is provided. A new customer will be created using the the name and email. [max length: 50, min length: 2]
- *
note
This field can be used to store a note that is not displayed to the customer. [max length: 4000]
- *
reference
User defined reference field. [max length: 255]
- *
shippingAddress.city
Address city of the location where the goods or services were supplied. [max length: 255, min length: 2]
- *
shippingAddress.country
Address country of the location where the goods or services were supplied. [max length: 2, min length: 2]
- *
shippingAddress.line1
Address line 1 of the location where the goods or services were supplied. [max length: 255]
- *
shippingAddress.line2
Address line 2 of the location where the goods or services were supplied. [max length: 255]
- *
shippingAddress.name
Address name of the location where the goods or services were supplied. [max length: 255]
- *
shippingAddress.state
Address state of the location where the goods or services were supplied. [max length: 255]
- *
shippingAddress.zip
Address zip of the location where the goods or services were supplied. [max length: 32]
- *
suppliedDate
The date on which the goods or services were supplied.
- *
taxNo
The tax number or VAT id of the person who supplied the goods or services. [max length: 255]
- *
type
The type of invoice. One of WEB or MOBILE. [valid values: WEB, MOBILE, default: WEB]
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Invoice a Invoice object. - */ - static public function createInvoice($hash, $authentication = null) { + /** + * Creates an Simplify_Invoice object + * @param array $hash a map of parameters; valid keys are:
+ *
billingAddress.city
Billing address city of the location where the goods or services were supplied. [max length: 255, min length: 2]
+ *
billingAddress.country
Billing address country of the location where the goods or services were supplied. [max length: 2, min length: 2]
+ *
billingAddress.line1
Billing address line 1 of the location where the goods or services were supplied. [max length: 255]
+ *
billingAddress.line2
Billing address line 2 of the location where the goods or services were supplied. [max length: 255]
+ *
billingAddress.name
Billing address name of the location where the goods or services were supplied. Will use the customer name if not provided. [max length: 255]
+ *
billingAddress.state
Billing address state of the location where the goods or services were supplied. [max length: 255]
+ *
billingAddress.zip
Billing address zip of the location where the goods or services were supplied. [max length: 32]
+ *
businessAddress.city
Address city of the business that is sending the invoice. [max length: 255, min length: 2]
+ *
businessAddress.country
Address country of the business that is sending the invoice. [max length: 2, min length: 2]
+ *
businessAddress.line1
Address line 1 of the business that is sending the invoice. [max length: 255]
+ *
businessAddress.line2
Address line 2 of the business that is sending the invoice. [max length: 255]
+ *
businessAddress.name
The name of the business that is sending the invoice. [max length: 255]
+ *
businessAddress.state
Address state of the business that is sending the invoice. [max length: 255]
+ *
businessAddress.zip
Address zip of the business that is sending the invoice. [max length: 32]
+ *
currency
Currency code (ISO-4217). Must match the currency associated with your account. [max length: 3, min length: 3, default: USD]
+ *
customer
The customer ID of the customer we are invoicing. This is optional if invoiceToCopy or a name and email are provided
+ *
customerTaxNo
The tax number or VAT id of the person to whom the goods or services were supplied. [max length: 255]
+ *
discountRate
The discount percent as a decimal e.g. 12.5. This is used to calculate the discount amount which is subtracted from the total amount due before any tax is applied. [max length: 6]
+ *
dueDate
The date invoice payment is due. If a late fee is provided this will be added to the invoice total is the due date has past.
+ *
email
The email of the customer we are invoicing. This is optional if customer or invoiceToCopy is provided. A new customer will be created using the the name and email.
+ *
invoiceId
User defined invoice id. If not provided the system will generate a numeric id. [max length: 255]
+ *
invoiceToCopy
The id of an existing invoice to be copied. This is optional if customer or a name and email are provided
+ *
items.amount
Amount of the invoice item (the smallest unit of your currency). Example: 100 = $1.00USD [min value: -9999900, max value: 9999900] required
+ *
items.description
The description of the invoice item. [max length: 1024]
+ *
items.invoice
The ID of the invoice this item belongs to.
+ *
items.product
The product this invoice item refers to.
+ *
items.quantity
Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999, default: 1]
+ *
items.reference
User defined reference field. [max length: 255]
+ *
items.tax
The tax ID of the tax charge in the invoice item.
+ *
lateFee
The late fee amount that will be added to the invoice total is the due date is past due. Value provided must be in the smallest unit of your currency. Example: 100 = $1.00USD [max value: 9999900]
+ *
memo
A memo that is displayed to the customer on the invoice payment screen. [max length: 4000]
+ *
name
The name of the customer we are invoicing. This is optional if customer or invoiceToCopy is provided. A new customer will be created using the the name and email. [max length: 50, min length: 2]
+ *
note
This field can be used to store a note that is not displayed to the customer. [max length: 4000]
+ *
reference
User defined reference field. [max length: 255]
+ *
shippingAddress.city
Address city of the location where the goods or services were supplied. [max length: 255, min length: 2]
+ *
shippingAddress.country
Address country of the location where the goods or services were supplied. [max length: 2, min length: 2]
+ *
shippingAddress.line1
Address line 1 of the location where the goods or services were supplied. [max length: 255]
+ *
shippingAddress.line2
Address line 2 of the location where the goods or services were supplied. [max length: 255]
+ *
shippingAddress.name
Address name of the location where the goods or services were supplied. [max length: 255]
+ *
shippingAddress.state
Address state of the location where the goods or services were supplied. [max length: 255]
+ *
shippingAddress.zip
Address zip of the location where the goods or services were supplied. [max length: 32]
+ *
suppliedDate
The date on which the goods or services were supplied.
+ *
taxNo
The tax number or VAT id of the person who supplied the goods or services. [max length: 255]
+ *
type
The type of invoice. One of WEB or MOBILE. [valid values: WEB, MOBILE, default: WEB]
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Invoice a Invoice object. + */ + static public function createInvoice($hash, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $instance = new Simplify_Invoice(); - $instance->setAll($hash); + $instance = new Simplify_Invoice(); + $instance->setAll($hash); - $object = Simplify_PaymentsApi::createObject($instance, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } - /** - * Deletes an Simplify_Invoice object. - * - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - */ - public function deleteInvoice($authentication = null) { + /** + * Deletes an Simplify_Invoice object. + * + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + */ + public function deleteInvoice($authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); - $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); - $this->properties = null; - return true; - } + $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); + $this->properties = null; + return true; + } - /** - * Retrieve Simplify_Invoice objects. - * @param array criteria a map of parameters; valid keys are:
- *
filter
Filters to apply to the list.
- *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
- *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
- *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: id invoiceDate dueDate datePaid customer status dateCreated.
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Invoice objects and the total - * number of Invoice objects available for the given criteria. - * @see ResourceList - */ - static public function listInvoice($criteria = null, $authentication = null) { + /** + * Retrieve Simplify_Invoice objects. + * @param array criteria a map of parameters; valid keys are:
+ *
filter
Filters to apply to the list.
+ *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
+ *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
+ *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: id invoiceDate dueDate datePaid customer status dateCreated.
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Invoice objects and the total + * number of Invoice objects available for the given criteria. + * @see ResourceList + */ + static public function listInvoice($criteria = null, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Invoice(); - $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + $val = new Simplify_Invoice(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); - return $list; - } + return $list; + } - /** - * Retrieve a Simplify_Invoice object from the API - * - * @param string id the id of the Invoice object to retrieve - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Invoice a Invoice object - */ - static public function findInvoice($id, $authentication = null) { + /** + * Retrieve a Simplify_Invoice object from the API + * + * @param string id the id of the Invoice object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Invoice a Invoice object + */ + static public function findInvoice($id, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Invoice(); - $val->id = $id; + $val = new Simplify_Invoice(); + $val->id = $id; - $obj = Simplify_PaymentsApi::findObject($val, $authentication); + $obj = Simplify_PaymentsApi::findObject($val, $authentication); - return $obj; - } + return $obj; + } - /** - * Updates an Simplify_Invoice object. - * - * The properties that can be updated: - *
- *
billingAddress.city
Billing address city of the location where the goods or services were supplied. [max length: 255, min length: 2]
- *
billingAddress.country
Billing address country of the location where the goods or services were supplied. [max length: 2, min length: 2]
- *
billingAddress.line1
Billing address line 1 of the location where the goods or services were supplied. [max length: 255]
- *
billingAddress.line2
Billing address line 2 of the location where the goods or services were supplied. [max length: 255]
- *
billingAddress.name
Billing address name of the location where the goods or services were supplied. [max length: 255]
- *
billingAddress.state
Billing address state of the location where the goods or services were supplied. [max length: 255]
- *
billingAddress.zip
Billing address zip of the location where the goods or services were supplied. [max length: 32]
- *
businessAddress.city
Business address city of the business that is sending the invoice. [max length: 255, min length: 2]
- *
businessAddress.country
Business address country of the business that is sending the invoice. [max length: 2, min length: 2]
- *
businessAddress.line1
Business address line 1 of the business that is sending the invoice. [max length: 255]
- *
businessAddress.line2
Business address line 2 of the business that is sending the invoice. [max length: 255]
- *
businessAddress.name
Business address name of the business that is sending the invoice. [max length: 255]
- *
businessAddress.state
Business address state of the business that is sending the invoice. [max length: 255]
- *
businessAddress.zip
Business address zip of the business that is sending the invoice. [max length: 32]
- *
currency
Currency code (ISO-4217). Must match the currency associated with your account. [max length: 3, min length: 3]
- *
customerTaxNo
The tax number or VAT id of the person to whom the goods or services were supplied. [max length: 255]
- *
datePaid
This is the date the invoice was PAID in UTC millis.
- *
discountRate
The discount percent as a decimal e.g. 12.5. This is used to calculate the discount amount which is subtracted from the total amount due before any tax is applied. [max length: 6]
- *
dueDate
The date invoice payment is due. If a late fee is provided this will be added to the invoice total is the due date has past.
- *
email
The email of the customer we are invoicing. This is optional if customer or invoiceToCopy is provided. A new customer will be created using the the name and email.
- *
invoiceId
User defined invoice id. If not provided the system will generate a numeric id. [max length: 255]
- *
items.amount
Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00USD [min value: -9999900, max value: 9999900] required
- *
items.description
The description of the invoice item. [max length: 1024]
- *
items.invoice
The ID of the invoice this item belongs to.
- *
items.product
The Id of the product this item refers to.
- *
items.quantity
Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999, default: 1]
- *
items.reference
User defined reference field. [max length: 255]
- *
items.tax
The tax ID of the tax charge in the invoice item.
- *
lateFee
The late fee amount that will be added to the invoice total is the due date is past due. Value provided must be in the smallest unit of your currency. Example: 100 = $1.00USD [max value: 9999900]
- *
memo
A memo that is displayed to the customer on the invoice payment screen. [max length: 4000]
- *
name
The name of the customer we are invoicing. This is optional if customer or invoiceToCopy is provided. A new customer will be created using the the name and email. [max length: 50, min length: 2]
- *
note
This field can be used to store a note that is not displayed to the customer. [max length: 4000]
- *
payment
The ID of the payment. Use this ID to query the /payment API. [max length: 255]
- *
reference
User defined reference field. [max length: 255]
- *
shippingAddress.city
Address city of the location where the goods or services were supplied. [max length: 255, min length: 2]
- *
shippingAddress.country
Address country of the location where the goods or services were supplied. [max length: 2, min length: 2]
- *
shippingAddress.line1
Address line 1 of the location where the goods or services were supplied. [max length: 255]
- *
shippingAddress.line2
Address line 2 of the location where the goods or services were supplied. [max length: 255]
- *
shippingAddress.name
Address name of the location where the goods or services were supplied. [max length: 255]
- *
shippingAddress.state
Address state of the location where the goods or services were supplied. [max length: 255]
- *
shippingAddress.zip
Address zip of the location where the goods or services were supplied. [max length: 32]
- *
status
New status of the invoice.
- *
suppliedDate
The date on which the goods or services were supplied.
- *
taxNo
The tax number or VAT id of the person who supplied the goods or services. [max length: 255]
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Invoice a Invoice object. - */ - public function updateInvoice($authentication = null) { + /** + * Updates an Simplify_Invoice object. + * + * The properties that can be updated: + *
+ *
billingAddress.city
Billing address city of the location where the goods or services were supplied. [max length: 255, min length: 2]
+ *
billingAddress.country
Billing address country of the location where the goods or services were supplied. [max length: 2, min length: 2]
+ *
billingAddress.line1
Billing address line 1 of the location where the goods or services were supplied. [max length: 255]
+ *
billingAddress.line2
Billing address line 2 of the location where the goods or services were supplied. [max length: 255]
+ *
billingAddress.name
Billing address name of the location where the goods or services were supplied. [max length: 255]
+ *
billingAddress.state
Billing address state of the location where the goods or services were supplied. [max length: 255]
+ *
billingAddress.zip
Billing address zip of the location where the goods or services were supplied. [max length: 32]
+ *
businessAddress.city
Business address city of the business that is sending the invoice. [max length: 255, min length: 2]
+ *
businessAddress.country
Business address country of the business that is sending the invoice. [max length: 2, min length: 2]
+ *
businessAddress.line1
Business address line 1 of the business that is sending the invoice. [max length: 255]
+ *
businessAddress.line2
Business address line 2 of the business that is sending the invoice. [max length: 255]
+ *
businessAddress.name
Business address name of the business that is sending the invoice. [max length: 255]
+ *
businessAddress.state
Business address state of the business that is sending the invoice. [max length: 255]
+ *
businessAddress.zip
Business address zip of the business that is sending the invoice. [max length: 32]
+ *
currency
Currency code (ISO-4217). Must match the currency associated with your account. [max length: 3, min length: 3]
+ *
customerTaxNo
The tax number or VAT id of the person to whom the goods or services were supplied. [max length: 255]
+ *
datePaid
This is the date the invoice was PAID in UTC millis.
+ *
discountRate
The discount percent as a decimal e.g. 12.5. This is used to calculate the discount amount which is subtracted from the total amount due before any tax is applied. [max length: 6]
+ *
dueDate
The date invoice payment is due. If a late fee is provided this will be added to the invoice total is the due date has past.
+ *
email
The email of the customer we are invoicing. This is optional if customer or invoiceToCopy is provided. A new customer will be created using the the name and email.
+ *
invoiceId
User defined invoice id. If not provided the system will generate a numeric id. [max length: 255]
+ *
items.amount
Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00USD [min value: -9999900, max value: 9999900] required
+ *
items.description
The description of the invoice item. [max length: 1024]
+ *
items.invoice
The ID of the invoice this item belongs to.
+ *
items.product
The Id of the product this item refers to.
+ *
items.quantity
Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999, default: 1]
+ *
items.reference
User defined reference field. [max length: 255]
+ *
items.tax
The tax ID of the tax charge in the invoice item.
+ *
lateFee
The late fee amount that will be added to the invoice total is the due date is past due. Value provided must be in the smallest unit of your currency. Example: 100 = $1.00USD [max value: 9999900]
+ *
memo
A memo that is displayed to the customer on the invoice payment screen. [max length: 4000]
+ *
name
The name of the customer we are invoicing. This is optional if customer or invoiceToCopy is provided. A new customer will be created using the the name and email. [max length: 50, min length: 2]
+ *
note
This field can be used to store a note that is not displayed to the customer. [max length: 4000]
+ *
payment
The ID of the payment. Use this ID to query the /payment API. [max length: 255]
+ *
reference
User defined reference field. [max length: 255]
+ *
shippingAddress.city
Address city of the location where the goods or services were supplied. [max length: 255, min length: 2]
+ *
shippingAddress.country
Address country of the location where the goods or services were supplied. [max length: 2, min length: 2]
+ *
shippingAddress.line1
Address line 1 of the location where the goods or services were supplied. [max length: 255]
+ *
shippingAddress.line2
Address line 2 of the location where the goods or services were supplied. [max length: 255]
+ *
shippingAddress.name
Address name of the location where the goods or services were supplied. [max length: 255]
+ *
shippingAddress.state
Address state of the location where the goods or services were supplied. [max length: 255]
+ *
shippingAddress.zip
Address zip of the location where the goods or services were supplied. [max length: 32]
+ *
status
New status of the invoice.
+ *
suppliedDate
The date on which the goods or services were supplied.
+ *
taxNo
The tax number or VAT id of the person who supplied the goods or services. [max length: 255]
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Invoice a Invoice object. + */ + public function updateInvoice($authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); - $object = Simplify_PaymentsApi::updateObject($this, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::updateObject($this, $authentication); + return $object; + } - /** - * @ignore - */ - public function getClazz() { - return "Invoice"; - } -} \ No newline at end of file + /** + * @ignore + */ + public function getClazz() { + return "Invoice"; + } +} diff --git a/includes/gateways/simplify-commerce/includes/Simplify/InvoiceItem.php b/includes/gateways/simplify-commerce/includes/Simplify/InvoiceItem.php index 183add41434..2d40f66b942 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/InvoiceItem.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/InvoiceItem.php @@ -2,123 +2,123 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ class Simplify_InvoiceItem extends Simplify_Object { - /** - * Creates an Simplify_InvoiceItem object - * @param array $hash a map of parameters; valid keys are:
- *
amount
Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00USD [min value: -9999900, max value: 9999900] required
- *
description
Individual items of an invoice [max length: 1024]
- *
invoice
The ID of the invoice this item belongs to.
- *
product
Product ID this item relates to.
- *
quantity
Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999, default: 1]
- *
reference
User defined reference field. [max length: 255]
- *
tax
The tax ID of the tax charge in the invoice item.
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return InvoiceItem a InvoiceItem object. - */ - static public function createInvoiceItem($hash, $authentication = null) { + /** + * Creates an Simplify_InvoiceItem object + * @param array $hash a map of parameters; valid keys are:
+ *
amount
Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00USD [min value: -9999900, max value: 9999900] required
+ *
description
Individual items of an invoice [max length: 1024]
+ *
invoice
The ID of the invoice this item belongs to.
+ *
product
Product ID this item relates to.
+ *
quantity
Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999, default: 1]
+ *
reference
User defined reference field. [max length: 255]
+ *
tax
The tax ID of the tax charge in the invoice item.
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return InvoiceItem a InvoiceItem object. + */ + static public function createInvoiceItem($hash, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $instance = new Simplify_InvoiceItem(); - $instance->setAll($hash); + $instance = new Simplify_InvoiceItem(); + $instance->setAll($hash); - $object = Simplify_PaymentsApi::createObject($instance, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } - /** - * Deletes an Simplify_InvoiceItem object. - * - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - */ - public function deleteInvoiceItem($authentication = null) { + /** + * Deletes an Simplify_InvoiceItem object. + * + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + */ + public function deleteInvoiceItem($authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); - $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); - $this->properties = null; - return true; - } + $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); + $this->properties = null; + return true; + } - /** - * Retrieve a Simplify_InvoiceItem object from the API - * - * @param string id the id of the InvoiceItem object to retrieve - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return InvoiceItem a InvoiceItem object - */ - static public function findInvoiceItem($id, $authentication = null) { + /** + * Retrieve a Simplify_InvoiceItem object from the API + * + * @param string id the id of the InvoiceItem object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return InvoiceItem a InvoiceItem object + */ + static public function findInvoiceItem($id, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_InvoiceItem(); - $val->id = $id; + $val = new Simplify_InvoiceItem(); + $val->id = $id; - $obj = Simplify_PaymentsApi::findObject($val, $authentication); + $obj = Simplify_PaymentsApi::findObject($val, $authentication); - return $obj; - } + return $obj; + } - /** - * Updates an Simplify_InvoiceItem object. - * - * The properties that can be updated: - *
- *
amount
Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00USD [min value: 1]
- *
description
Individual items of an invoice
- *
quantity
Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999]
- *
reference
User defined reference field.
- *
tax
The tax ID of the tax charge in the invoice item.
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return InvoiceItem a InvoiceItem object. - */ - public function updateInvoiceItem($authentication = null) { + /** + * Updates an Simplify_InvoiceItem object. + * + * The properties that can be updated: + *
+ *
amount
Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00USD [min value: 1]
+ *
description
Individual items of an invoice
+ *
quantity
Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999]
+ *
reference
User defined reference field.
+ *
tax
The tax ID of the tax charge in the invoice item.
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return InvoiceItem a InvoiceItem object. + */ + public function updateInvoiceItem($authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); - $object = Simplify_PaymentsApi::updateObject($this, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::updateObject($this, $authentication); + return $object; + } - /** - * @ignore - */ - public function getClazz() { - return "InvoiceItem"; - } -} \ No newline at end of file + /** + * @ignore + */ + public function getClazz() { + return "InvoiceItem"; + } +} diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Object.php b/includes/gateways/simplify-commerce/includes/Simplify/Object.php index 0885fa38666..8d8293f7f3e 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Object.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Object.php @@ -2,27 +2,27 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ @@ -32,48 +32,48 @@ */ class Simplify_Object { - private $properties = array(); + private $properties = array(); - /** - * @ignore - */ - public function __get($key) { - if (array_key_exists($key, $this->properties)) { - return $this->properties[$key]; - } else { - return null; - } - } + /** + * @ignore + */ + public function __get($key) { + if (array_key_exists($key, $this->properties)) { + return $this->properties[$key]; + } else { + return null; + } + } - /** - * @ignore - */ - public function __set($key, $value) { - $this->properties[$key] = $value; - } + /** + * @ignore + */ + public function __set($key, $value) { + $this->properties[$key] = $value; + } - /** - * Updates the object's properties with the values in the specified map. - * @param $hash array Map of values to set. - */ - public function setAll($hash) { - foreach ($hash as $key => $value) { - $this->$key = $value; - } - } + /** + * Updates the object's properties with the values in the specified map. + * @param $hash array Map of values to set. + */ + public function setAll($hash) { + foreach ($hash as $key => $value) { + $this->$key = $value; + } + } - /** - * @ignore - */ - public function __toString() { - return json_encode($this->properties); - } + /** + * @ignore + */ + public function __toString() { + return json_encode($this->properties); + } - /** - * Returns the object's properties as a map. - * @return array map of properties. - */ - public function getProperties() { - return $this->properties; - } -} \ No newline at end of file + /** + * Returns the object's properties as a map. + * @return array map of properties. + */ + public function getProperties() { + return $this->properties; + } +} diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Payment.php b/includes/gateways/simplify-commerce/includes/Simplify/Payment.php index 04f93fb72ab..3b7c9e0950f 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Payment.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Payment.php @@ -2,140 +2,140 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ class Simplify_Payment extends Simplify_Object { - /** - * Creates an Simplify_Payment object - * @param array $hash a map of parameters; valid keys are:
- *
amount
Amount of the payment (in the smallest unit of your currency). Example: 100 = $1.00USD
- *
authorization
The ID of the authorization being used to capture the payment.
- *
card.addressCity
City of the cardholder. [max length: 50, min length: 2]
- *
card.addressCountry
Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2]
- *
card.addressLine1
Address of the cardholder. [max length: 255]
- *
card.addressLine2
Address of the cardholder if needed. [max length: 255]
- *
card.addressState
State of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, min length: 2]
- *
card.addressZip
Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. [max length: 9, min length: 3]
- *
card.cvc
CVC security code of the card. This is the code on the back of the card. Example: 123
- *
card.expMonth
Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] required
- *
card.expYear
Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] required
- *
card.name
Name as it appears on the card. [max length: 50, min length: 2]
- *
card.number
Card number as it appears on the card. [max length: 19, min length: 13] required
- *
currency
Currency code (ISO-4217) for the transaction. Must match the currency associated with your account. [default: USD] required
- *
customer
ID of customer. If specified, card on file of customer will be used.
- *
description
Free form text field to be used as a description of the payment. This field is echoed back with the payment on any find or list operations. [max length: 1024]
- *
invoice
ID of invoice for which this payment is being made.
- *
reference
Custom reference field to be used with outside systems.
- *
replayId
An identifier that can be sent to uniquely identify a payment request to facilitate retries due to I/O related issues. This identifier must be unique for your account (sandbox or live) across all of your payments. If supplied, we will check for a payment on your account that matches this identifier. If found will attempt to return an identical response of the original request. [max length: 50, min length: 1]
- *
statementDescription.name
Merchant name. required
- *
statementDescription.phoneNumber
Merchant contact phone number.
- *
token
If specified, card associated with card token will be used. [max length: 255]
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Payment a Payment object. - */ - static public function createPayment($hash, $authentication = null) { + /** + * Creates an Simplify_Payment object + * @param array $hash a map of parameters; valid keys are:
+ *
amount
Amount of the payment (in the smallest unit of your currency). Example: 100 = $1.00USD
+ *
authorization
The ID of the authorization being used to capture the payment.
+ *
card.addressCity
City of the cardholder. [max length: 50, min length: 2]
+ *
card.addressCountry
Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2]
+ *
card.addressLine1
Address of the cardholder. [max length: 255]
+ *
card.addressLine2
Address of the cardholder if needed. [max length: 255]
+ *
card.addressState
State of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, min length: 2]
+ *
card.addressZip
Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. [max length: 9, min length: 3]
+ *
card.cvc
CVC security code of the card. This is the code on the back of the card. Example: 123
+ *
card.expMonth
Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] required
+ *
card.expYear
Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] required
+ *
card.name
Name as it appears on the card. [max length: 50, min length: 2]
+ *
card.number
Card number as it appears on the card. [max length: 19, min length: 13] required
+ *
currency
Currency code (ISO-4217) for the transaction. Must match the currency associated with your account. [default: USD] required
+ *
customer
ID of customer. If specified, card on file of customer will be used.
+ *
description
Free form text field to be used as a description of the payment. This field is echoed back with the payment on any find or list operations. [max length: 1024]
+ *
invoice
ID of invoice for which this payment is being made.
+ *
reference
Custom reference field to be used with outside systems.
+ *
replayId
An identifier that can be sent to uniquely identify a payment request to facilitate retries due to I/O related issues. This identifier must be unique for your account (sandbox or live) across all of your payments. If supplied, we will check for a payment on your account that matches this identifier. If found will attempt to return an identical response of the original request. [max length: 50, min length: 1]
+ *
statementDescription.name
Merchant name. required
+ *
statementDescription.phoneNumber
Merchant contact phone number.
+ *
token
If specified, card associated with card token will be used. [max length: 255]
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Payment a Payment object. + */ + static public function createPayment($hash, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $instance = new Simplify_Payment(); - $instance->setAll($hash); + $instance = new Simplify_Payment(); + $instance->setAll($hash); - $object = Simplify_PaymentsApi::createObject($instance, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } - /** - * Retrieve Simplify_Payment objects. - * @param array criteria a map of parameters; valid keys are:
- *
filter
Filters to apply to the list.
- *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
- *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
- *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated createdBy amount id description paymentDate.
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Payment objects and the total - * number of Payment objects available for the given criteria. - * @see ResourceList - */ - static public function listPayment($criteria = null, $authentication = null) { + /** + * Retrieve Simplify_Payment objects. + * @param array criteria a map of parameters; valid keys are:
+ *
filter
Filters to apply to the list.
+ *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
+ *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
+ *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated createdBy amount id description paymentDate.
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Payment objects and the total + * number of Payment objects available for the given criteria. + * @see ResourceList + */ + static public function listPayment($criteria = null, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Payment(); - $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + $val = new Simplify_Payment(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); - return $list; - } + return $list; + } - /** - * Retrieve a Simplify_Payment object from the API - * - * @param string id the id of the Payment object to retrieve - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Payment a Payment object - */ - static public function findPayment($id, $authentication = null) { + /** + * Retrieve a Simplify_Payment object from the API + * + * @param string id the id of the Payment object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Payment a Payment object + */ + static public function findPayment($id, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Payment(); - $val->id = $id; + $val = new Simplify_Payment(); + $val->id = $id; - $obj = Simplify_PaymentsApi::findObject($val, $authentication); + $obj = Simplify_PaymentsApi::findObject($val, $authentication); - return $obj; - } + return $obj; + } - /** - * Updates an Simplify_Payment object. - * - * The properties that can be updated: - *
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Payment a Payment object. - */ - public function updatePayment($authentication = null) { + /** + * Updates an Simplify_Payment object. + * + * The properties that can be updated: + *
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Payment a Payment object. + */ + public function updatePayment($authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); - $object = Simplify_PaymentsApi::updateObject($this, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::updateObject($this, $authentication); + return $object; + } - /** - * @ignore - */ - public function getClazz() { - return "Payment"; - } -} \ No newline at end of file + /** + * @ignore + */ + public function getClazz() { + return "Payment"; + } +} diff --git a/includes/gateways/simplify-commerce/includes/Simplify/PaymentsApi.php b/includes/gateways/simplify-commerce/includes/Simplify/PaymentsApi.php index f318f70030d..4f51193b610 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/PaymentsApi.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/PaymentsApi.php @@ -2,27 +2,27 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ @@ -30,261 +30,261 @@ class Simplify_PaymentsApi { - /** - * @ignore - */ - public static $methodMap = array( - 'create' => 'POST', - 'delete' => 'DELETE', - 'list' => 'GET', - 'show' => 'GET', - 'update' => 'PUT' - ); + /** + * @ignore + */ + public static $methodMap = array( + 'create' => 'POST', + 'delete' => 'DELETE', + 'list' => 'GET', + 'show' => 'GET', + 'update' => 'PUT' + ); - /** - * @ignore - */ - static public function createObject($object, $authentication = null) - { - $paymentsApi = new Simplify_PaymentsApi(); + /** + * @ignore + */ + static public function createObject($object, $authentication = null) + { + $paymentsApi = new Simplify_PaymentsApi(); - $jsonObject = $paymentsApi->execute("create", $object, $authentication); + $jsonObject = $paymentsApi->execute("create", $object, $authentication); - $o = $paymentsApi->convertFromHashToObject($jsonObject, $object->getClazz()); + $o = $paymentsApi->convertFromHashToObject($jsonObject, $object->getClazz()); - return $o; - } + return $o; + } - /** - * @ignore - */ - static public function findObject($object, $authentication = null) - { - $paymentsApi = new Simplify_PaymentsApi(); + /** + * @ignore + */ + static public function findObject($object, $authentication = null) + { + $paymentsApi = new Simplify_PaymentsApi(); - $jsonObject = $paymentsApi->execute("show", $object, $authentication); - $o = $paymentsApi->convertFromHashToObject($jsonObject, $object->getClazz()); + $jsonObject = $paymentsApi->execute("show", $object, $authentication); + $o = $paymentsApi->convertFromHashToObject($jsonObject, $object->getClazz()); - return $o; - } + return $o; + } - /** - * @ignore - */ - static public function updateObject($object, $authentication = null) { - $paymentsApi = new Simplify_PaymentsApi(); + /** + * @ignore + */ + static public function updateObject($object, $authentication = null) { + $paymentsApi = new Simplify_PaymentsApi(); - $jsonObject = $paymentsApi->execute("update", $object, $authentication); - $o = $paymentsApi->convertFromHashToObject($jsonObject, $object->getClazz()); + $jsonObject = $paymentsApi->execute("update", $object, $authentication); + $o = $paymentsApi->convertFromHashToObject($jsonObject, $object->getClazz()); - return $o; - } + return $o; + } - /** - * @ignore - */ - static public function deleteObject($object, $authentication = null) { - $paymentsApi = new Simplify_PaymentsApi(); + /** + * @ignore + */ + static public function deleteObject($object, $authentication = null) { + $paymentsApi = new Simplify_PaymentsApi(); - $jsonObject = $paymentsApi->execute("delete", $object, $authentication); + $jsonObject = $paymentsApi->execute("delete", $object, $authentication); - return $jsonObject; - } + return $jsonObject; + } - /** - * @ignore - */ - static public function listObject($object, $criteria = null, $authentication =null) { - if ($criteria != null) { - if (isset($criteria['max'])) { - $object->max = $criteria['max']; - } - if (isset($criteria['offset'])) { - $object->offset = $criteria['offset']; - } - if (isset($criteria['sorting'])) { - $object->sorting = $criteria['sorting']; - } - if (isset($criteria['filter'])) { - $object->filter = $criteria['filter']; - } - } + /** + * @ignore + */ + static public function listObject($object, $criteria = null, $authentication =null) { + if ($criteria != null) { + if (isset($criteria['max'])) { + $object->max = $criteria['max']; + } + if (isset($criteria['offset'])) { + $object->offset = $criteria['offset']; + } + if (isset($criteria['sorting'])) { + $object->sorting = $criteria['sorting']; + } + if (isset($criteria['filter'])) { + $object->filter = $criteria['filter']; + } + } - $paymentsApi = new Simplify_PaymentsApi(); - $jsonObject = $paymentsApi->execute("list", $object, $authentication); + $paymentsApi = new Simplify_PaymentsApi(); + $jsonObject = $paymentsApi->execute("list", $object, $authentication); - $ret = new Simplify_ResourceList(); - if (array_key_exists('list', $jsonObject) & is_array($jsonObject['list'])) { - foreach ($jsonObject['list'] as $obj) { - array_push($ret->list, $paymentsApi->convertFromHashToObject($obj, $object->getClazz())); - } - $ret->total = $jsonObject['total']; - } + $ret = new Simplify_ResourceList(); + if (array_key_exists('list', $jsonObject) & is_array($jsonObject['list'])) { + foreach ($jsonObject['list'] as $obj) { + array_push($ret->list, $paymentsApi->convertFromHashToObject($obj, $object->getClazz())); + } + $ret->total = $jsonObject['total']; + } - return $ret; - } + return $ret; + } - /** - * @ignore - */ - public function convertFromHashToObject($from, $toClazz) - { - $clazz = 'stdClass'; - $toClazz = "Simplify_" . $toClazz; - if ("stdClass" != $toClazz && class_exists("{$toClazz}", false)) { - $clazz = "{$toClazz}"; - } - $object = new $clazz(); + /** + * @ignore + */ + public function convertFromHashToObject($from, $toClazz) + { + $clazz = 'stdClass'; + $toClazz = "Simplify_" . $toClazz; + if ("stdClass" != $toClazz && class_exists("{$toClazz}", false)) { + $clazz = "{$toClazz}"; + } + $object = new $clazz(); - foreach ($from as $key => $value) { - if (is_array($value) && count(array_keys($value))) { - $newClazz = "Simplify_" . ucfirst($key); - if (!class_exists($newClazz, false)) { - $newClazz = 'stdClass'; - } + foreach ($from as $key => $value) { + if (is_array($value) && count(array_keys($value))) { + $newClazz = "Simplify_" . ucfirst($key); + if (!class_exists($newClazz, false)) { + $newClazz = 'stdClass'; + } - $object->$key = $this->convertFromHashToObject($value, $newClazz); - } else { - $object->$key = $value; - } - } + $object->$key = $this->convertFromHashToObject($value, $newClazz); + } else { + $object->$key = $value; + } + } - return $object; - } + return $object; + } - /** - * @ignore - */ - public function getUrl($publicKey, $action, $object) - { - $url = $this->fixUrl(Simplify::$apiBaseSandboxUrl); - if ($this->isLiveKey($publicKey)) { - $url = $this->fixUrl(Simplify::$apiBaseLiveUrl); - } - $url = $this->fixUrl($url) . urlencode(lcfirst($object->getClazz())) . '/'; + /** + * @ignore + */ + public function getUrl($publicKey, $action, $object) + { + $url = $this->fixUrl(Simplify::$apiBaseSandboxUrl); + if ($this->isLiveKey($publicKey)) { + $url = $this->fixUrl(Simplify::$apiBaseLiveUrl); + } + $url = $this->fixUrl($url) . urlencode(lcfirst($object->getClazz())) . '/'; - $queryParams = array(); - if ($action == "show") { - $url .= urlencode($object->id); - } elseif ($action == "list") { - $queryParams = array_merge($queryParams, array('max' => $object->max, 'offset' => $object->offset)); - if (is_array($object->filter) && count(array_keys($object->filter))) { - foreach ($object->filter as $key => $value) { - $queryParams["filter[$key]"] = $value; - } - } - if (is_array($object->sorting) && count(array_keys($object->sorting))) { - foreach ($object->sorting as $key => $value) { - $queryParams["sorting[$key]"] = $value; - } - } - $query = http_build_query($queryParams); - if ($query != '') { - if (strpos($url, '?', strlen($url)) === false) $url .= '?'; - $url .= $query; - } + $queryParams = array(); + if ($action == "show") { + $url .= urlencode($object->id); + } elseif ($action == "list") { + $queryParams = array_merge($queryParams, array('max' => $object->max, 'offset' => $object->offset)); + if (is_array($object->filter) && count(array_keys($object->filter))) { + foreach ($object->filter as $key => $value) { + $queryParams["filter[$key]"] = $value; + } + } + if (is_array($object->sorting) && count(array_keys($object->sorting))) { + foreach ($object->sorting as $key => $value) { + $queryParams["sorting[$key]"] = $value; + } + } + $query = http_build_query($queryParams); + if ($query != '') { + if (strpos($url, '?', strlen($url)) === false) $url .= '?'; + $url .= $query; + } - } elseif ($action == "delete") { - $url .= urlencode($object->id); - } elseif ($action == "update") { - $url .= urlencode($object->id); - } elseif ($action == "create") { - } - return $url; - } + } elseif ($action == "delete") { + $url .= urlencode($object->id); + } elseif ($action == "update") { + $url .= urlencode($object->id); + } elseif ($action == "create") { + } + return $url; + } - /** - * @ignore - */ - public function getMethod($action) - { - if (array_key_exists(strtolower($action), self::$methodMap)) { - return self::$methodMap[strtolower($action)]; - } - return 'GET'; - } + /** + * @ignore + */ + public function getMethod($action) + { + if (array_key_exists(strtolower($action), self::$methodMap)) { + return self::$methodMap[strtolower($action)]; + } + return 'GET'; + } - /** - * @ignore - */ - private function execute($action, $object, $authentication) - { - $http = new Simplify_HTTP(); + /** + * @ignore + */ + private function execute($action, $object, $authentication) + { + $http = new Simplify_HTTP(); - return $http->apiRequest($this->getUrl($authentication->publicKey, $action, $object), $this->getMethod($action), - $authentication, json_encode($object->getProperties())); - } + return $http->apiRequest($this->getUrl($authentication->publicKey, $action, $object), $this->getMethod($action), + $authentication, json_encode($object->getProperties())); + } - /** - * @ignore - */ - public function jwsDecode($hash, $authentication) - { - $http = new Simplify_HTTP(); + /** + * @ignore + */ + public function jwsDecode($hash, $authentication) + { + $http = new Simplify_HTTP(); - $data = $http->jwsDecode($authentication, $hash); + $data = $http->jwsDecode($authentication, $hash); - return json_decode($data, true); - } + return json_decode($data, true); + } - /** - * @ignore - */ - private function fixUrl($url) - { - if ($this->endsWith($url, '/')) { - return $url; - } - return $url . '/'; - } + /** + * @ignore + */ + private function fixUrl($url) + { + if ($this->endsWith($url, '/')) { + return $url; + } + return $url . '/'; + } - /** - * @ignore - */ - private function isLiveKey($k) { - return strpos($k, "lvpb") === 0; - } + /** + * @ignore + */ + private function isLiveKey($k) { + return strpos($k, "lvpb") === 0; + } - /** - * @ignore - */ - private function endsWith($s, $c) - { - return substr($s, -strlen($c)) == $c; - } + /** + * @ignore + */ + private function endsWith($s, $c) + { + return substr($s, -strlen($c)) == $c; + } - /** - * Helper function to build the Authentication object for backwards compatibility. - * An array of all the arguments passed to one of the API functions is checked against what - * we expect to received. If it's greater, then we're assuming that the user is using the older way of - * passing the keys. i.e as two separate strings. We take those two string and create the Authentication object - * - * @ignore - * @param $authentication - * @param $args - * @param $expectedArgCount - * @return Simplify_Authentication - */ - static function buildAuthenticationObject($authentication = null, $args, $expectedArgCount){ + /** + * Helper function to build the Authentication object for backwards compatibility. + * An array of all the arguments passed to one of the API functions is checked against what + * we expect to received. If it's greater, then we're assuming that the user is using the older way of + * passing the keys. i.e as two separate strings. We take those two string and create the Authentication object + * + * @ignore + * @param $authentication + * @param $args + * @param $expectedArgCount + * @return Simplify_Authentication + */ + static function buildAuthenticationObject($authentication = null, $args, $expectedArgCount){ - if(sizeof($args) > $expectedArgCount) { - $authentication = new Simplify_Authentication($args[$expectedArgCount-1], $args[$expectedArgCount]); - } + if(sizeof($args) > $expectedArgCount) { + $authentication = new Simplify_Authentication($args[$expectedArgCount-1], $args[$expectedArgCount]); + } - if ($authentication == null){ - $authentication = new Simplify_Authentication(); - } + if ($authentication == null){ + $authentication = new Simplify_Authentication(); + } - // check that the keys have been set, if not use the global keys - if ( empty($authentication->publicKey)){ - $authentication->publicKey = Simplify::$publicKey; - } - if ( empty($authentication->privateKey)){ - $authentication->privateKey = Simplify::$privateKey; - } + // check that the keys have been set, if not use the global keys + if ( empty($authentication->publicKey)){ + $authentication->publicKey = Simplify::$publicKey; + } + if ( empty($authentication->privateKey)){ + $authentication->privateKey = Simplify::$privateKey; + } - return $authentication; - } + return $authentication; + } } diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Plan.php b/includes/gateways/simplify-commerce/includes/Simplify/Plan.php index 90d492d6a1d..d5a09564589 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Plan.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Plan.php @@ -2,146 +2,146 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ class Simplify_Plan extends Simplify_Object { - /** - * Creates an Simplify_Plan object - * @param array $hash a map of parameters; valid keys are:
- *
amount
Amount of payment for the plan in the smallest unit of your currency. Example: 100 = $1.00USD required
- *
billingCycle
How the plan is billed to the customer. Values must be AUTO (indefinitely until the customer cancels) or FIXED (a fixed number of billing cycles). [default: AUTO]
- *
billingCycleLimit
The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4
- *
currency
Currency code (ISO-4217) for the plan. Must match the currency associated with your account. [default: USD] required
- *
frequency
Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY". [default: MONTHLY] required
- *
frequencyPeriod
Period of frequency of payment for the plan. Example: if the frequency is weekly, and periodFrequency is 2, then the subscription is billed bi-weekly. [min value: 1, default: 1] required
- *
name
Name of the plan [max length: 50, min length: 2] required
- *
renewalReminderLeadDays
If set, how many days before the next billing cycle that a renewal reminder is sent to the customer. If null, then no emails are sent. Minimum value is 7 if set.
- *
trialPeriod
Plan free trial period selection. Must be Days, Weeks, or Month [default: NONE] required
- *
trialPeriodQuantity
Quantity of the trial period. Must be greater than 0 and a whole number. [min value: 1]
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Plan a Plan object. - */ - static public function createPlan($hash, $authentication = null) { + /** + * Creates an Simplify_Plan object + * @param array $hash a map of parameters; valid keys are:
+ *
amount
Amount of payment for the plan in the smallest unit of your currency. Example: 100 = $1.00USD required
+ *
billingCycle
How the plan is billed to the customer. Values must be AUTO (indefinitely until the customer cancels) or FIXED (a fixed number of billing cycles). [default: AUTO]
+ *
billingCycleLimit
The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4
+ *
currency
Currency code (ISO-4217) for the plan. Must match the currency associated with your account. [default: USD] required
+ *
frequency
Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY". [default: MONTHLY] required
+ *
frequencyPeriod
Period of frequency of payment for the plan. Example: if the frequency is weekly, and periodFrequency is 2, then the subscription is billed bi-weekly. [min value: 1, default: 1] required
+ *
name
Name of the plan [max length: 50, min length: 2] required
+ *
renewalReminderLeadDays
If set, how many days before the next billing cycle that a renewal reminder is sent to the customer. If null, then no emails are sent. Minimum value is 7 if set.
+ *
trialPeriod
Plan free trial period selection. Must be Days, Weeks, or Month [default: NONE] required
+ *
trialPeriodQuantity
Quantity of the trial period. Must be greater than 0 and a whole number. [min value: 1]
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Plan a Plan object. + */ + static public function createPlan($hash, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $instance = new Simplify_Plan(); - $instance->setAll($hash); + $instance = new Simplify_Plan(); + $instance->setAll($hash); - $object = Simplify_PaymentsApi::createObject($instance, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } - /** - * Deletes an Simplify_Plan object. - * - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - */ - public function deletePlan($authentication = null) { + /** + * Deletes an Simplify_Plan object. + * + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + */ + public function deletePlan($authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); - $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); - $this->properties = null; - return true; - } + $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); + $this->properties = null; + return true; + } - /** - * Retrieve Simplify_Plan objects. - * @param array criteria a map of parameters; valid keys are:
- *
filter
Filters to apply to the list.
- *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
- *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
- *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated amount frequency name id.
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Plan objects and the total - * number of Plan objects available for the given criteria. - * @see ResourceList - */ - static public function listPlan($criteria = null, $authentication = null) { + /** + * Retrieve Simplify_Plan objects. + * @param array criteria a map of parameters; valid keys are:
+ *
filter
Filters to apply to the list.
+ *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
+ *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
+ *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated amount frequency name id.
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Plan objects and the total + * number of Plan objects available for the given criteria. + * @see ResourceList + */ + static public function listPlan($criteria = null, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Plan(); - $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + $val = new Simplify_Plan(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); - return $list; - } + return $list; + } - /** - * Retrieve a Simplify_Plan object from the API - * - * @param string id the id of the Plan object to retrieve - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Plan a Plan object - */ - static public function findPlan($id, $authentication = null) { + /** + * Retrieve a Simplify_Plan object from the API + * + * @param string id the id of the Plan object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Plan a Plan object + */ + static public function findPlan($id, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Plan(); - $val->id = $id; + $val = new Simplify_Plan(); + $val->id = $id; - $obj = Simplify_PaymentsApi::findObject($val, $authentication); + $obj = Simplify_PaymentsApi::findObject($val, $authentication); - return $obj; - } + return $obj; + } - /** - * Updates an Simplify_Plan object. - * - * The properties that can be updated: - *
- *
name
Name of the plan. [min length: 2] required
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Plan a Plan object. - */ - public function updatePlan($authentication = null) { + /** + * Updates an Simplify_Plan object. + * + * The properties that can be updated: + *
+ *
name
Name of the plan. [min length: 2] required
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Plan a Plan object. + */ + public function updatePlan($authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); - $object = Simplify_PaymentsApi::updateObject($this, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::updateObject($this, $authentication); + return $object; + } - /** - * @ignore - */ - public function getClazz() { - return "Plan"; - } -} \ No newline at end of file + /** + * @ignore + */ + public function getClazz() { + return "Plan"; + } +} diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Refund.php b/includes/gateways/simplify-commerce/includes/Simplify/Refund.php index 2c2ccd8eead..ae2e55a8b04 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Refund.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Refund.php @@ -2,107 +2,107 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ class Simplify_Refund extends Simplify_Object { - /** - * Creates an Simplify_Refund object - * @param array $hash a map of parameters; valid keys are:
- *
amount
Amount of the refund in the smallest unit of your currency. Example: 100 = $1.00USD [min value: 1] required
- *
payment
ID of the payment for the refund required
- *
reason
Reason for the refund
- *
reference
Custom reference field to be used with outside systems.
- *
replayId
An identifier that can be sent to uniquely identify a refund request to facilitate retries due to I/O related issues. This identifier must be unique for your account (sandbox or live) across all of your refunds. If supplied, we will check for a refund on your account that matches this identifier. If found we will return an identical response to that of the original request. [max length: 50, min length: 1]
- *
statementDescription.name
Merchant name. required
- *
statementDescription.phoneNumber
Merchant contact phone number.
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Refund a Refund object. - */ - static public function createRefund($hash, $authentication = null) { + /** + * Creates an Simplify_Refund object + * @param array $hash a map of parameters; valid keys are:
+ *
amount
Amount of the refund in the smallest unit of your currency. Example: 100 = $1.00USD [min value: 1] required
+ *
payment
ID of the payment for the refund required
+ *
reason
Reason for the refund
+ *
reference
Custom reference field to be used with outside systems.
+ *
replayId
An identifier that can be sent to uniquely identify a refund request to facilitate retries due to I/O related issues. This identifier must be unique for your account (sandbox or live) across all of your refunds. If supplied, we will check for a refund on your account that matches this identifier. If found we will return an identical response to that of the original request. [max length: 50, min length: 1]
+ *
statementDescription.name
Merchant name. required
+ *
statementDescription.phoneNumber
Merchant contact phone number.
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Refund a Refund object. + */ + static public function createRefund($hash, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $instance = new Simplify_Refund(); - $instance->setAll($hash); + $instance = new Simplify_Refund(); + $instance->setAll($hash); - $object = Simplify_PaymentsApi::createObject($instance, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } - /** - * Retrieve Simplify_Refund objects. - * @param array criteria a map of parameters; valid keys are:
- *
filter
Filters to apply to the list.
- *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
- *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
- *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: id amount description dateCreated paymentDate.
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Refund objects and the total - * number of Refund objects available for the given criteria. - * @see ResourceList - */ - static public function listRefund($criteria = null, $authentication = null) { + /** + * Retrieve Simplify_Refund objects. + * @param array criteria a map of parameters; valid keys are:
+ *
filter
Filters to apply to the list.
+ *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
+ *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
+ *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: id amount description dateCreated paymentDate.
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Refund objects and the total + * number of Refund objects available for the given criteria. + * @see ResourceList + */ + static public function listRefund($criteria = null, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Refund(); - $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + $val = new Simplify_Refund(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); - return $list; - } + return $list; + } - /** - * Retrieve a Simplify_Refund object from the API - * - * @param string id the id of the Refund object to retrieve - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Refund a Refund object - */ - static public function findRefund($id, $authentication = null) { + /** + * Retrieve a Simplify_Refund object from the API + * + * @param string id the id of the Refund object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Refund a Refund object + */ + static public function findRefund($id, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Refund(); - $val->id = $id; + $val = new Simplify_Refund(); + $val->id = $id; - $obj = Simplify_PaymentsApi::findObject($val, $authentication); + $obj = Simplify_PaymentsApi::findObject($val, $authentication); - return $obj; - } + return $obj; + } - /** - * @ignore - */ - public function getClazz() { - return "Refund"; - } -} \ No newline at end of file + /** + * @ignore + */ + public function getClazz() { + return "Refund"; + } +} diff --git a/includes/gateways/simplify-commerce/includes/Simplify/ResourceList.php b/includes/gateways/simplify-commerce/includes/Simplify/ResourceList.php index c34b8db78c1..5297c79e392 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/ResourceList.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/ResourceList.php @@ -2,27 +2,27 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ @@ -32,13 +32,13 @@ */ class Simplify_ResourceList { - /** - * @var array $list the list of domain objects. - */ - public $list = array(); + /** + * @var array $list the list of domain objects. + */ + public $list = array(); - /** - * @var int $total the total number of object available. - */ - public $total = 0; -} \ No newline at end of file + /** + * @var int $total the total number of object available. + */ + public $total = 0; +} diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Subscription.php b/includes/gateways/simplify-commerce/includes/Simplify/Subscription.php index 514a931b416..e72573824b2 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Subscription.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Subscription.php @@ -2,159 +2,159 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ class Simplify_Subscription extends Simplify_Object { - /** - * Creates an Simplify_Subscription object - * @param array $hash a map of parameters; valid keys are:
- *
amount
Amount of the payment in the smallest unit of your currency. Example: 100 = $1.00USD
- *
billingCycle
How the plan is billed to the customer. Values must be AUTO (indefinitely until the customer cancels) or FIXED (a fixed number of billing cycles). [default: AUTO]
- *
billingCycleLimit
The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4
- *
coupon
Coupon ID associated with the subscription
- *
currency
Currency code (ISO-4217). Must match the currency associated with your account. [default: USD]
- *
customer
Customer that is enrolling in the subscription.
- *
frequency
Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY".
- *
frequencyPeriod
Period of frequency of payment for the plan. Example: if the frequency is weekly, and periodFrequency is 2, then the subscription is billed bi-weekly.
- *
name
Name describing subscription
- *
plan
The ID of the plan that should be used for the subscription.
- *
quantity
Quantity of the plan for the subscription. [min value: 1]
- *
renewalReminderLeadDays
If set, how many days before the next billing cycle that a renewal reminder is sent to the customer. If null, then no emails are sent. Minimum value is 7 if set.
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Subscription a Subscription object. - */ - static public function createSubscription($hash, $authentication = null) { + /** + * Creates an Simplify_Subscription object + * @param array $hash a map of parameters; valid keys are:
+ *
amount
Amount of the payment in the smallest unit of your currency. Example: 100 = $1.00USD
+ *
billingCycle
How the plan is billed to the customer. Values must be AUTO (indefinitely until the customer cancels) or FIXED (a fixed number of billing cycles). [default: AUTO]
+ *
billingCycleLimit
The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4
+ *
coupon
Coupon ID associated with the subscription
+ *
currency
Currency code (ISO-4217). Must match the currency associated with your account. [default: USD]
+ *
customer
Customer that is enrolling in the subscription.
+ *
frequency
Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY".
+ *
frequencyPeriod
Period of frequency of payment for the plan. Example: if the frequency is weekly, and periodFrequency is 2, then the subscription is billed bi-weekly.
+ *
name
Name describing subscription
+ *
plan
The ID of the plan that should be used for the subscription.
+ *
quantity
Quantity of the plan for the subscription. [min value: 1]
+ *
renewalReminderLeadDays
If set, how many days before the next billing cycle that a renewal reminder is sent to the customer. If null, then no emails are sent. Minimum value is 7 if set.
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Subscription a Subscription object. + */ + static public function createSubscription($hash, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $instance = new Simplify_Subscription(); - $instance->setAll($hash); + $instance = new Simplify_Subscription(); + $instance->setAll($hash); - $object = Simplify_PaymentsApi::createObject($instance, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } - /** - * Deletes an Simplify_Subscription object. - * - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - */ - public function deleteSubscription($authentication = null) { + /** + * Deletes an Simplify_Subscription object. + * + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + */ + public function deleteSubscription($authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); - $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); - $this->properties = null; - return true; - } + $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); + $this->properties = null; + return true; + } - /** - * Retrieve Simplify_Subscription objects. - * @param array criteria a map of parameters; valid keys are:
- *
filter
Filters to apply to the list.
- *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
- *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
- *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: id plan.
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Subscription objects and the total - * number of Subscription objects available for the given criteria. - * @see ResourceList - */ - static public function listSubscription($criteria = null, $authentication = null) { + /** + * Retrieve Simplify_Subscription objects. + * @param array criteria a map of parameters; valid keys are:
+ *
filter
Filters to apply to the list.
+ *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
+ *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
+ *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: id plan.
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Subscription objects and the total + * number of Subscription objects available for the given criteria. + * @see ResourceList + */ + static public function listSubscription($criteria = null, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Subscription(); - $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + $val = new Simplify_Subscription(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); - return $list; - } + return $list; + } - /** - * Retrieve a Simplify_Subscription object from the API - * - * @param string id the id of the Subscription object to retrieve - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Subscription a Subscription object - */ - static public function findSubscription($id, $authentication = null) { + /** + * Retrieve a Simplify_Subscription object from the API + * + * @param string id the id of the Subscription object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Subscription a Subscription object + */ + static public function findSubscription($id, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Subscription(); - $val->id = $id; + $val = new Simplify_Subscription(); + $val->id = $id; - $obj = Simplify_PaymentsApi::findObject($val, $authentication); + $obj = Simplify_PaymentsApi::findObject($val, $authentication); - return $obj; - } + return $obj; + } - /** - * Updates an Simplify_Subscription object. - * - * The properties that can be updated: - *
- *
amount
Amount of the payment in the smallest unit of your currency. Example: 100 = $1.00USD
- *
billingCycle
How the plan is billed to the customer. Values must be AUTO (indefinitely until the customer cancels) or FIXED (a fixed number of billing cycles). [default: AUTO]
- *
billingCycleLimit
The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4
- *
coupon
Coupon being assigned to this subscription
- *
currency
Currency code (ISO-4217). Must match the currency associated with your account. [default: USD]
- *
frequency
Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY".
- *
frequencyPeriod
Period of frequency of payment for the plan. Example: if the frequency is weekly, and periodFrequency is 2, then the subscription is billed bi-weekly. [min value: 1]
- *
name
Name describing subscription
- *
plan
Plan that should be used for the subscription.
- *
prorate
Whether to prorate existing subscription. [default: true] required
- *
quantity
Quantity of the plan for the subscription. [min value: 1]
- *
renewalReminderLeadDays
If set, how many days before the next billing cycle that a renewal reminder is sent to the customer. If null or 0, no emails are sent. Minimum value is 7 if set.
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Subscription a Subscription object. - */ - public function updateSubscription($authentication = null) { + /** + * Updates an Simplify_Subscription object. + * + * The properties that can be updated: + *
+ *
amount
Amount of the payment in the smallest unit of your currency. Example: 100 = $1.00USD
+ *
billingCycle
How the plan is billed to the customer. Values must be AUTO (indefinitely until the customer cancels) or FIXED (a fixed number of billing cycles). [default: AUTO]
+ *
billingCycleLimit
The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4
+ *
coupon
Coupon being assigned to this subscription
+ *
currency
Currency code (ISO-4217). Must match the currency associated with your account. [default: USD]
+ *
frequency
Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY".
+ *
frequencyPeriod
Period of frequency of payment for the plan. Example: if the frequency is weekly, and periodFrequency is 2, then the subscription is billed bi-weekly. [min value: 1]
+ *
name
Name describing subscription
+ *
plan
Plan that should be used for the subscription.
+ *
prorate
Whether to prorate existing subscription. [default: true] required
+ *
quantity
Quantity of the plan for the subscription. [min value: 1]
+ *
renewalReminderLeadDays
If set, how many days before the next billing cycle that a renewal reminder is sent to the customer. If null or 0, no emails are sent. Minimum value is 7 if set.
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Subscription a Subscription object. + */ + public function updateSubscription($authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); - $object = Simplify_PaymentsApi::updateObject($this, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::updateObject($this, $authentication); + return $object; + } - /** - * @ignore - */ - public function getClazz() { - return "Subscription"; - } -} \ No newline at end of file + /** + * @ignore + */ + public function getClazz() { + return "Subscription"; + } +} diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Tax.php b/includes/gateways/simplify-commerce/includes/Simplify/Tax.php index 9edbfadb5c1..b3a05fa1344 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Tax.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Tax.php @@ -2,119 +2,119 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ class Simplify_Tax extends Simplify_Object { - /** - * Creates an Simplify_Tax object - * @param array $hash a map of parameters; valid keys are:
- *
label
The label of the tax object. [max length: 255] required
- *
rate
The tax rate. Decimal value up three decimal places. e.g 12.501. [max length: 6] required
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Tax a Tax object. - */ - static public function createTax($hash, $authentication = null) { + /** + * Creates an Simplify_Tax object + * @param array $hash a map of parameters; valid keys are:
+ *
label
The label of the tax object. [max length: 255] required
+ *
rate
The tax rate. Decimal value up three decimal places. e.g 12.501. [max length: 6] required
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Tax a Tax object. + */ + static public function createTax($hash, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $instance = new Simplify_Tax(); - $instance->setAll($hash); + $instance = new Simplify_Tax(); + $instance->setAll($hash); - $object = Simplify_PaymentsApi::createObject($instance, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } - /** - * Deletes an Simplify_Tax object. - * - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - */ - public function deleteTax($authentication = null) { + /** + * Deletes an Simplify_Tax object. + * + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + */ + public function deleteTax($authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); - $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); - $this->properties = null; - return true; - } + $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); + $this->properties = null; + return true; + } - /** - * Retrieve Simplify_Tax objects. - * @param array criteria a map of parameters; valid keys are:
- *
filter
Filters to apply to the list.
- *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
- *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
- *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: id label.
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Tax objects and the total - * number of Tax objects available for the given criteria. - * @see ResourceList - */ - static public function listTax($criteria = null, $authentication = null) { + /** + * Retrieve Simplify_Tax objects. + * @param array criteria a map of parameters; valid keys are:
+ *
filter
Filters to apply to the list.
+ *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
+ *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
+ *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: id label.
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Tax objects and the total + * number of Tax objects available for the given criteria. + * @see ResourceList + */ + static public function listTax($criteria = null, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Tax(); - $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + $val = new Simplify_Tax(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); - return $list; - } + return $list; + } - /** - * Retrieve a Simplify_Tax object from the API - * - * @param string id the id of the Tax object to retrieve - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Tax a Tax object - */ - static public function findTax($id, $authentication = null) { + /** + * Retrieve a Simplify_Tax object from the API + * + * @param string id the id of the Tax object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Tax a Tax object + */ + static public function findTax($id, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Tax(); - $val->id = $id; + $val = new Simplify_Tax(); + $val->id = $id; - $obj = Simplify_PaymentsApi::findObject($val, $authentication); + $obj = Simplify_PaymentsApi::findObject($val, $authentication); - return $obj; - } + return $obj; + } - /** - * @ignore - */ - public function getClazz() { - return "Tax"; - } -} \ No newline at end of file + /** + * @ignore + */ + public function getClazz() { + return "Tax"; + } +} diff --git a/includes/gateways/simplify-commerce/includes/Simplify/TransactionReview.php b/includes/gateways/simplify-commerce/includes/Simplify/TransactionReview.php index a438230d9e3..cfea74e4069 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/TransactionReview.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/TransactionReview.php @@ -2,136 +2,136 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ class Simplify_TransactionReview extends Simplify_Object { - /** - * Creates an Simplify_TransactionReview object - * @param array $hash a map of parameters; valid keys are:
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return TransactionReview a TransactionReview object. - */ - static public function createTransactionReview($hash, $authentication = null) { + /** + * Creates an Simplify_TransactionReview object + * @param array $hash a map of parameters; valid keys are:
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return TransactionReview a TransactionReview object. + */ + static public function createTransactionReview($hash, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $instance = new Simplify_TransactionReview(); - $instance->setAll($hash); + $instance = new Simplify_TransactionReview(); + $instance->setAll($hash); - $object = Simplify_PaymentsApi::createObject($instance, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } - /** - * Deletes an Simplify_TransactionReview object. - * - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - */ - public function deleteTransactionReview($authentication = null) { + /** + * Deletes an Simplify_TransactionReview object. + * + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + */ + public function deleteTransactionReview($authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); - $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); - $this->properties = null; - return true; - } + $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); + $this->properties = null; + return true; + } - /** - * Retrieve Simplify_TransactionReview objects. - * @param array criteria a map of parameters; valid keys are:
- *
filter
Allows for ascending or descending sorting of the list.
- *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
- *
offset
Filters to apply to the list. [min value: 0, default: 0]
- *
sorting
Used in paging of the list. This is the start offset of the page. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated status.
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of TransactionReview objects and the total - * number of TransactionReview objects available for the given criteria. - * @see ResourceList - */ - static public function listTransactionReview($criteria = null, $authentication = null) { + /** + * Retrieve Simplify_TransactionReview objects. + * @param array criteria a map of parameters; valid keys are:
+ *
filter
Allows for ascending or descending sorting of the list.
+ *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
+ *
offset
Filters to apply to the list. [min value: 0, default: 0]
+ *
sorting
Used in paging of the list. This is the start offset of the page. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated status.
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of TransactionReview objects and the total + * number of TransactionReview objects available for the given criteria. + * @see ResourceList + */ + static public function listTransactionReview($criteria = null, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_TransactionReview(); - $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + $val = new Simplify_TransactionReview(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); - return $list; - } + return $list; + } - /** - * Retrieve a Simplify_TransactionReview object from the API - * - * @param string id the id of the TransactionReview object to retrieve - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return TransactionReview a TransactionReview object - */ - static public function findTransactionReview($id, $authentication = null) { + /** + * Retrieve a Simplify_TransactionReview object from the API + * + * @param string id the id of the TransactionReview object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return TransactionReview a TransactionReview object + */ + static public function findTransactionReview($id, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_TransactionReview(); - $val->id = $id; + $val = new Simplify_TransactionReview(); + $val->id = $id; - $obj = Simplify_PaymentsApi::findObject($val, $authentication); + $obj = Simplify_PaymentsApi::findObject($val, $authentication); - return $obj; - } + return $obj; + } - /** - * Updates an Simplify_TransactionReview object. - * - * The properties that can be updated: - *
- *
status
Status of the transaction review.
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return TransactionReview a TransactionReview object. - */ - public function updateTransactionReview($authentication = null) { + /** + * Updates an Simplify_TransactionReview object. + * + * The properties that can be updated: + *
+ *
status
Status of the transaction review.
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return TransactionReview a TransactionReview object. + */ + public function updateTransactionReview($authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); - $object = Simplify_PaymentsApi::updateObject($this, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::updateObject($this, $authentication); + return $object; + } - /** - * @ignore - */ - public function getClazz() { - return "TransactionReview"; - } -} \ No newline at end of file + /** + * @ignore + */ + public function getClazz() { + return "TransactionReview"; + } +} diff --git a/includes/gateways/simplify-commerce/includes/Simplify/Webhook.php b/includes/gateways/simplify-commerce/includes/Simplify/Webhook.php index 537c52c1f5a..ab32aa4cfdc 100644 --- a/includes/gateways/simplify-commerce/includes/Simplify/Webhook.php +++ b/includes/gateways/simplify-commerce/includes/Simplify/Webhook.php @@ -2,137 +2,137 @@ /* * Copyright (c) 2013 - 2015 MasterCard International Incorporated * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are + * + * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of + * + * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials + * Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * Neither the name of the MasterCard International Incorporated nor the names of its - * contributors may be used to endorse or promote products derived from this software + * Neither the name of the MasterCard International Incorporated nor the names of its + * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ class Simplify_Webhook extends Simplify_Object { - /** - * Creates an Simplify_Webhook object - * @param array $hash a map of parameters; valid keys are:
- *
url
Endpoint URL required
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Webhook a Webhook object. - */ - static public function createWebhook($hash, $authentication = null) { + /** + * Creates an Simplify_Webhook object + * @param array $hash a map of parameters; valid keys are:
+ *
url
Endpoint URL required
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Webhook a Webhook object. + */ + static public function createWebhook($hash, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $instance = new Simplify_Webhook(); - $instance->setAll($hash); + $instance = new Simplify_Webhook(); + $instance->setAll($hash); - $object = Simplify_PaymentsApi::createObject($instance, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } - /** - * Deletes an Simplify_Webhook object. - * - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - */ - public function deleteWebhook($authentication = null) { + /** + * Deletes an Simplify_Webhook object. + * + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + */ + public function deleteWebhook($authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); - $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); - $this->properties = null; - return true; - } + $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); + $this->properties = null; + return true; + } - /** - * Retrieve Simplify_Webhook objects. - * @param array criteria a map of parameters; valid keys are:
- *
filter
Filters to apply to the list.
- *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
- *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
- *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated.
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return ResourceList a ResourceList object that holds the list of Webhook objects and the total - * number of Webhook objects available for the given criteria. - * @see ResourceList - */ - static public function listWebhook($criteria = null, $authentication = null) { + /** + * Retrieve Simplify_Webhook objects. + * @param array criteria a map of parameters; valid keys are:
+ *
filter
Filters to apply to the list.
+ *
max
Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
+ *
offset
Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
+ *
sorting
Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated.
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Webhook objects and the total + * number of Webhook objects available for the given criteria. + * @see ResourceList + */ + static public function listWebhook($criteria = null, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Webhook(); - $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + $val = new Simplify_Webhook(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); - return $list; - } + return $list; + } - /** - * Retrieve a Simplify_Webhook object from the API - * - * @param string id the id of the Webhook object to retrieve - * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Webhook a Webhook object - */ - static public function findWebhook($id, $authentication = null) { + /** + * Retrieve a Simplify_Webhook object from the API + * + * @param string id the id of the Webhook object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Webhook a Webhook object + */ + static public function findWebhook($id, $authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); - $val = new Simplify_Webhook(); - $val->id = $id; + $val = new Simplify_Webhook(); + $val->id = $id; - $obj = Simplify_PaymentsApi::findObject($val, $authentication); + $obj = Simplify_PaymentsApi::findObject($val, $authentication); - return $obj; - } + return $obj; + } - /** - * Updates an Simplify_Webhook object. - * - * The properties that can be updated: - *
- *
url
Endpoint URL required
- * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. - * @return Webhook a Webhook object. - */ - public function updateWebhook($authentication = null) { + /** + * Updates an Simplify_Webhook object. + * + * The properties that can be updated: + *
+ *
url
Endpoint URL required
+ * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Webhook a Webhook object. + */ + public function updateWebhook($authentication = null) { - $args = func_get_args(); - $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); - $object = Simplify_PaymentsApi::updateObject($this, $authentication); - return $object; - } + $object = Simplify_PaymentsApi::updateObject($this, $authentication); + return $object; + } - /** - * @ignore - */ - public function getClazz() { - return "Webhook"; - } -} \ No newline at end of file + /** + * @ignore + */ + public function getClazz() { + return "Webhook"; + } +} diff --git a/includes/shipping/legacy-local-delivery/class-wc-shipping-legacy-local-delivery.php b/includes/shipping/legacy-local-delivery/class-wc-shipping-legacy-local-delivery.php index f590e7b2135..d6ab06cafe7 100644 --- a/includes/shipping/legacy-local-delivery/class-wc-shipping-legacy-local-delivery.php +++ b/includes/shipping/legacy-local-delivery/class-wc-shipping-legacy-local-delivery.php @@ -37,7 +37,7 @@ class WC_Shipping_Legacy_Local_Delivery extends WC_Shipping_Local_Pickup { exit; } } - + /** * Return the name of the option in the WP DB. * @since 2.6.0 @@ -87,7 +87,7 @@ class WC_Shipping_Legacy_Local_Delivery extends WC_Shipping_Local_Pickup { foreach ( $package['contents'] as $item_id => $values ) { if ( $values['quantity'] > 0 && $values['data']->needs_shipping() ) { $shipping_total += $this->fee * $values['quantity']; - } + } } break; } diff --git a/includes/wc-cart-functions.php b/includes/wc-cart-functions.php index 26f424024c1..83b79c33022 100644 --- a/includes/wc-cart-functions.php +++ b/includes/wc-cart-functions.php @@ -70,13 +70,13 @@ function wc_get_raw_referer() { return wp_get_raw_referer(); } - if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) { - return wp_unslash( $_REQUEST['_wp_http_referer'] ); - } else if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) { - return wp_unslash( $_SERVER['HTTP_REFERER'] ); - } + if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) { + return wp_unslash( $_REQUEST['_wp_http_referer'] ); + } elseif ( ! empty( $_SERVER['HTTP_REFERER'] ) ) { + return wp_unslash( $_SERVER['HTTP_REFERER'] ); + } - return false; + return false; } /** diff --git a/includes/wc-formatting-functions.php b/includes/wc-formatting-functions.php index de3366345bc..d6431432ab8 100644 --- a/includes/wc-formatting-functions.php +++ b/includes/wc-formatting-functions.php @@ -308,7 +308,7 @@ function wc_sanitize_tooltip( $var ) { 'li' => array(), 'ol' => array(), 'p' => array(), - ) ) ); + ) ) ); } /** diff --git a/includes/wc-page-functions.php b/includes/wc-page-functions.php index 09e1c6eb47a..f215220d852 100644 --- a/includes/wc-page-functions.php +++ b/includes/wc-page-functions.php @@ -129,7 +129,7 @@ function wc_nav_menu_items( $items ) { } } - return $items; + return $items; } add_filter( 'wp_nav_menu_objects', 'wc_nav_menu_items', 10 ); @@ -195,16 +195,21 @@ add_filter( 'wp_nav_menu_objects', 'wc_nav_menu_item_classes', 2 ); * @return string */ function wc_list_pages( $pages ) { - if (is_woocommerce()) { - $pages = str_replace( 'current_page_parent', '', $pages); // remove current_page_parent class from any item - $shop_page = 'page-item-' . wc_get_page_id('shop'); // find shop_page_id through woocommerce options + if ( is_woocommerce() ) { + // Remove current_page_parent class from any item. + $pages = str_replace( 'current_page_parent', '', $pages ); + // Find shop_page_id through woocommerce options. + $shop_page = 'page-item-' . wc_get_page_id( 'shop' ); - if (is_shop()) : - $pages = str_replace($shop_page, $shop_page . ' current_page_item', $pages); // add current_page_item class to shop page - else : - $pages = str_replace($shop_page, $shop_page . ' current_page_parent', $pages); // add current_page_parent class to shop page - endif; - } - return $pages; + if ( is_shop() ) { + // Add current_page_item class to shop page. + $pages = str_replace( $shop_page, $shop_page . ' current_page_item', $pages ); + } else { + // Add current_page_parent class to shop page. + $pages = str_replace( $shop_page, $shop_page . ' current_page_parent', $pages ); + } + } + + return $pages; } add_filter( 'wp_list_pages', 'wc_list_pages' ); diff --git a/includes/wc-template-functions.php b/includes/wc-template-functions.php index 2a8e5ed6dc2..ffc6848ca75 100644 --- a/includes/wc-template-functions.php +++ b/includes/wc-template-functions.php @@ -484,9 +484,9 @@ if ( ! function_exists( 'woocommerce_page_title' ) ) { $page_title = apply_filters( 'woocommerce_page_title', $page_title ); if ( $echo ) - echo $page_title; - else - return $page_title; + echo $page_title; + else + return $page_title; } } @@ -1151,8 +1151,8 @@ if ( ! function_exists( 'woocommerce_sort_product_tabs' ) ) { if ( ! function_exists( '_sort_priority_callback' ) ) { function _sort_priority_callback( $a, $b ) { if ( $a['priority'] === $b['priority'] ) - return 0; - return ( $a['priority'] < $b['priority'] ) ? -1 : 1; + return 0; + return ( $a['priority'] < $b['priority'] ) ? -1 : 1; } } diff --git a/includes/wc-user-functions.php b/includes/wc-user-functions.php index 697b760fde1..43ce6b7505e 100644 --- a/includes/wc-user-functions.php +++ b/includes/wc-user-functions.php @@ -317,7 +317,7 @@ function wc_modify_editable_roles( $roles ){ if ( ! current_user_can( 'administrator' ) ) { unset( $roles[ 'administrator' ] ); } - return $roles; + return $roles; } add_filter( 'editable_roles', 'wc_modify_editable_roles' ); diff --git a/includes/widgets/class-wc-widget-recently-viewed.php b/includes/widgets/class-wc-widget-recently-viewed.php index 008ed850fce..2ef0f26fae5 100644 --- a/includes/widgets/class-wc-widget-recently-viewed.php +++ b/includes/widgets/class-wc-widget-recently-viewed.php @@ -63,11 +63,11 @@ class WC_Widget_Recently_Viewed extends WC_Widget { $number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : $this->settings['number']['std']; - $query_args = array( 'posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'post__in' => $viewed_products, 'orderby' => 'rand' ); + $query_args = array( 'posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'post__in' => $viewed_products, 'orderby' => 'rand' ); $query_args['meta_query'] = array(); - $query_args['meta_query'][] = WC()->query->stock_status_meta_query(); - $query_args['meta_query'] = array_filter( $query_args['meta_query'] ); + $query_args['meta_query'][] = WC()->query->stock_status_meta_query(); + $query_args['meta_query'] = array_filter( $query_args['meta_query'] ); $r = new WP_Query( $query_args ); diff --git a/templates/checkout/form-coupon.php b/templates/checkout/form-coupon.php index 1e856bd3c70..56306183ad6 100644 --- a/templates/checkout/form-coupon.php +++ b/templates/checkout/form-coupon.php @@ -25,8 +25,8 @@ if ( ! wc_coupons_enabled() ) { } if ( empty( WC()->cart->applied_coupons ) ) { - $info_message = apply_filters( 'woocommerce_checkout_coupon_message', __( 'Have a coupon?', 'woocommerce' ) . ' ' . __( 'Click here to enter your code', 'woocommerce' ) . '' ); - wc_print_notice( $info_message, 'notice' ); + $info_message = apply_filters( 'woocommerce_checkout_coupon_message', __( 'Have a coupon?', 'woocommerce' ) . ' ' . __( 'Click here to enter your code', 'woocommerce' ) . '' ); + wc_print_notice( $info_message, 'notice' ); } ?> diff --git a/templates/checkout/terms.php b/templates/checkout/terms.php index 02b7be5c6b6..3c75c9482a2 100644 --- a/templates/checkout/terms.php +++ b/templates/checkout/terms.php @@ -12,10 +12,10 @@ if ( ! defined( 'ABSPATH' ) ) { if ( wc_get_page_id( 'terms' ) > 0 && apply_filters( 'woocommerce_checkout_show_terms', true ) ) : ?> -

+

id="terms" /> - - -

+ + +

diff --git a/templates/emails/customer-reset-password.php b/templates/emails/customer-reset-password.php index 200d2414877..5a071edcdb8 100644 --- a/templates/emails/customer-reset-password.php +++ b/templates/emails/customer-reset-password.php @@ -29,7 +29,7 @@ if ( ! defined( 'ABSPATH' ) ) {

- +

diff --git a/templates/emails/email-footer.php b/templates/emails/email-footer.php index a1e1e948006..9a97b19cccf 100644 --- a/templates/emails/email-footer.php +++ b/templates/emails/email-footer.php @@ -23,38 +23,38 @@ if ( ! defined( 'ABSPATH' ) ) { ?>
- - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/emails/email-header.php b/templates/emails/email-header.php index c053a638d8c..c84f91f1e61 100644 --- a/templates/emails/email-header.php +++ b/templates/emails/email-header.php @@ -23,44 +23,44 @@ if ( ! defined( 'ABSPATH' ) ) { ?> - - - <?php echo get_bloginfo( 'name', 'display' ); ?> + + + <?php echo get_bloginfo( 'name', 'display' ); ?> - ="0" marginwidth="0" topmargin="0" marginheight="0" offset="0"> -
- - -
+ ="0" marginwidth="0" topmargin="0" marginheight="0" offset="0"> +
+ + +
- ' . get_bloginfo( 'name', 'display' ) . '

'; - } - ?> + ' . get_bloginfo( 'name', 'display' ) . '

'; + } + ?>
- - - - - -
- - - - - -
-

-
- -
- - - -
- - - -
-
+ + + + + +
+ + + + + +
+

+
+ +
+ + + +
+ + + + - +
+
diff --git a/templates/emails/email-styles.php b/templates/emails/email-styles.php index d848d4b15e1..b2e939d7cb1 100644 --- a/templates/emails/email-styles.php +++ b/templates/emails/email-styles.php @@ -34,146 +34,146 @@ $text_lighter_20 = wc_hex_lighter( $text, 20 ); // !important; is a gmail hack to prevent styles being stripped if it doesn't like something. ?> #wrapper { - background-color: ; - margin: 0; - padding: 70px 0 70px 0; - -webkit-text-size-adjust: none !important; - width: 100%; + background-color: ; + margin: 0; + padding: 70px 0 70px 0; + -webkit-text-size-adjust: none !important; + width: 100%; } #template_container { - box-shadow: 0 1px 4px rgba(0,0,0,0.1) !important; - background-color: ; - border: 1px solid ; - border-radius: 3px !important; + box-shadow: 0 1px 4px rgba(0,0,0,0.1) !important; + background-color: ; + border: 1px solid ; + border-radius: 3px !important; } #template_header { - background-color: ; - border-radius: 3px 3px 0 0 !important; - color: ; - border-bottom: 0; - font-weight: bold; - line-height: 100%; - vertical-align: middle; - font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; + background-color: ; + border-radius: 3px 3px 0 0 !important; + color: ; + border-bottom: 0; + font-weight: bold; + line-height: 100%; + vertical-align: middle; + font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; } #template_header h1 { - color: ; + color: ; } #template_footer td { - padding: 0; - -webkit-border-radius: 6px; + padding: 0; + -webkit-border-radius: 6px; } #template_footer #credit { - border:0; - color: ; - font-family: Arial; - font-size:12px; - line-height:125%; - text-align:center; - padding: 0 48px 48px 48px; + border:0; + color: ; + font-family: Arial; + font-size:12px; + line-height:125%; + text-align:center; + padding: 0 48px 48px 48px; } #body_content { - background-color: ; + background-color: ; } #body_content table td { - padding: 48px; + padding: 48px; } #body_content table td td { - padding: 12px; + padding: 12px; } #body_content table td th { - padding: 12px; + padding: 12px; } #body_content p { - margin: 0 0 16px; + margin: 0 0 16px; } #body_content_inner { - color: ; - font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; - font-size: 14px; - line-height: 150%; - text-align: ; + color: ; + font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; + font-size: 14px; + line-height: 150%; + text-align: ; } .td { - color: ; - border: 1px solid ; + color: ; + border: 1px solid ; } .text { - color: ; - font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; + color: ; + font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; } .link { - color: ; + color: ; } #header_wrapper { - padding: 36px 48px; - display: block; + padding: 36px 48px; + display: block; } h1 { - color: ; - font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; - font-size: 30px; - font-weight: 300; - line-height: 150%; - margin: 0; - text-align: ; - text-shadow: 0 1px 0 ; - -webkit-font-smoothing: antialiased; + color: ; + font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; + font-size: 30px; + font-weight: 300; + line-height: 150%; + margin: 0; + text-align: ; + text-shadow: 0 1px 0 ; + -webkit-font-smoothing: antialiased; } h2 { - color: ; - display: block; - font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; - font-size: 18px; - font-weight: bold; - line-height: 130%; - margin: 16px 0 8px; - text-align: ; + color: ; + display: block; + font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; + font-size: 18px; + font-weight: bold; + line-height: 130%; + margin: 16px 0 8px; + text-align: ; } h3 { - color: ; - display: block; - font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; - font-size: 16px; - font-weight: bold; - line-height: 130%; - margin: 16px 0 8px; - text-align: ; + color: ; + display: block; + font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; + font-size: 16px; + font-weight: bold; + line-height: 130%; + margin: 16px 0 8px; + text-align: ; } a { - color: ; - font-weight: normal; - text-decoration: underline; + color: ; + font-weight: normal; + text-decoration: underline; } img { - border: none; - display: inline; - font-size: 14px; - font-weight: bold; - height: auto; - line-height: 100%; - outline: none; - text-decoration: none; - text-transform: capitalize; + border: none; + display: inline; + font-size: 14px; + font-weight: bold; + height: auto; + line-height: 100%; + outline: none; + text-decoration: none; + text-transform: capitalize; } get_order_item_totals() ) { } if ( $sent_to_admin ) { - echo "\n" . sprintf( __( 'View order: %s', 'woocommerce'), admin_url( 'post.php?post=' . $order->id . '&action=edit' ) ) . "\n"; + echo "\n" . sprintf( __( 'View order: %s', 'woocommerce'), admin_url( 'post.php?post=' . $order->id . '&action=edit' ) ) . "\n"; } do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text, $email ); diff --git a/templates/single-product-reviews.php b/templates/single-product-reviews.php index 623626721c9..079445d18f1 100644 --- a/templates/single-product-reviews.php +++ b/templates/single-product-reviews.php @@ -71,9 +71,9 @@ if ( ! comments_open() ) { 'comment_notes_after' => '', 'fields' => array( 'author' => '

' . ' ' . - '

', + '

', 'email' => '', + '

', ), 'label_submit' => __( 'Submit', 'woocommerce' ), 'logged_in_as' => '', diff --git a/templates/single-product/add-to-cart/variable.php b/templates/single-product/add-to-cart/variable.php index eddaa17fab3..8a3453afe07 100644 --- a/templates/single-product/add-to-cart/variable.php +++ b/templates/single-product/add-to-cart/variable.php @@ -44,7 +44,7 @@ do_action( 'woocommerce_before_add_to_cart_form' ); ?> ?>
diff --git a/templates/single-product/add-to-cart/variation.php b/templates/single-product/add-to-cart/variation.php index c977b7c6f8e..868c972b411 100644 --- a/templates/single-product/add-to-cart/variation.php +++ b/templates/single-product/add-to-cart/variation.php @@ -15,18 +15,18 @@ if ( ! defined( 'ABSPATH' ) ) { } ?> diff --git a/tests/bin/install.sh b/tests/bin/install.sh index 7fa5ae5f023..dcea51f3708 100755 --- a/tests/bin/install.sh +++ b/tests/bin/install.sh @@ -16,11 +16,11 @@ WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib} WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/} download() { - if [ `which curl` ]; then - curl -s "$1" > "$2"; - elif [ `which wget` ]; then - wget -nv -O "$2" "$1" - fi + if [ `which curl` ]; then + curl -s "$1" > "$2"; + elif [ `which wget` ]; then + wget -nv -O "$2" "$1" + fi } if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then @@ -110,4 +110,4 @@ install_db() { install_wp install_test_suite -install_db \ No newline at end of file +install_db diff --git a/tests/framework/helpers/class-wc-helper-shipping-zones.php b/tests/framework/helpers/class-wc-helper-shipping-zones.php index d668611ca44..ca44c1d9b57 100644 --- a/tests/framework/helpers/class-wc-helper-shipping-zones.php +++ b/tests/framework/helpers/class-wc-helper-shipping-zones.php @@ -7,50 +7,50 @@ */ class WC_Helper_Shipping_Zones { - /** - * Create some mock shipping zones to test against - */ - public static function create_mock_zones() { - self::remove_mock_zones(); - - // Local zone - $zone = new WC_Shipping_Zone(); - $zone->set_zone_name( 'Local' ); - $zone->set_zone_order( 1 ); - $zone->add_location( 'GB', 'country' ); - $zone->add_location( 'CB*', 'postcode' ); - $zone->save(); + /** + * Create some mock shipping zones to test against + */ + public static function create_mock_zones() { + self::remove_mock_zones(); - // Europe zone - $zone = new WC_Shipping_Zone(); - $zone->set_zone_name( 'Europe' ); - $zone->set_zone_order( 2 ); - $zone->add_location( 'EU', 'continent' ); - $zone->save(); + // Local zone + $zone = new WC_Shipping_Zone(); + $zone->set_zone_name( 'Local' ); + $zone->set_zone_order( 1 ); + $zone->add_location( 'GB', 'country' ); + $zone->add_location( 'CB*', 'postcode' ); + $zone->save(); - // US california zone - $zone = new WC_Shipping_Zone(); - $zone->set_zone_name( 'California' ); - $zone->set_zone_order( 3 ); - $zone->add_location( 'US:CA', 'state' ); - $zone->save(); + // Europe zone + $zone = new WC_Shipping_Zone(); + $zone->set_zone_name( 'Europe' ); + $zone->set_zone_order( 2 ); + $zone->add_location( 'EU', 'continent' ); + $zone->save(); - // US zone - $zone = new WC_Shipping_Zone(); - $zone->set_zone_name( 'US' ); - $zone->set_zone_order( 4 ); - $zone->add_location( 'US', 'country' ); - $zone->save(); - } + // US california zone + $zone = new WC_Shipping_Zone(); + $zone->set_zone_name( 'California' ); + $zone->set_zone_order( 3 ); + $zone->add_location( 'US:CA', 'state' ); + $zone->save(); - /** - * Remove all zones - */ - public static function remove_mock_zones() { - global $wpdb; - $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}woocommerce_shipping_zone_methods;" ); - $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}woocommerce_shipping_zone_locations;" ); - $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}woocommerce_shipping_zones;" ); + // US zone + $zone = new WC_Shipping_Zone(); + $zone->set_zone_name( 'US' ); + $zone->set_zone_order( 4 ); + $zone->add_location( 'US', 'country' ); + $zone->save(); + } + + /** + * Remove all zones + */ + public static function remove_mock_zones() { + global $wpdb; + $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}woocommerce_shipping_zone_methods;" ); + $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}woocommerce_shipping_zone_locations;" ); + $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}woocommerce_shipping_zones;" ); WC_Cache_Helper::incr_cache_prefix( 'shipping_zones' ); - } + } } diff --git a/tests/unit-tests/shipping-zones/shipping-zone.php b/tests/unit-tests/shipping-zones/shipping-zone.php index 5875847becf..26b36354229 100644 --- a/tests/unit-tests/shipping-zones/shipping-zone.php +++ b/tests/unit-tests/shipping-zones/shipping-zone.php @@ -10,246 +10,246 @@ class WC_Tests_Shipping_Zone extends WC_Unit_Test_Case { * Test: WC_Shipping_Zone::get_data */ public function test_get_data() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); - // Test - $zone = WC_Shipping_Zones::get_zone( 1 ); - $data = $zone->get_data(); + // Test + $zone = WC_Shipping_Zones::get_zone( 1 ); + $data = $zone->get_data(); - // Assert - $this->assertTrue( is_array( $data ) ); + // Assert + $this->assertTrue( is_array( $data ) ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); } - /** + /** * Test: WC_Shipping_Zones::get_zone_id */ - public function test_get_zone_id() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + public function test_get_zone_id() { + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); - // Test - $zone = WC_Shipping_Zones::get_zone( 1 ); + // Test + $zone = WC_Shipping_Zones::get_zone( 1 ); - // Assert - $this->assertEquals( $zone->get_zone_id(), 1 ); + // Assert + $this->assertEquals( $zone->get_zone_id(), 1 ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); - } + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); + } - /** + /** * Test: WC_Shipping_Zones::get_zone_name */ - public function test_get_zone_name() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + public function test_get_zone_name() { + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); - // Test - $zone = WC_Shipping_Zones::get_zone( 1 ); + // Test + $zone = WC_Shipping_Zones::get_zone( 1 ); - // Assert - $this->assertEquals( $zone->get_zone_name(), 'Local' ); + // Assert + $this->assertEquals( $zone->get_zone_name(), 'Local' ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); - } + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); + } - /** + /** * Test: WC_Shipping_Zones::get_zone_order */ - public function test_get_zone_order() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + public function test_get_zone_order() { + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); - // Test - $zone = WC_Shipping_Zones::get_zone( 1 ); + // Test + $zone = WC_Shipping_Zones::get_zone( 1 ); - // Assert - $this->assertEquals( $zone->get_zone_order(), 1 ); + // Assert + $this->assertEquals( $zone->get_zone_order(), 1 ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); - } + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); + } - /** + /** * Test: WC_Shipping_Zones::get_zone_locations */ - public function test_get_zone_locations() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + public function test_get_zone_locations() { + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); - // Test - $zone = WC_Shipping_Zones::get_zone( 1 ); + // Test + $zone = WC_Shipping_Zones::get_zone( 1 ); - // Assert - $this->assertTrue( is_array( $zone->get_zone_locations() ) ); - $this->assertTrue( 2 === sizeof( $zone->get_zone_locations() ) ); + // Assert + $this->assertTrue( is_array( $zone->get_zone_locations() ) ); + $this->assertTrue( 2 === sizeof( $zone->get_zone_locations() ) ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); - } + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); + } - /** + /** * Test: WC_Shipping_Zones::get_formatted_location */ - public function test_get_formatted_location() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + public function test_get_formatted_location() { + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); - // Test - $zone = WC_Shipping_Zones::get_zone( 1 ); + // Test + $zone = WC_Shipping_Zones::get_zone( 1 ); - // Assert - $this->assertEquals( $zone->get_formatted_location(), 'United Kingdom (UK), CB*' ); + // Assert + $this->assertEquals( $zone->get_formatted_location(), 'United Kingdom (UK), CB*' ); - // Test - $zone = WC_Shipping_Zones::get_zone( 2 ); + // Test + $zone = WC_Shipping_Zones::get_zone( 2 ); - // Assert - $this->assertEquals( $zone->get_formatted_location(), 'Europe' ); + // Assert + $this->assertEquals( $zone->get_formatted_location(), 'Europe' ); - // Test - $zone = WC_Shipping_Zones::get_zone( 3 ); + // Test + $zone = WC_Shipping_Zones::get_zone( 3 ); - // Assert - $this->assertEquals( $zone->get_formatted_location(), 'California' ); + // Assert + $this->assertEquals( $zone->get_formatted_location(), 'California' ); - // Test - $zone = WC_Shipping_Zones::get_zone( 4 ); + // Test + $zone = WC_Shipping_Zones::get_zone( 4 ); - // Assert - $this->assertEquals( $zone->get_formatted_location(), 'United States (US)' ); + // Assert + $this->assertEquals( $zone->get_formatted_location(), 'United States (US)' ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); - } + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); + } - /** + /** * Test: WC_Shipping_Zone::get_shipping_methods */ public function test_get_shipping_methods() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); - // Test - $zone = WC_Shipping_Zones::get_zone( 1 ); + // Test + $zone = WC_Shipping_Zones::get_zone( 1 ); $zone->add_shipping_method( 'flat_rate' ); $methods = $zone->get_shipping_methods(); - // Assert - $this->assertTrue( 1 === sizeof( $methods ) ); + // Assert + $this->assertTrue( 1 === sizeof( $methods ) ); $this->assertInstanceOf( 'WC_Shipping_Method', current( $methods ) ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); } - /** + /** * Test: WC_Shipping_Zone::set_zone_name */ public function test_set_zone_name() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); - // Test - $zone = WC_Shipping_Zones::get_zone( 1 ); + // Test + $zone = WC_Shipping_Zones::get_zone( 1 ); $zone->set_zone_name( 'I am a fish' ); - // Assert - $this->assertEquals( $zone->get_zone_name(), 'I am a fish' ); + // Assert + $this->assertEquals( $zone->get_zone_name(), 'I am a fish' ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); } - /** + /** * Test: WC_Shipping_Zone::set_zone_order */ public function test_set_zone_order() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); - // Test - $zone = WC_Shipping_Zones::get_zone( 1 ); + // Test + $zone = WC_Shipping_Zones::get_zone( 1 ); $zone->set_zone_order( 100 ); - // Assert - $this->assertEquals( $zone->get_zone_order(), 100 ); + // Assert + $this->assertEquals( $zone->get_zone_order(), 100 ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); } - /** + /** * Test: WC_Shipping_Zone::is_valid_location_type */ public function test_is_valid_location_type() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); - // Test - $zone = WC_Shipping_Zones::get_zone( 1 ); + // Test + $zone = WC_Shipping_Zones::get_zone( 1 ); - // Assert - $this->assertEquals( $zone->get_zone_order(), 1 ); + // Assert + $this->assertEquals( $zone->get_zone_order(), 1 ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); } - /** + /** * Test: WC_Shipping_Zone::add_location */ public function test_add_location() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); - // Test - $zone = WC_Shipping_Zones::get_zone( 1 ); + // Test + $zone = WC_Shipping_Zones::get_zone( 1 ); - // Assert - $this->assertTrue( $zone->is_valid_location_type( 'state' ) ); + // Assert + $this->assertTrue( $zone->is_valid_location_type( 'state' ) ); $this->assertTrue( $zone->is_valid_location_type( 'country' ) ); $this->assertTrue( $zone->is_valid_location_type( 'continent' ) ); $this->assertTrue( $zone->is_valid_location_type( 'postcode' ) ); $this->assertFalse( $zone->is_valid_location_type( 'poop' ) ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); } - /** + /** * Test: WC_Shipping_Zone::clear_locations */ public function test_clear_locations() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); - // Test - $zone = WC_Shipping_Zones::get_zone( 1 ); + // Test + $zone = WC_Shipping_Zones::get_zone( 1 ); $zone->clear_locations(); - // Assert - $zone_locations = $zone->get_zone_locations(); - $this->assertTrue( empty( $zone_locations ) ); + // Assert + $zone_locations = $zone->get_zone_locations(); + $this->assertTrue( empty( $zone_locations ) ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); } - /** + /** * Test: WC_Shipping_Zone::set_locations */ public function test_set_locations() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); - // Test - $zone = WC_Shipping_Zones::get_zone( 1 ); + // Test + $zone = WC_Shipping_Zones::get_zone( 1 ); $zone->clear_locations(); $zone->set_locations( array( array( @@ -262,8 +262,8 @@ class WC_Tests_Shipping_Zone extends WC_Unit_Test_Case { ) ) ); - // Assert - $this->assertEquals( $zone->get_zone_locations(), array( + // Assert + $this->assertEquals( $zone->get_zone_locations(), array( 2 => (object) array( 'code' => 'US', 'type' => 'country' @@ -274,50 +274,50 @@ class WC_Tests_Shipping_Zone extends WC_Unit_Test_Case { ) ) ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); } - /** + /** * Test: WC_Shipping_Zone::save */ public function test_save() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); // Test - $zone = WC_Shipping_Zones::get_zone( 1 ); + $zone = WC_Shipping_Zones::get_zone( 1 ); $zone->set_zone_name( 'I am a fish' ); $zone->save(); $zone = WC_Shipping_Zones::get_zone( 1 ); - // Assert - $this->assertEquals( $zone->get_zone_name(), 'I am a fish' ); + // Assert + $this->assertEquals( $zone->get_zone_name(), 'I am a fish' ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); } - /** + /** * Test: WC_Shipping_Zone::add_shipping_method */ public function test_add_shipping_method() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); - // Test - $zone = WC_Shipping_Zones::get_zone( 1 ); + // Test + $zone = WC_Shipping_Zones::get_zone( 1 ); $zone->add_shipping_method( 'flat_rate' ); $zone->add_shipping_method( 'free_shipping' ); - // Assert + // Assert $methods = $zone->get_shipping_methods(); // Assert $this->assertTrue( 2 === sizeof( $methods ) ); $this->assertInstanceOf( 'WC_Shipping_Method', current( $methods ) ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); } } diff --git a/tests/unit-tests/shipping-zones/shipping-zones.php b/tests/unit-tests/shipping-zones/shipping-zones.php index e6d67a5ef18..4c19ef31013 100644 --- a/tests/unit-tests/shipping-zones/shipping-zones.php +++ b/tests/unit-tests/shipping-zones/shipping-zones.php @@ -10,146 +10,146 @@ class WC_Tests_Shipping_Zones extends WC_Unit_Test_Case { * Test: WC_Shipping_Zones::get_zones */ public function test_get_zones() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); - // Test - $zones = WC_Shipping_Zones::get_zones(); + // Test + $zones = WC_Shipping_Zones::get_zones(); - // Assert - $this->assertTrue( is_array( $zones ) ); - $this->assertTrue( 4 === sizeof( $zones ) ); + // Assert + $this->assertTrue( is_array( $zones ) ); + $this->assertTrue( 4 === sizeof( $zones ) ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); } - /** + /** * Test: WC_Shipping_Zones::get_zone */ - public function test_get_zone() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + public function test_get_zone() { + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); - // Test - $zone = WC_Shipping_Zones::get_zone( 1 ); + // Test + $zone = WC_Shipping_Zones::get_zone( 1 ); - // Assert that the first zone is our local zone - $this->assertInstanceOf( 'WC_Shipping_Zone', $zone ); - $this->assertEquals( $zone->get_zone_name(), 'Local' ); + // Assert that the first zone is our local zone + $this->assertInstanceOf( 'WC_Shipping_Zone', $zone ); + $this->assertEquals( $zone->get_zone_name(), 'Local' ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); - } + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); + } - /** + /** * Test: WC_Shipping_Zones::get_zone_by */ - public function test_get_zone_by() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + public function test_get_zone_by() { + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); - // Test - $zone = WC_Shipping_Zones::get_zone_by( 'zone_id', 2 ); + // Test + $zone = WC_Shipping_Zones::get_zone_by( 'zone_id', 2 ); - // Assert - $this->assertInstanceOf( 'WC_Shipping_Zone', $zone ); - $this->assertEquals( $zone->get_zone_name(), 'Europe' ); + // Assert + $this->assertInstanceOf( 'WC_Shipping_Zone', $zone ); + $this->assertEquals( $zone->get_zone_name(), 'Europe' ); - // Test instance_id - $instance_id = $zone->add_shipping_method( 'flat_rate' ); + // Test instance_id + $instance_id = $zone->add_shipping_method( 'flat_rate' ); - $zone = WC_Shipping_Zones::get_zone_by( 'instance_id', $instance_id ); + $zone = WC_Shipping_Zones::get_zone_by( 'instance_id', $instance_id ); - // Assert - $this->assertInstanceOf( 'WC_Shipping_Zone', $zone ); - $this->assertEquals( $zone->get_zone_name(), 'Europe' ); + // Assert + $this->assertInstanceOf( 'WC_Shipping_Zone', $zone ); + $this->assertEquals( $zone->get_zone_name(), 'Europe' ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); - } + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); + } - /** + /** * Test: WC_Shipping_Zones::get_shipping_method */ - public function test_get_shipping_method() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + public function test_get_shipping_method() { + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); - // Test - $zone = WC_Shipping_Zones::get_zone_by( 'zone_id', 1 ); - $instance_id = $zone->add_shipping_method( 'flat_rate' ); - $shipping_method = WC_Shipping_Zones::get_shipping_method( $instance_id ); + // Test + $zone = WC_Shipping_Zones::get_zone_by( 'zone_id', 1 ); + $instance_id = $zone->add_shipping_method( 'flat_rate' ); + $shipping_method = WC_Shipping_Zones::get_shipping_method( $instance_id ); - // Assert - $this->assertInstanceOf( 'WC_Shipping_Flat_Rate', $shipping_method ); + // Assert + $this->assertInstanceOf( 'WC_Shipping_Flat_Rate', $shipping_method ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); - } + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); + } - /** + /** * Test: WC_Shipping_Zones::delete_zone */ - public function test_delete_zone() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + public function test_delete_zone() { + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); - // Test - WC_Shipping_Zones::delete_zone( 1 ); - $zones = WC_Shipping_Zones::get_zones(); + // Test + WC_Shipping_Zones::delete_zone( 1 ); + $zones = WC_Shipping_Zones::get_zones(); - // Assert - $this->assertTrue( 3 === sizeof( $zones ) ); + // Assert + $this->assertTrue( 3 === sizeof( $zones ) ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); - } + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); + } - /** + /** * Test: WC_Shipping_Zones::get_zone_matching_package */ - public function test_get_zone_matching_package() { - // Setup - WC_Helper_Shipping_Zones::create_mock_zones(); + public function test_get_zone_matching_package() { + // Setup + WC_Helper_Shipping_Zones::create_mock_zones(); - // Test - $zone1 = WC_Shipping_Zones::get_zone_matching_package( array( - 'destination' => array( - 'country' => 'GB', - 'state' => 'Cambs', - 'postcode' => 'CB23 1GG', - ) - ) ); - $zone2 = WC_Shipping_Zones::get_zone_matching_package( array( - 'destination' => array( - 'country' => 'GB', - 'state' => 'Cambs', - 'postcode' => 'PE12 1BG', - ) - ) ); - $zone3 = WC_Shipping_Zones::get_zone_matching_package( array( - 'destination' => array( - 'country' => 'US', - 'state' => 'CA', - 'postcode' => '90210', - ) - ) ); - $zone4 = WC_Shipping_Zones::get_zone_matching_package( array( - 'destination' => array( - 'country' => 'US', - 'state' => 'AL', - 'postcode' => '12345', - ) - ) ); + // Test + $zone1 = WC_Shipping_Zones::get_zone_matching_package( array( + 'destination' => array( + 'country' => 'GB', + 'state' => 'Cambs', + 'postcode' => 'CB23 1GG', + ) + ) ); + $zone2 = WC_Shipping_Zones::get_zone_matching_package( array( + 'destination' => array( + 'country' => 'GB', + 'state' => 'Cambs', + 'postcode' => 'PE12 1BG', + ) + ) ); + $zone3 = WC_Shipping_Zones::get_zone_matching_package( array( + 'destination' => array( + 'country' => 'US', + 'state' => 'CA', + 'postcode' => '90210', + ) + ) ); + $zone4 = WC_Shipping_Zones::get_zone_matching_package( array( + 'destination' => array( + 'country' => 'US', + 'state' => 'AL', + 'postcode' => '12345', + ) + ) ); - // Assert - $this->assertEquals( 'Local', $zone1->get_zone_name() ); - $this->assertEquals( 'Europe', $zone2->get_zone_name() ); - $this->assertEquals( 'California', $zone3->get_zone_name() ); - $this->assertEquals( 'US', $zone4->get_zone_name() ); + // Assert + $this->assertEquals( 'Local', $zone1->get_zone_name() ); + $this->assertEquals( 'Europe', $zone2->get_zone_name() ); + $this->assertEquals( 'California', $zone3->get_zone_name() ); + $this->assertEquals( 'US', $zone4->get_zone_name() ); - // Clean - WC_Helper_Shipping_Zones::remove_mock_zones(); - } + // Clean + WC_Helper_Shipping_Zones::remove_mock_zones(); + } } diff --git a/tests/unit-tests/util/validation.php b/tests/unit-tests/util/validation.php index f1a5c3e3094..6c05cff3b68 100644 --- a/tests/unit-tests/util/validation.php +++ b/tests/unit-tests/util/validation.php @@ -82,15 +82,15 @@ class WC_Tests_Validation extends WC_Unit_Test_Case { array( false, WC_Validation::is_postcode( '99999-ABC', 'BR' ) ) ); - $ca = array( - array( true, WC_Validation::is_postcode( 'A9A 9A9', 'CA' ) ), + $ca = array( + array( true, WC_Validation::is_postcode( 'A9A 9A9', 'CA' ) ), array( true, WC_Validation::is_postcode( 'A9A9A9', 'CA' ) ), - array( true, WC_Validation::is_postcode( 'a9a9a9', 'CA' ) ), + array( true, WC_Validation::is_postcode( 'a9a9a9', 'CA' ) ), array( false, WC_Validation::is_postcode( 'D0A 9A9', 'CA' ) ), - array( false, WC_Validation::is_postcode( '99999', 'CA' ) ), - array( false, WC_Validation::is_postcode( 'ABC999', 'CA' ) ), + array( false, WC_Validation::is_postcode( '99999', 'CA' ) ), + array( false, WC_Validation::is_postcode( 'ABC999', 'CA' ) ), array( false, WC_Validation::is_postcode( '0A0A0A', 'CA' ) ) - ); + ); return array_merge( $generic, $gb, $us, $ch, $br, $ca ); }