Remove simplify commerce gateway

This commit is contained in:
Mike Jolley 2019-01-10 12:01:27 +00:00
parent 5117a65638
commit 9d381d456b
42 changed files with 14 additions and 5317 deletions

View File

@ -24,7 +24,6 @@ exclude_paths:
- "includes/api/legacy/"
- "includes/libraries/"
- "includes/updates/"
- "includes/gateways/simplify-commerce/"
- "includes/shipping/legacy-*"
- "includes/wc-deprecated-functions.php"
- "assets/js/accounting/"

View File

@ -27,7 +27,6 @@ filter:
- sample-data/
- i18n/
- includes/api/legacy/
- includes/gateways/simplify-commerce/includes/
- includes/legacy/
- includes/libraries/
- includes/shipping/legacy-*

View File

@ -298,15 +298,14 @@ module.exports = function( grunt ) {
},
dist: {
src: [
'**/*.php', // Include all files
'!apigen/**', // Exclude apigen/
'!includes/api/legacy/**', // Exclude legacy REST API
'!includes/gateways/simplify-commerce/includes/Simplify/**', // Exclude simplify commerce SDK
'!includes/libraries/**', // Exclude libraries/
'!node_modules/**', // Exclude node_modules/
'!tests/cli/**', // Exclude tests/cli/
'!tmp/**', // Exclude tmp/
'!vendor/**' // Exclude vendor/
'**/*.php', // Include all php files.
'!apigen/**',
'!includes/api/legacy/**',
'!includes/libraries/**',
'!node_modules/**',
'!tests/cli/**',
'!tmp/**',
'!vendor/**'
]
}
},

View File

@ -583,17 +583,6 @@
color: inherit;
}
.simplify-commerce-banner {
overflow: hidden;
img {
float: right;
padding: 15px 0;
margin-left: 1em;
width: 200px;
}
}
/**
* Help Tip
*/
@ -3686,15 +3675,15 @@
padding: 0 15px 10px 0;
}
}
.wc-shipping-zone-settings {
td.forminp {
input, textarea {
width: 448px;
padding: 6px 11px;
}
.select2-search input {
padding: 6px;
}

View File

@ -31,7 +31,6 @@ class WC_Admin_Notices {
'template_files' => 'template_file_check_notice',
'legacy_shipping' => 'legacy_shipping_notice',
'no_shipping_methods' => 'no_shipping_methods_notice',
'simplify_commerce' => 'simplify_commerce_notice',
'regenerating_thumbnails' => 'regenerating_thumbnails_notice',
'no_secure_connection' => 'secure_connection_notice',
'wootenberg' => 'wootenberg_feature_plugin_notice',
@ -81,17 +80,9 @@ class WC_Admin_Notices {
* Reset notices for themes when switched or a new version of WC is installed.
*/
public static function reset_admin_notices() {
$simplify_options = get_option( 'woocommerce_simplify_commerce_settings', array() );
$location = wc_get_base_location();
if ( ! class_exists( 'WC_Gateway_Simplify_Commerce_Loader' ) && ! empty( $simplify_options['enabled'] ) && 'yes' === $simplify_options['enabled'] && in_array( $location['country'], apply_filters( 'woocommerce_gateway_simplify_commerce_supported_countries', array( 'US', 'IE' ) ), true ) ) {
self::add_notice( 'simplify_commerce' );
}
if ( ! self::is_ssl() ) {
self::add_notice( 'no_secure_connection' );
}
self::add_wootenberg_feature_plugin_notice();
self::add_notice( 'template_files' );
}
@ -329,18 +320,10 @@ class WC_Admin_Notices {
}
/**
* Simplify Commerce is being removed from core.
* Simplify Commerce is no longer in core.
*/
public static function simplify_commerce_notice() {
$location = wc_get_base_location();
if ( class_exists( 'WC_Gateway_Simplify_Commerce_Loader' ) || ! in_array( $location['country'], apply_filters( 'woocommerce_gateway_simplify_commerce_supported_countries', array( 'US', 'IE' ) ), true ) ) {
self::remove_notice( 'simplify_commerce' );
return;
}
if ( empty( $_GET['action'] ) ) { // WPCS: input var ok, CSRF ok.
include dirname( __FILE__ ) . '/views/html-notice-simplify-commerce.php';
}
wc_deprecated_function( 'WC_Admin_Notices::simplify_commerce_notice', '3.6.0' );
}
/**

View File

@ -1,24 +0,0 @@
<?php
/**
* Admin View: Notice - Simplify Commerce.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$plugin_slug = 'woocommerce-gateway-simplify-commerce';
if ( current_user_can( 'install_plugins' ) ) {
$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $plugin_slug ), 'install-plugin_' . $plugin_slug );
} else {
$url = 'https://wordpress.org/plugins/' . $plugin_slug;
}
?>
<div id="message" class="updated woocommerce-message">
<a class="woocommerce-message-close notice-dismiss" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-hide-notice', 'simplify_commerce' ), 'woocommerce_hide_notices_nonce', '_wc_notice_nonce' ) ); ?>"><?php _e( 'Dismiss', 'woocommerce' ); ?></a>
<p><?php _e( '<strong>The Simplify Commerce payment gateway is deprecated</strong> &#8211; Please install our new free Simplify Commerce plugin from WordPress.org. Simplify Commerce will be removed from WooCommerce core in a future update.', 'woocommerce' ); ?></p>
<p class="submit"><a href="<?php echo esc_url( $url ); ?>" class="wc-update-now button-primary"><?php _e( 'Install our new Simplify Commerce plugin', 'woocommerce' ); ?></a></p>
</div>

View File

@ -81,21 +81,6 @@ class WC_Payment_Gateways {
'WC_Gateway_Paypal',
);
/**
* Simplify Commerce is @deprecated in 2.6.0. Only load when enabled.
*/
if ( ! class_exists( 'WC_Gateway_Simplify_Commerce_Loader' ) && in_array( WC()->countries->get_base_country(), apply_filters( 'woocommerce_gateway_simplify_commerce_supported_countries', array( 'US', 'IE' ) ), true ) ) {
$simplify_options = get_option( 'woocommerce_simplify_commerce_settings', array() );
if ( ! empty( $simplify_options['enabled'] ) && 'yes' === $simplify_options['enabled'] ) {
if ( function_exists( 'wcs_create_renewal_order' ) ) {
$load_gateways[] = 'WC_Addons_Gateway_Simplify_Commerce';
} else {
$load_gateways[] = 'WC_Gateway_Simplify_Commerce';
}
}
}
// Filter.
$load_gateways = apply_filters( 'woocommerce_payment_gateways', $load_gateways );

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

View File

@ -1,118 +0,0 @@
/*global Simplify_commerce_params, SimplifyCommerce */
(function ( $ ) {
// Form handler
function simplifyFormHandler() {
var $form = $( 'form.checkout, form#order_review, form#add_payment_method' );
if ( ( $( '#payment_method_simplify_commerce' ).is( ':checked' ) && 'new' === $( 'input[name="wc-simplify_commerce-payment-token"]:checked' ).val() ) || ( '1' === $( '#woocommerce_add_payment_method' ).val() ) ) {
if ( 0 === $( 'input.simplify-token' ).length ) {
$form.block({
message: null,
overlayCSS: {
background: '#fff',
opacity: 0.6
}
});
var card = $( '#simplify_commerce-card-number' ).val(),
cvc = $( '#simplify_commerce-card-cvc' ).val(),
expiry = $.payment.cardExpiryVal( $( '#simplify_commerce-card-expiry' ).val() ),
address1 = $form.find( '#billing_address_1' ).val() || '',
address2 = $form.find( '#billing_address_2' ).val() || '',
addressCountry = $form.find( '#billing_country' ).val() || '',
addressState = $form.find( '#billing_state' ).val() || '',
addressCity = $form.find( '#billing_city' ).val() || '',
addressZip = $form.find( '#billing_postcode' ).val() || '';
addressZip = addressZip.replace( /-/g, '' );
card = card.replace( /\s/g, '' );
SimplifyCommerce.generateToken({
key: Simplify_commerce_params.key,
card: {
number: card,
cvc: cvc,
expMonth: expiry.month,
expYear: ( expiry.year - 2000 ),
addressLine1: address1,
addressLine2: address2,
addressCountry: addressCountry,
addressState: addressState,
addressZip: addressZip,
addressCity: addressCity
}
}, simplifyResponseHandler );
// Prevent the form from submitting
return false;
}
}
return true;
}
// Handle Simplify response
function simplifyResponseHandler( data ) {
var $form = $( 'form.checkout, form#order_review, form#add_payment_method' ),
ccForm = $( '#wc-simplify_commerce-cc-form' );
if ( data.error ) {
// Show the errors on the form
$( '.woocommerce-error, .simplify-token', ccForm ).remove();
$form.unblock();
// Show any validation errors
if ( 'validation' === data.error.code ) {
var fieldErrors = data.error.fieldErrors,
fieldErrorsLength = fieldErrors.length,
errorList = '';
for ( var i = 0; i < fieldErrorsLength; i++ ) {
errorList += '<li>' + Simplify_commerce_params[ fieldErrors[i].field ] + ' ' + Simplify_commerce_params.is_invalid + ' - ' + fieldErrors[i].message + '.</li>';
}
ccForm.prepend( '<ul class="woocommerce-error">' + errorList + '</ul>' );
}
} else {
// Insert the token into the form so it gets submitted to the server
ccForm.append( '<input type="hidden" class="simplify-token" name="simplify_token" value="' + data.id + '"/>' );
$form.submit();
}
}
$( function () {
$( document.body ).on( 'checkout_error', function () {
$( '.simplify-token' ).remove();
});
/* Checkout Form */
$( 'form.checkout' ).on( 'checkout_place_order_simplify_commerce', function () {
return simplifyFormHandler();
});
/* Pay Page Form */
$( 'form#order_review' ).on( 'submit', function () {
return simplifyFormHandler();
});
/* Pay Page Form */
$( 'form#add_payment_method' ).on( 'submit', function () {
return simplifyFormHandler();
});
/* Both Forms */
$( 'form.checkout, form#order_review, form#add_payment_method' ).on( 'change', '#wc-simplify_commerce-cc-form input', function() {
$( '.simplify-token' ).remove();
});
});
}( jQuery ) );

View File

@ -1 +0,0 @@
!function(e){function r(){var r=e("form.checkout, form#order_review, form#add_payment_method");if((e("#payment_method_simplify_commerce").is(":checked")&&"new"===e('input[name="wc-simplify_commerce-payment-token"]:checked').val()||"1"===e("#woocommerce_add_payment_method").val())&&0===e("input.simplify-token").length){r.block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var i=e("#simplify_commerce-card-number").val(),m=e("#simplify_commerce-card-cvc").val(),c=e.payment.cardExpiryVal(e("#simplify_commerce-card-expiry").val()),n=r.find("#billing_address_1").val()||"",a=r.find("#billing_address_2").val()||"",t=r.find("#billing_country").val()||"",d=r.find("#billing_state").val()||"",l=r.find("#billing_city").val()||"",f=r.find("#billing_postcode").val()||"";return f=f.replace(/-/g,""),i=i.replace(/\s/g,""),SimplifyCommerce.generateToken({key:Simplify_commerce_params.key,card:{number:i,cvc:m,expMonth:c.month,expYear:c.year-2e3,addressLine1:n,addressLine2:a,addressCountry:t,addressState:d,addressZip:f,addressCity:l}},o),!1}return!0}function o(r){var o=e("form.checkout, form#order_review, form#add_payment_method"),i=e("#wc-simplify_commerce-cc-form");if(r.error){if(e(".woocommerce-error, .simplify-token",i).remove(),o.unblock(),"validation"===r.error.code){for(var m=r.error.fieldErrors,c=m.length,n="",a=0;a<c;a++)n+="<li>"+Simplify_commerce_params[m[a].field]+" "+Simplify_commerce_params.is_invalid+" - "+m[a].message+".</li>";i.prepend('<ul class="woocommerce-error">'+n+"</ul>")}}else i.append('<input type="hidden" class="simplify-token" name="simplify_token" value="'+r.id+'"/>'),o.submit()}e(function(){e(document.body).on("checkout_error",function(){e(".simplify-token").remove()}),e("form.checkout").on("checkout_place_order_simplify_commerce",function(){return r()}),e("form#order_review").on("submit",function(){return r()}),e("form#add_payment_method").on("submit",function(){return r()}),e("form.checkout, form#order_review, form#add_payment_method").on("change","#wc-simplify_commerce-cc-form input",function(){e(".simplify-token").remove()})})}(jQuery);

View File

@ -1,519 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Simplify Commerce Gateway for subscriptions.
*
* @class WC_Addons_Gateway_Simplify_Commerce
* @extends WC_Gateway_Simplify_Commerce
* @since 2.2.0
* @version 1.0.0
* @package WooCommerce/Classes/Payment
* @author WooThemes
*/
class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
/**
* Constructor.
*/
public function __construct() {
parent::__construct();
if ( class_exists( 'WC_Subscriptions_Order' ) ) {
add_action( 'woocommerce_scheduled_subscription_payment_' . $this->id, array( $this, 'scheduled_subscription_payment' ), 10, 2 );
add_action( 'woocommerce_subscription_failing_payment_method_updated_' . $this->id, array( $this, 'update_failing_payment_method' ), 10, 2 );
add_action( 'wcs_resubscribe_order_created', array( $this, 'delete_resubscribe_meta' ), 10 );
// Allow store managers to manually set Simplify as the payment method on a subscription
add_filter( 'woocommerce_subscription_payment_meta', array( $this, 'add_subscription_payment_meta' ), 10, 2 );
add_filter( 'woocommerce_subscription_validate_payment_meta', array( $this, 'validate_subscription_payment_meta' ), 10, 2 );
}
if ( class_exists( 'WC_Pre_Orders_Order' ) ) {
add_action( 'wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array( $this, 'process_pre_order_release_payment' ) );
}
add_filter( 'woocommerce_simplify_commerce_hosted_args', array( $this, 'hosted_payment_args' ), 10, 2 );
add_action( 'woocommerce_api_wc_addons_gateway_simplify_commerce', array( $this, 'return_handler' ) );
}
/**
* Hosted payment args.
*
* @param array $args
* @param int $order_id
* @return array
*/
public function hosted_payment_args( $args, $order_id ) {
if ( ( $this->order_contains_subscription( $order_id ) ) || ( $this->order_contains_pre_order( $order_id ) && WC_Pre_Orders_Order::order_requires_payment_tokenization( $order_id ) ) ) {
$args['operation'] = 'create.token';
}
$args['redirect-url'] = WC()->api_request_url( 'WC_Addons_Gateway_Simplify_Commerce' );
return $args;
}
/**
* Check if order contains subscriptions.
*
* @param int $order_id
* @return bool
*/
protected function order_contains_subscription( $order_id ) {
return function_exists( 'wcs_order_contains_subscription' ) && ( wcs_order_contains_subscription( $order_id ) || wcs_order_contains_renewal( $order_id ) );
}
/**
* Check if order contains pre-orders.
*
* @param int $order_id
* @return bool
*/
protected function order_contains_pre_order( $order_id ) {
return class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Order::order_contains_pre_order( $order_id );
}
/**
* Process the subscription.
*
* @param WC_Order $order
* @param string $cart_token
* @uses Simplify_ApiException
* @uses Simplify_BadRequestException
* @return array
* @throws Exception
*/
protected function process_subscription( $order, $cart_token = '' ) {
try {
if ( empty( $cart_token ) ) {
$error_msg = __( 'Please make sure your card details have been entered correctly and that your browser supports JavaScript.', 'woocommerce' );
if ( 'yes' == $this->sandbox ) {
$error_msg .= ' ' . __( 'Developers: Please make sure that you are including jQuery and there are no JavaScript errors on the page.', 'woocommerce' );
}
throw new Simplify_ApiException( $error_msg );
}
// Create customer
$customer = Simplify_Customer::createCustomer(
array(
'token' => $cart_token,
'email' => $order->get_billing_email(),
'name' => trim( $order->get_formatted_billing_full_name() ),
'reference' => $order->get_id(),
)
);
if ( is_object( $customer ) && '' != $customer->id ) {
$this->save_subscription_meta( $order->get_id(), $customer->id );
} else {
$error_msg = __( 'Error creating user in Simplify Commerce.', 'woocommerce' );
throw new Simplify_ApiException( $error_msg );
}
$payment_response = $this->process_subscription_payment( $order, $order->get_total() );
if ( is_wp_error( $payment_response ) ) {
throw new Exception( $payment_response->get_error_message() );
} else {
// Remove cart
WC()->cart->empty_cart();
// Return thank you page redirect
return array(
'result' => 'success',
'redirect' => $this->get_return_url( $order ),
);
}
} catch ( Simplify_ApiException $e ) {
if ( $e instanceof Simplify_BadRequestException && $e->hasFieldErrors() && $e->getFieldErrors() ) {
foreach ( $e->getFieldErrors() as $error ) {
wc_add_notice( $error->getFieldName() . ': "' . $error->getMessage() . '" (' . $error->getErrorCode() . ')', 'error' );
}
} else {
wc_add_notice( $e->getMessage(), 'error' );
}
return array(
'result' => 'fail',
'redirect' => '',
);
}
}
/**
* Store the customer and card IDs on the order and subscriptions in the order.
*
* @param int $order_id
* @param string $customer_id
*/
protected function save_subscription_meta( $order_id, $customer_id ) {
$customer_id = wc_clean( $customer_id );
update_post_meta( $order_id, '_simplify_customer_id', $customer_id );
// Also store it on the subscriptions being purchased in the order
foreach ( wcs_get_subscriptions_for_order( $order_id ) as $subscription ) {
update_post_meta( $subscription->id, '_simplify_customer_id', $customer_id );
}
}
/**
* Process the pre-order.
*
* @param WC_Order $order
* @param string $cart_token
* @uses Simplify_ApiException
* @uses Simplify_BadRequestException
* @return array
*/
protected function process_pre_order( $order, $cart_token = '' ) {
if ( WC_Pre_Orders_Order::order_requires_payment_tokenization( $order->get_id() ) ) {
try {
if ( $order->get_total() * 100 < 50 ) {
$error_msg = __( 'Sorry, the minimum allowed order total is 0.50 to use this payment method.', 'woocommerce' );
throw new Simplify_ApiException( $error_msg );
}
if ( empty( $cart_token ) ) {
$error_msg = __( 'Please make sure your card details have been entered correctly and that your browser supports JavaScript.', 'woocommerce' );
if ( 'yes' == $this->sandbox ) {
$error_msg .= ' ' . __( 'Developers: Please make sure that you are including jQuery and there are no JavaScript errors on the page.', 'woocommerce' );
}
throw new Simplify_ApiException( $error_msg );
}
// Create customer
$customer = Simplify_Customer::createCustomer(
array(
'token' => $cart_token,
'email' => $order->get_billing_email(),
'name' => trim( $order->get_formatted_billing_full_name() ),
'reference' => $order->get_id(),
)
);
if ( is_object( $customer ) && '' != $customer->id ) {
$customer_id = wc_clean( $customer->id );
// Store the customer ID in the order
update_post_meta( $order->get_id(), '_simplify_customer_id', $customer_id );
} else {
$error_msg = __( 'Error creating user in Simplify Commerce.', 'woocommerce' );
throw new Simplify_ApiException( $error_msg );
}
// Remove cart
WC()->cart->empty_cart();
// Is pre ordered!
WC_Pre_Orders_Order::mark_order_as_pre_ordered( $order );
// Return thank you page redirect
return array(
'result' => 'success',
'redirect' => $this->get_return_url( $order ),
);
} catch ( Simplify_ApiException $e ) {
if ( $e instanceof Simplify_BadRequestException && $e->hasFieldErrors() && $e->getFieldErrors() ) {
foreach ( $e->getFieldErrors() as $error ) {
wc_add_notice( $error->getFieldName() . ': "' . $error->getMessage() . '" (' . $error->getErrorCode() . ')', 'error' );
}
} else {
wc_add_notice( $e->getMessage(), 'error' );
}
return array(
'result' => 'fail',
'redirect' => '',
);
}
} else {
return parent::process_standard_payments( $order, $cart_token );
}
}
/**
* Process the payment.
*
* @param int $order_id
* @return array
*/
public function process_payment( $order_id ) {
$cart_token = isset( $_POST['simplify_token'] ) ? wc_clean( $_POST['simplify_token'] ) : '';
$order = wc_get_order( $order_id );
// Processing subscription
if ( 'standard' == $this->mode && ( $this->order_contains_subscription( $order->get_id() ) || ( function_exists( 'wcs_is_subscription' ) && wcs_is_subscription( $order_id ) ) ) ) {
return $this->process_subscription( $order, $cart_token );
} elseif ( 'standard' == $this->mode && $this->order_contains_pre_order( $order->get_id() ) ) {
// Processing pre-order.
return $this->process_pre_order( $order, $cart_token );
} else {
// Processing regular product.
return parent::process_payment( $order_id );
}
}
/**
* process_subscription_payment function.
*
* @param WC_order $order
* @param int $amount (default: 0)
* @uses Simplify_BadRequestException
* @return bool|WP_Error
*/
public function process_subscription_payment( $order, $amount = 0 ) {
if ( 0 == $amount ) {
// Payment complete
$order->payment_complete();
return true;
}
if ( $amount * 100 < 50 ) {
return new WP_Error( 'simplify_error', __( 'Sorry, the minimum allowed order total is 0.50 to use this payment method.', 'woocommerce' ) );
}
$customer_id = get_post_meta( $order->get_id(), '_simplify_customer_id', true );
if ( ! $customer_id ) {
return new WP_Error( 'simplify_error', __( 'Customer not found.', 'woocommerce' ) );
}
try {
// Charge the customer
$payment = Simplify_Payment::createPayment(
array(
'amount' => $amount * 100, // In cents.
'customer' => $customer_id,
'description' => sprintf( __( '%1$s - Order #%2$s', 'woocommerce' ), esc_html( get_bloginfo( 'name', 'display' ) ), $order->get_order_number() ),
'currency' => strtoupper( get_woocommerce_currency() ),
'reference' => $order->get_id(),
)
);
} catch ( Exception $e ) {
$error_message = $e->getMessage();
if ( $e instanceof Simplify_BadRequestException && $e->hasFieldErrors() && $e->getFieldErrors() ) {
$error_message = '';
foreach ( $e->getFieldErrors() as $error ) {
$error_message .= ' ' . $error->getFieldName() . ': "' . $error->getMessage() . '" (' . $error->getErrorCode() . ')';
}
}
$order->add_order_note( sprintf( __( 'Simplify payment error: %s.', 'woocommerce' ), $error_message ) );
return new WP_Error( 'simplify_payment_declined', $e->getMessage(), array( 'status' => $e->getCode() ) );
}
if ( 'APPROVED' == $payment->paymentStatus ) {
// Payment complete
$order->payment_complete( $payment->id );
// Add order note
$order->add_order_note( sprintf( __( 'Simplify payment approved (ID: %1$s, Auth Code: %2$s)', 'woocommerce' ), $payment->id, $payment->authCode ) );
return true;
} else {
$order->add_order_note( __( 'Simplify payment declined', 'woocommerce' ) );
return new WP_Error( 'simplify_payment_declined', __( 'Payment was declined - please try another card.', 'woocommerce' ) );
}
}
/**
* scheduled_subscription_payment function.
*
* @param float $amount_to_charge The amount to charge.
* @param WC_Order $renewal_order A WC_Order object created to record the renewal payment.
*/
public function scheduled_subscription_payment( $amount_to_charge, $renewal_order ) {
$result = $this->process_subscription_payment( $renewal_order, $amount_to_charge );
if ( is_wp_error( $result ) ) {
$renewal_order->update_status( 'failed', sprintf( __( 'Simplify Transaction Failed (%s)', 'woocommerce' ), $result->get_error_message() ) );
}
}
/**
* Update the customer_id for a subscription after using Simplify to complete a payment to make up for.
* an automatic renewal payment which previously failed.
*
* @param WC_Subscription $subscription The subscription for which the failing payment method relates.
* @param WC_Order $renewal_order The order which recorded the successful payment (to make up for the failed automatic payment).
*/
public function update_failing_payment_method( $subscription, $renewal_order ) {
update_post_meta( $subscription->id, '_simplify_customer_id', get_post_meta( $renewal_order->get_id(), '_simplify_customer_id', true ) );
}
/**
* Include the payment meta data required to process automatic recurring payments so that store managers can.
* manually set up automatic recurring payments for a customer via the Edit Subscription screen in Subscriptions v2.0+.
*
* @since 2.4
* @param array $payment_meta associative array of meta data required for automatic payments
* @param WC_Subscription $subscription An instance of a subscription object
* @return array
*/
public function add_subscription_payment_meta( $payment_meta, $subscription ) {
$payment_meta[ $this->id ] = array(
'post_meta' => array(
'_simplify_customer_id' => array(
'value' => get_post_meta( $subscription->id, '_simplify_customer_id', true ),
'label' => 'Simplify Customer ID',
),
),
);
return $payment_meta;
}
/**
* Validate the payment meta data required to process automatic recurring payments so that store managers can.
* manually set up automatic recurring payments for a customer via the Edit Subscription screen in Subscriptions 2.0+.
*
* @since 2.4
* @param string $payment_method_id The ID of the payment method to validate
* @param array $payment_meta associative array of meta data required for automatic payments
* @throws Exception
*/
public function validate_subscription_payment_meta( $payment_method_id, $payment_meta ) {
if ( $this->id === $payment_method_id ) {
if ( ! isset( $payment_meta['post_meta']['_simplify_customer_id']['value'] ) || empty( $payment_meta['post_meta']['_simplify_customer_id']['value'] ) ) {
throw new Exception( 'A "_simplify_customer_id" value is required.' );
}
}
}
/**
* Don't transfer customer meta to resubscribe orders.
*
* @access public
* @param int $resubscribe_order The order created for the customer to resubscribe to the old expired/cancelled subscription
* @return void
*/
public function delete_resubscribe_meta( $resubscribe_order ) {
delete_post_meta( $resubscribe_order->get_id(), '_simplify_customer_id' );
}
/**
* Process a pre-order payment when the pre-order is released.
*
* @param WC_Order $order
* @return WP_Error|null
*/
public function process_pre_order_release_payment( $order ) {
try {
$order_items = $order->get_items();
$order_item = array_shift( $order_items );
/* translators: 1: site name 2: product name 3: order number */
$pre_order_name = sprintf(
__( '%1$s - Pre-order for "%2$s" (Order #%3$s)', 'woocommerce' ),
esc_html( get_bloginfo( 'name', 'display' ) ),
$order_item['name'],
$order->get_order_number()
);
$customer_id = get_post_meta( $order->get_id(), '_simplify_customer_id', true );
if ( ! $customer_id ) {
return new WP_Error( 'simplify_error', __( 'Customer not found.', 'woocommerce' ) );
}
// Charge the customer
$payment = Simplify_Payment::createPayment(
array(
'amount' => $order->get_total() * 100, // In cents.
'customer' => $customer_id,
'description' => trim( substr( $pre_order_name, 0, 1024 ) ),
'currency' => strtoupper( get_woocommerce_currency() ),
'reference' => $order->get_id(),
)
);
if ( 'APPROVED' == $payment->paymentStatus ) {
// Payment complete
$order->payment_complete( $payment->id );
// Add order note
$order->add_order_note( sprintf( __( 'Simplify payment approved (ID: %1$s, Auth Code: %2$s)', 'woocommerce' ), $payment->id, $payment->authCode ) );
} else {
return new WP_Error( 'simplify_payment_declined', __( 'Payment was declined - the customer need to try another card.', 'woocommerce' ) );
}
} catch ( Exception $e ) {
$order_note = sprintf( __( 'Simplify Transaction Failed (%s)', 'woocommerce' ), $e->getMessage() );
// Mark order as failed if not already set,
// otherwise, make sure we add the order note so we can detect when someone fails to check out multiple times
if ( 'failed' != $order->get_status() ) {
$order->update_status( 'failed', $order_note );
} else {
$order->add_order_note( $order_note );
}
}
}
/**
* Return handler for Hosted Payments.
*/
public function return_handler() {
if ( ! isset( $_REQUEST['cardToken'] ) ) {
parent::return_handler();
}
@ob_clean();
header( 'HTTP/1.1 200 OK' );
$redirect_url = wc_get_page_permalink( 'cart' );
if ( isset( $_REQUEST['reference'] ) && isset( $_REQUEST['amount'] ) ) {
$cart_token = $_REQUEST['cardToken'];
$amount = absint( $_REQUEST['amount'] );
$order_id = absint( $_REQUEST['reference'] );
$order = wc_get_order( $order_id );
$order_total = absint( $order->get_total() * 100 );
if ( $amount === $order_total ) {
if ( $this->order_contains_subscription( $order->get_id() ) ) {
$response = $this->process_subscription( $order, $cart_token );
} elseif ( $this->order_contains_pre_order( $order->get_id() ) ) {
$response = $this->process_pre_order( $order, $cart_token );
} else {
$response = parent::process_standard_payments( $order, $cart_token );
}
if ( 'success' == $response['result'] ) {
$redirect_url = $response['redirect'];
} else {
$order->update_status( 'failed', __( 'Payment was declined by Simplify Commerce.', 'woocommerce' ) );
}
wp_redirect( $redirect_url );
exit();
}
}
wp_redirect( $redirect_url );
exit();
}
}

View File

@ -1,777 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Simplify Commerce Gateway.
*
* @class WC_Gateway_Simplify_Commerce
* @extends WC_Payment_Gateway_CC
* @since 2.2.0
* @version 1.0.0
* @package WooCommerce/Classes/Payment
* @author WooThemes
*/
class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway_CC {
/**
* Constructor.
*/
public function __construct() {
$this->id = 'simplify_commerce';
$this->method_title = __( 'Simplify Commerce', 'woocommerce' );
$this->method_description = __( 'Take payments via Simplify Commerce - uses simplify.js to create card tokens and the Simplify Commerce SDK. Requires SSL when sandbox is disabled.', 'woocommerce' );
$this->new_method_label = __( 'Use a new card', 'woocommerce' );
$this->has_fields = true;
$this->supports = array(
'subscriptions',
'products',
'subscription_cancellation',
'subscription_reactivation',
'subscription_suspension',
'subscription_amount_changes',
'subscription_payment_method_change', // Subscriptions 1.n compatibility
'subscription_payment_method_change_customer',
'subscription_payment_method_change_admin',
'subscription_date_changes',
'multiple_subscriptions',
'default_credit_card_form',
'tokenization',
'refunds',
'pre-orders',
);
$this->view_transaction_url = 'https://www.simplify.com/commerce/app#/payment/%s';
// Load the form fields
$this->init_form_fields();
// Load the settings.
$this->init_settings();
// Get setting values
$this->title = $this->get_option( 'title' );
$this->description = $this->get_option( 'description' );
$this->enabled = $this->get_option( 'enabled' );
$this->mode = $this->get_option( 'mode', 'standard' );
$this->modal_color = $this->get_option( 'modal_color', '#a46497' );
$this->sandbox = $this->get_option( 'sandbox' );
$this->public_key = ( 'no' === $this->sandbox ) ? $this->get_option( 'public_key' ) : $this->get_option( 'sandbox_public_key' );
$this->private_key = ( 'no' === $this->sandbox ) ? $this->get_option( 'private_key' ) : $this->get_option( 'sandbox_private_key' );
$this->init_simplify_sdk();
// Hooks
add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
add_action( 'woocommerce_receipt_' . $this->id, array( $this, 'receipt_page' ) );
add_action( 'woocommerce_api_wc_gateway_simplify_commerce', array( $this, 'return_handler' ) );
}
/**
* Init Simplify SDK.
*/
protected function init_simplify_sdk() {
// Include lib
require_once dirname( __FILE__ ) . '/includes/Simplify.php';
Simplify::$publicKey = $this->public_key;
Simplify::$privateKey = $this->private_key;
Simplify::$userAgent = 'WooCommerce/' . WC()->version;
}
/**
* Admin Panel Options.
* - Options for bits like 'title' and availability on a country-by-country basis.
*/
public function admin_options() {
?>
<h3><?php _e( 'Simplify Commerce by MasterCard', 'woocommerce' ); ?></h3>
<?php if ( empty( $this->public_key ) ) : ?>
<div class="simplify-commerce-banner updated">
<img src="<?php echo WC()->plugin_url() . '/includes/gateways/simplify-commerce/assets/images/logo.png'; ?>" />
<p class="main"><strong><?php _e( 'Getting started', 'woocommerce' ); ?></strong></p>
<p><?php _e( 'Simplify Commerce is your merchant account and payment gateway all rolled into one. Choose Simplify Commerce as your WooCommerce payment gateway to get access to your money quickly with a powerful, secure payment engine backed by MasterCard.', 'woocommerce' ); ?></p>
<p><a href="https://www.simplify.com/commerce/partners/woocommerce#/signup" target="_blank" class="button button-primary"><?php _e( 'Sign up for Simplify Commerce', 'woocommerce' ); ?></a> <a href="https://www.simplify.com/commerce/partners/woocommerce#/" target="_blank" class="button"><?php _e( 'Learn more', 'woocommerce' ); ?></a></p>
</div>
<?php else : ?>
<p><?php _e( 'Simplify Commerce is your merchant account and payment gateway all rolled into one. Choose Simplify Commerce as your WooCommerce payment gateway to get access to your money quickly with a powerful, secure payment engine backed by MasterCard.', 'woocommerce' ); ?></p>
<?php endif; ?>
<?php $this->checks(); ?>
<table class="form-table">
<?php $this->generate_settings_html(); ?>
<script type="text/javascript">
jQuery( '#woocommerce_simplify_commerce_sandbox' ).on( 'change', function() {
var sandbox = jQuery( '#woocommerce_simplify_commerce_sandbox_public_key, #woocommerce_simplify_commerce_sandbox_private_key' ).closest( 'tr' ),
production = jQuery( '#woocommerce_simplify_commerce_public_key, #woocommerce_simplify_commerce_private_key' ).closest( 'tr' );
if ( jQuery( this ).is( ':checked' ) ) {
sandbox.show();
production.hide();
} else {
sandbox.hide();
production.show();
}
}).change();
jQuery( '#woocommerce_simplify_commerce_mode' ).on( 'change', function() {
var color = jQuery( '#woocommerce_simplify_commerce_modal_color' ).closest( 'tr' );
if ( 'standard' === jQuery( this ).val() ) {
color.hide();
} else {
color.show();
}
}).change();
</script>
</table>
<?php
}
/**
* Check if SSL is enabled and notify the user.
*/
public function checks() {
if ( 'no' == $this->enabled ) {
return;
}
if ( version_compare( phpversion(), '5.3', '<' ) ) {
// PHP Version
echo '<div class="error"><p>' . sprintf( __( 'Simplify Commerce Error: Simplify commerce requires PHP 5.3 and above. You are using version %s.', 'woocommerce' ), phpversion() ) . '</p></div>';
} elseif ( ! $this->public_key || ! $this->private_key ) {
// Check required fields
echo '<div class="error"><p>' . __( 'Simplify Commerce Error: Please enter your public and private keys', 'woocommerce' ) . '</p></div>';
} elseif ( 'standard' == $this->mode && ! wc_checkout_is_https() ) {
// Show message when using standard mode and no SSL on the checkout page
echo '<div class="error"><p>' . sprintf( __( 'Simplify Commerce is enabled, but the <a href="%s">force SSL option</a> is disabled; your checkout may not be secure! Please enable SSL and ensure your server has a valid SSL certificate - Simplify Commerce will only work in sandbox mode.', 'woocommerce' ), admin_url( 'admin.php?page=wc-settings&tab=checkout' ) ) . '</p></div>';
}
}
/**
* Check if this gateway is enabled.
*
* @return bool
*/
public function is_available() {
if ( 'yes' !== $this->enabled ) {
return false;
}
if ( 'standard' === $this->mode && 'yes' !== $this->sandbox && ! wc_checkout_is_https() ) {
return false;
}
if ( ! $this->public_key || ! $this->private_key ) {
return false;
}
return true;
}
/**
* Initialise Gateway Settings Form Fields.
*/
public function init_form_fields() {
$this->form_fields = array(
'enabled' => array(
'title' => __( 'Enable/Disable', 'woocommerce' ),
'label' => __( 'Enable Simplify Commerce', 'woocommerce' ),
'type' => 'checkbox',
'description' => '',
'default' => 'no',
),
'title' => array(
'title' => __( 'Title', 'woocommerce' ),
'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
'default' => __( 'Credit card', 'woocommerce' ),
'desc_tip' => true,
),
'description' => array(
'title' => __( 'Description', 'woocommerce' ),
'type' => 'text',
'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce' ),
'default' => 'Pay with your credit card via Simplify Commerce by MasterCard.',
'desc_tip' => true,
),
'mode' => array(
'title' => __( 'Payment mode', 'woocommerce' ),
'label' => __( 'Enable Hosted Payments', 'woocommerce' ),
'type' => 'select',
'description' => sprintf( __( 'Standard will display the credit card fields on your store (SSL required). %1$s Hosted Payments will display a Simplify Commerce modal dialog on your store (if SSL) or will redirect the customer to Simplify Commerce hosted page (if not SSL). %1$s Note: Hosted Payments need a new API Key pair with the hosted payments flag selected. %2$sFor more details check the Simplify Commerce docs%3$s.', 'woocommerce' ), '<br />', '<a href="https://simplify.desk.com/customer/portal/articles/1792405-how-do-i-enable-hosted-payments" target="_blank">', '</a>' ),
'default' => 'standard',
'options' => array(
'standard' => __( 'Standard', 'woocommerce' ),
'hosted' => __( 'Hosted Payments', 'woocommerce' ),
),
),
'modal_color' => array(
'title' => __( 'Modal color', 'woocommerce' ),
'type' => 'color',
'description' => __( 'Set the color of the buttons and titles on the modal dialog.', 'woocommerce' ),
'default' => '#a46497',
'desc_tip' => true,
),
'sandbox' => array(
'title' => __( 'Sandbox', 'woocommerce' ),
'label' => __( 'Enable sandbox mode', 'woocommerce' ),
'type' => 'checkbox',
'description' => __( 'Place the payment gateway in sandbox mode using sandbox API keys (real payments will not be taken).', 'woocommerce' ),
'default' => 'yes',
),
'sandbox_public_key' => array(
'title' => __( 'Sandbox public key', 'woocommerce' ),
'type' => 'text',
'description' => __( 'Get your API keys from your Simplify account: Settings > API Keys.', 'woocommerce' ),
'default' => '',
'desc_tip' => true,
),
'sandbox_private_key' => array(
'title' => __( 'Sandbox private key', 'woocommerce' ),
'type' => 'text',
'description' => __( 'Get your API keys from your Simplify account: Settings > API Keys.', 'woocommerce' ),
'default' => '',
'desc_tip' => true,
),
'public_key' => array(
'title' => __( 'Public key', 'woocommerce' ),
'type' => 'text',
'description' => __( 'Get your API keys from your Simplify account: Settings > API Keys.', 'woocommerce' ),
'default' => '',
'desc_tip' => true,
),
'private_key' => array(
'title' => __( 'Private key', 'woocommerce' ),
'type' => 'text',
'description' => __( 'Get your API keys from your Simplify account: Settings > API Keys.', 'woocommerce' ),
'default' => '',
'desc_tip' => true,
),
);
}
/**
* Payment form on checkout page.
*/
public function payment_fields() {
$description = $this->get_description();
if ( 'yes' == $this->sandbox ) {
$description .= ' ' . sprintf( __( 'TEST MODE ENABLED. Use a test card: %s', 'woocommerce' ), '<a href="https://www.simplify.com/commerce/docs/tutorial/index#testing">https://www.simplify.com/commerce/docs/tutorial/index#testing</a>' );
}
if ( $description ) {
echo wpautop( wptexturize( trim( $description ) ) );
}
if ( 'standard' == $this->mode ) {
parent::payment_fields();
}
}
/**
* Outputs scripts used for simplify payment.
*/
public function payment_scripts() {
$load_scripts = false;
if ( is_checkout() ) {
$load_scripts = true;
}
if ( $this->is_available() ) {
$load_scripts = true;
}
if ( false === $load_scripts ) {
return;
}
wp_enqueue_script( 'simplify-commerce', 'https://www.simplify.com/commerce/v1/simplify.js', array( 'jquery' ), WC_VERSION, true );
wp_enqueue_script( 'wc-simplify-commerce', WC()->plugin_url() . '/includes/gateways/simplify-commerce/assets/js/simplify-commerce.js', array( 'simplify-commerce', 'wc-credit-card-form' ), WC_VERSION, true );
wp_localize_script(
'wc-simplify-commerce', 'Simplify_commerce_params', array(
'key' => $this->public_key,
'card.number' => __( 'Card number', 'woocommerce' ),
'card.expMonth' => __( 'Expiry month', 'woocommerce' ),
'card.expYear' => __( 'Expiry year', 'woocommerce' ),
'is_invalid' => __( 'is invalid', 'woocommerce' ),
'mode' => $this->mode,
'is_ssl' => is_ssl(),
)
);
}
public function add_payment_method() {
if ( empty( $_POST['simplify_token'] ) ) {
wc_add_notice( __( 'There was a problem adding this card.', 'woocommerce' ), 'error' );
return;
}
$cart_token = wc_clean( $_POST['simplify_token'] );
$customer_token = $this->get_users_token();
$current_user = wp_get_current_user();
$customer_info = array(
'email' => $current_user->user_email,
'name' => $current_user->display_name,
);
$token = $this->save_token( $customer_token, $cart_token, $customer_info );
if ( is_null( $token ) ) {
wc_add_notice( __( 'There was a problem adding this card.', 'woocommerce' ), 'error' );
return;
}
return array(
'result' => 'success',
'redirect' => wc_get_endpoint_url( 'payment-methods' ),
);
}
/**
* Actually saves a customer token to the database.
*
* @param WC_Payment_Token $customer_token Payment Token
* @param string $cart_token CC Token
* @param array $customer_info 'email', 'name'
*
* @return null|WC_Payment_Token|WC_Payment_Token_CC
*/
public function save_token( $customer_token, $cart_token, $customer_info ) {
if ( ! is_null( $customer_token ) ) {
$customer = Simplify_Customer::findCustomer( $customer_token->get_token() );
$updates = array( 'token' => $cart_token );
$customer->setAll( $updates );
$customer->updateCustomer();
$customer = Simplify_Customer::findCustomer( $customer_token->get_token() ); // get updated customer with new set card
$token = $customer_token;
} else {
$customer = Simplify_Customer::createCustomer(
array(
'token' => $cart_token,
'email' => $customer_info['email'],
'name' => $customer_info['name'],
)
);
$token = new WC_Payment_Token_CC();
$token->set_token( $customer->id );
}
// If we were able to create an save our card, save the data on our side too
if ( is_object( $customer ) && '' != $customer->id ) {
$customer_properties = $customer->getProperties();
$card = $customer_properties['card'];
$token->set_gateway_id( $this->id );
$token->set_card_type( strtolower( $card->type ) );
$token->set_last4( $card->last4 );
$expiry_month = ( 1 === strlen( $card->expMonth ) ? '0' . $card->expMonth : $card->expMonth );
$token->set_expiry_month( $expiry_month );
$token->set_expiry_year( '20' . $card->expYear );
if ( is_user_logged_in() ) {
$token->set_user_id( get_current_user_id() );
}
$token->save();
return $token;
}
return null;
}
/**
* Process customer: updating or creating a new customer/saved CC
*
* @param WC_Order $order Order object
* @param WC_Payment_Token $customer_token Payment Token
* @param string $cart_token CC Token
*/
protected function process_customer( $order, $customer_token = null, $cart_token = '' ) {
// Are we saving a new payment method?
if ( is_user_logged_in() && isset( $_POST['wc-simplify_commerce-new-payment-method'] ) && true === (bool) $_POST['wc-simplify_commerce-new-payment-method'] ) {
$customer_info = array(
'email' => $order->get_billing_email(),
'name' => trim( $order->get_formatted_billing_full_name() ),
);
$token = $this->save_token( $customer_token, $cart_token, $customer_info );
if ( ! is_null( $token ) ) {
$order->add_payment_token( $token );
}
}
}
/**
* Process standard payments.
*
* @param WC_Order $order
* @param string $cart_token
* @param string $customer_token
*
* @return array
* @uses Simplify_ApiException
* @uses Simplify_BadRequestException
*/
protected function process_standard_payments( $order, $cart_token = '', $customer_token = '' ) {
try {
if ( empty( $cart_token ) && empty( $customer_token ) ) {
$error_msg = __( 'Please make sure your card details have been entered correctly and that your browser supports JavaScript.', 'woocommerce' );
if ( 'yes' == $this->sandbox ) {
$error_msg .= ' ' . __( 'Developers: Please make sure that you are including jQuery and there are no JavaScript errors on the page.', 'woocommerce' );
}
throw new Simplify_ApiException( $error_msg );
}
// We need to figure out if we want to charge the card token (new unsaved token, no customer, etc)
// or the customer token (just saved method, previously saved method)
$pass_tokens = array();
if ( ! empty( $cart_token ) ) {
$pass_tokens['token'] = $cart_token;
}
if ( ! empty( $customer_token ) ) {
$pass_tokens['customer'] = $customer_token;
// Use the customer token only, since we already saved the (one time use) card token to the customer
if ( isset( $_POST['wc-simplify_commerce-new-payment-method'] ) && true === (bool) $_POST['wc-simplify_commerce-new-payment-method'] ) {
unset( $pass_tokens['token'] );
}
}
// Did we create an account and save a payment method? We might need to use the customer token instead of the card token
if ( isset( $_POST['createaccount'] ) && true === (bool) $_POST['createaccount'] && empty( $customer_token ) ) {
$user_token = $this->get_users_token();
if ( ! is_null( $user_token ) ) {
$pass_tokens['customer'] = $user_token->get_token();
unset( $pass_tokens['token'] );
}
}
$payment_response = $this->do_payment( $order, $order->get_total(), $pass_tokens );
if ( is_wp_error( $payment_response ) ) {
throw new Simplify_ApiException( $payment_response->get_error_message() );
} else {
// Remove cart
WC()->cart->empty_cart();
// Return thank you page redirect
return array(
'result' => 'success',
'redirect' => $this->get_return_url( $order ),
);
}
} catch ( Simplify_ApiException $e ) {
if ( $e instanceof Simplify_BadRequestException && $e->hasFieldErrors() && $e->getFieldErrors() ) {
foreach ( $e->getFieldErrors() as $error ) {
wc_add_notice( $error->getFieldName() . ': "' . $error->getMessage() . '" (' . $error->getErrorCode() . ')', 'error' );
}
} else {
wc_add_notice( $e->getMessage(), 'error' );
}
return array(
'result' => 'fail',
'redirect' => '',
);
}
}
/**
* do payment function.
*
* @param WC_order $order
* @param int $amount (default: 0)
* @param array $token
*
* @return bool|WP_Error
* @uses Simplify_BadRequestException
*/
public function do_payment( $order, $amount = 0, $token = array() ) {
if ( $amount * 100 < 50 ) {
return new WP_Error( 'simplify_error', __( 'Sorry, the minimum allowed order total is 0.50 to use this payment method.', 'woocommerce' ) );
}
try {
// Charge the customer
$data = array(
'amount' => $amount * 100, // In cents.
'description' => sprintf( __( '%1$s - Order #%2$s', 'woocommerce' ), esc_html( get_bloginfo( 'name', 'display' ) ), $order->get_order_number() ),
'currency' => strtoupper( get_woocommerce_currency() ),
'reference' => $order->get_id(),
);
$data = array_merge( $data, $token );
$payment = Simplify_Payment::createPayment( $data );
} catch ( Exception $e ) {
$error_message = $e->getMessage();
if ( $e instanceof Simplify_BadRequestException && $e->hasFieldErrors() && $e->getFieldErrors() ) {
$error_message = '';
foreach ( $e->getFieldErrors() as $error ) {
$error_message .= ' ' . $error->getFieldName() . ': "' . $error->getMessage() . '" (' . $error->getErrorCode() . ')';
}
}
$order->add_order_note( sprintf( __( 'Simplify payment error: %s.', 'woocommerce' ), $error_message ) );
return new WP_Error( 'simplify_payment_declined', $e->getMessage(), array( 'status' => $e->getCode() ) );
}
if ( 'APPROVED' == $payment->paymentStatus ) {
// Payment complete
$order->payment_complete( $payment->id );
// Add order note
$order->add_order_note( sprintf( __( 'Simplify payment approved (ID: %1$s, Auth Code: %2$s)', 'woocommerce' ), $payment->id, $payment->authCode ) );
return true;
} else {
$order->add_order_note( __( 'Simplify payment declined', 'woocommerce' ) );
return new WP_Error( 'simplify_payment_declined', __( 'Payment was declined - please try another card.', 'woocommerce' ) );
}
}
/**
* Process standard payments.
*
* @param WC_Order $order
* @return array
*/
protected function process_hosted_payments( $order ) {
return array(
'result' => 'success',
'redirect' => $order->get_checkout_payment_url( true ),
);
}
protected function get_users_token() {
$customer_token = null;
if ( is_user_logged_in() ) {
$tokens = WC_Payment_Tokens::get_customer_tokens( get_current_user_id() );
foreach ( $tokens as $token ) {
if ( $token->get_gateway_id() === $this->id ) {
$customer_token = $token;
break;
}
}
}
return $customer_token;
}
/**
* Process the payment.
*
* @param int $order_id
*
* @return array|void
*/
public function process_payment( $order_id ) {
$order = wc_get_order( $order_id );
// Payment/CC form is hosted on Simplify
if ( 'hosted' === $this->mode ) {
return $this->process_hosted_payments( $order );
}
// New CC info was entered
if ( isset( $_POST['simplify_token'] ) ) {
$cart_token = wc_clean( $_POST['simplify_token'] );
$customer_token = $this->get_users_token();
$customer_token_value = ( ! is_null( $customer_token ) ? $customer_token->get_token() : '' );
$this->process_customer( $order, $customer_token, $cart_token );
return $this->process_standard_payments( $order, $cart_token, $customer_token_value );
}
// Possibly Create (or update) customer/save payment token, use an existing token, and then process the payment
if ( isset( $_POST['wc-simplify_commerce-payment-token'] ) && 'new' !== $_POST['wc-simplify_commerce-payment-token'] ) {
$token_id = wc_clean( $_POST['wc-simplify_commerce-payment-token'] );
$token = WC_Payment_Tokens::get( $token_id );
if ( $token->get_user_id() !== get_current_user_id() ) {
wc_add_notice( __( 'Please make sure your card details have been entered correctly and that your browser supports JavaScript.', 'woocommerce' ), 'error' );
return;
}
$this->process_customer( $order, $token );
return $this->process_standard_payments( $order, '', $token->get_token() );
}
}
/**
* Hosted payment args.
*
* @param WC_Order $order
*
* @return array
*/
protected function get_hosted_payments_args( $order ) {
$args = apply_filters(
'woocommerce_simplify_commerce_hosted_args', array(
'sc-key' => $this->public_key,
'amount' => $order->get_total() * 100,
'reference' => $order->get_id(),
'name' => esc_html( get_bloginfo( 'name', 'display' ) ),
'description' => sprintf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ),
'receipt' => 'false',
'color' => $this->modal_color,
'redirect-url' => WC()->api_request_url( 'WC_Gateway_Simplify_Commerce' ),
'address' => $order->get_billing_address_1() . ' ' . $order->get_billing_address_2(),
'address-city' => $order->get_billing_city(),
'address-state' => $order->get_billing_state(),
'address-zip' => $order->get_billing_postcode(),
'address-country' => $order->get_billing_country(),
'operation' => 'create.token',
), $order->get_id()
);
return $args;
}
/**
* Receipt page.
*
* @param int $order_id
*/
public function receipt_page( $order_id ) {
$order = wc_get_order( $order_id );
echo '<p>' . __( 'Thank you for your order, please click the button below to pay with credit card using Simplify Commerce by MasterCard.', 'woocommerce' ) . '</p>';
$args = $this->get_hosted_payments_args( $order );
$button_args = array();
foreach ( $args as $key => $value ) {
$button_args[] = 'data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
}
echo '<script type="text/javascript" src="https://www.simplify.com/commerce/simplify.pay.js"></script>
<button class="button alt" id="simplify-payment-button" ' . implode( ' ', $button_args ) . '>' . __( 'Pay now', 'woocommerce' ) . '</button> <a class="button cancel" href="' . esc_url( $order->get_cancel_order_url() ) . '">' . __( 'Cancel order &amp; restore cart', 'woocommerce' ) . '</a>
';
}
/**
* Return handler for Hosted Payments.
*/
public function return_handler() {
@ob_clean();
header( 'HTTP/1.1 200 OK' );
if ( isset( $_REQUEST['reference'] ) && isset( $_REQUEST['paymentId'] ) && isset( $_REQUEST['signature'] ) ) {
$signature = strtoupper( md5( $_REQUEST['amount'] . $_REQUEST['reference'] . $_REQUEST['paymentId'] . $_REQUEST['paymentDate'] . $_REQUEST['paymentStatus'] . $this->private_key ) );
$order_id = absint( $_REQUEST['reference'] );
$order = wc_get_order( $order_id );
if ( hash_equals( $signature, $_REQUEST['signature'] ) ) {
$order_complete = $this->process_order_status( $order, $_REQUEST['paymentId'], $_REQUEST['paymentStatus'], $_REQUEST['paymentDate'] );
if ( ! $order_complete ) {
$order->update_status( 'failed', __( 'Payment was declined by Simplify Commerce.', 'woocommerce' ) );
}
wp_redirect( $this->get_return_url( $order ) );
exit();
}
}
wp_redirect( wc_get_page_permalink( 'cart' ) );
exit();
}
/**
* Process the order status.
*
* @param WC_Order $order
* @param string $payment_id
* @param string $status
* @param string $auth_code
*
* @return bool
*/
public function process_order_status( $order, $payment_id, $status, $auth_code ) {
if ( 'APPROVED' == $status ) {
// Payment complete
$order->payment_complete( $payment_id );
// Add order note
$order->add_order_note( sprintf( __( 'Simplify payment approved (ID: %1$s, Auth Code: %2$s)', 'woocommerce' ), $payment_id, $auth_code ) );
// Remove cart
WC()->cart->empty_cart();
return true;
}
return false;
}
/**
* Process refunds.
* WooCommerce 2.2 or later.
*
* @param int $order_id
* @param float $amount
* @param string $reason
* @uses Simplify_ApiException
* @uses Simplify_BadRequestException
* @return bool|WP_Error
*/
public function process_refund( $order_id, $amount = null, $reason = '' ) {
try {
$payment_id = get_post_meta( $order_id, '_transaction_id', true );
$refund = Simplify_Refund::createRefund(
array(
'amount' => $amount * 100, // In cents.
'payment' => $payment_id,
'reason' => $reason,
'reference' => $order_id,
)
);
if ( 'APPROVED' == $refund->paymentStatus ) {
return true;
} else {
throw new Simplify_ApiException( __( 'Refund was declined.', 'woocommerce' ) );
}
} catch ( Simplify_ApiException $e ) {
if ( $e instanceof Simplify_BadRequestException && $e->hasFieldErrors() && $e->getFieldErrors() ) {
foreach ( $e->getFieldErrors() as $error ) {
return new WP_Error( 'simplify_refund_error', $error->getFieldName() . ': "' . $error->getMessage() . '" (' . $error->getErrorCode() . ')' );
}
} else {
return new WP_Error( 'simplify_refund_error', $e->getMessage() );
}
}
return false;
}
/**
* Get gateway icon.
*
* @access public
* @return string
*/
public function get_icon() {
$icon = '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/visa.svg' ) . '" alt="Visa" width="32" />';
$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/mastercard.svg' ) . '" alt="MasterCard" width="32" />';
$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/discover.svg' ) . '" alt="Discover" width="32" />';
$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/amex.svg' ) . '" alt="Amex" width="32" />';
$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/jcb.svg' ) . '" alt="JCB" width="32" />';
return apply_filters( 'woocommerce_gateway_icon', $icon, $this->id );
}
}

View File

@ -1,88 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
// @codingStandardsIgnoreFile
require_once(dirname(__FILE__) . '/Simplify/Constants.php');
class Simplify
{
/**
* @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 $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 $userAgent User-agent string send with requests.
*/
public static $userAgent = null;
}
require_once(dirname(__FILE__) . '/Simplify/Object.php');
require_once(dirname(__FILE__) . '/Simplify/AccessToken.php');
require_once(dirname(__FILE__) . '/Simplify/Authentication.php');
require_once(dirname(__FILE__) . '/Simplify/PaymentsApi.php');
require_once(dirname(__FILE__) . '/Simplify/Exceptions.php');
require_once(dirname(__FILE__) . '/Simplify/Http.php');
require_once(dirname(__FILE__) . '/Simplify/ResourceList.php');
require_once(dirname(__FILE__) . '/Simplify/Authorization.php');
require_once(dirname(__FILE__) . '/Simplify/CardToken.php');
require_once(dirname(__FILE__) . '/Simplify/Chargeback.php');
require_once(dirname(__FILE__) . '/Simplify/Coupon.php');
require_once(dirname(__FILE__) . '/Simplify/Customer.php');
require_once(dirname(__FILE__) . '/Simplify/Deposit.php');
require_once(dirname(__FILE__) . '/Simplify/Event.php');
require_once(dirname(__FILE__) . '/Simplify/FraudCheck.php');
require_once(dirname(__FILE__) . '/Simplify/Invoice.php');
require_once(dirname(__FILE__) . '/Simplify/InvoiceItem.php');
require_once(dirname(__FILE__) . '/Simplify/Tax.php');
require_once(dirname(__FILE__) . '/Simplify/Payment.php');
require_once(dirname(__FILE__) . '/Simplify/Plan.php');
require_once(dirname(__FILE__) . '/Simplify/Refund.php');
require_once(dirname(__FILE__) . '/Simplify/Subscription.php');
require_once(dirname(__FILE__) . '/Simplify/TransactionReview.php');
require_once(dirname(__FILE__) . '/Simplify/Webhook.php');

View File

@ -1,127 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
/**
* AccessToken - used to manage OAuth access tokens
*/
class Simplify_AccessToken extends Simplify_Object {
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) {
$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);
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) {
$args = func_get_args();
$refresh_token = $this->refresh_token;
if (empty($refresh_token)){
throw new InvalidArgumentException('Cannot refresh access token; refresh token is invalid');
}
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
$props = 'refresh_token='.$refresh_token.'&grant_type=refresh_token';
$resp = Simplify_AccessToken::sendRequest($props, "token", $authentication);
$this->setAll($resp);
return $this;
}
/**
* <p>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) {
$args = func_get_args();
$access_token = $this->access_token;
if (empty($access_token)){
throw new InvalidArgumentException('Cannot revoke access token; access token is invalid');
}
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$props = 'token='.$access_token.'';
Simplify_AccessToken::sendRequest($props, "revoke", $authentication);
$this->access_token = null;
$this->refresh_token = null;
$this->redirect_uri = null;
return $this;
}
private static function sendRequest($props, $context, $authentication){
$url = Simplify_Constants::OAUTH_BASE_URL.'/'.$context;
$http = new Simplify_HTTP();
$resp = $http->oauthRequest($url, $props, $authentication);
return $resp;
}
/**
* @ignore
*/
static public function getClazz() {
return "AccessToken";
}
}

View File

@ -1,74 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
/**
* Simplify_Authentication - encapsulates the credentials needed to make a request to the Simplify API.
*
* @var $publicKey - this is your API public key
* @var $privateKey - this is your API private key
* @var $accessToken - Oauth access token that is needed to make API requests on behalf of another user
*/
class Simplify_Authentication {
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 __construct1($accessToken) {
$this->accessToken = $accessToken;
}
function __construct2($publicKey, $privateKey) {
$this->publicKey = $publicKey;
$this->privateKey = $privateKey;
}
function __construct3($publicKey, $privateKey, $accessToken) {
$this->publicKey = $publicKey;
$this->privateKey = $privateKey;
$this->accessToken = $accessToken;
}
}

View File

@ -1,142 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
class Simplify_Authorization extends Simplify_Object {
/**
* Creates an Simplify_Authorization object
* @param array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;">
* <dt><tt>amount</tt></dt> <dd>Amount of the payment (in the smallest unit of your currency). Example: 100 = $1.00USD <strong>required </strong></dd>
* <dt><tt>card.addressCity</tt></dt> <dd>City of the cardholder. [max length: 50, min length: 2] </dd>
* <dt><tt>card.addressCountry</tt></dt> <dd>Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2] </dd>
* <dt><tt>card.addressLine1</tt></dt> <dd>Address of the cardholder. [max length: 255] </dd>
* <dt><tt>card.addressLine2</tt></dt> <dd>Address of the cardholder if needed. [max length: 255] </dd>
* <dt><tt>card.addressState</tt></dt> <dd>State of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, min length: 2] </dd>
* <dt><tt>card.addressZip</tt></dt> <dd>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] </dd>
* <dt><tt>card.cvc</tt></dt> <dd>CVC security code of the card. This is the code on the back of the card. Example: 123 </dd>
* <dt><tt>card.expMonth</tt></dt> <dd>Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] <strong>required </strong></dd>
* <dt><tt>card.expYear</tt></dt> <dd>Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] <strong>required </strong></dd>
* <dt><tt>card.name</tt></dt> <dd>Name as it appears on the card. [max length: 50, min length: 2] </dd>
* <dt><tt>card.number</tt></dt> <dd>Card number as it appears on the card. [max length: 19, min length: 13] <strong>required </strong></dd>
* <dt><tt>currency</tt></dt> <dd>Currency code (ISO-4217) for the transaction. Must match the currency associated with your account. [default: USD] <strong>required </strong></dd>
* <dt><tt>customer</tt></dt> <dd>ID of customer. If specified, card on file of customer will be used. </dd>
* <dt><tt>description</tt></dt> <dd>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] </dd>
* <dt><tt>reference</tt></dt> <dd>Custom reference field to be used with outside systems. </dd>
* <dt><tt>replayId</tt></dt> <dd>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] </dd>
* <dt><tt>statementDescription.name</tt></dt> <dd>Merchant name <strong>required </strong></dd>
* <dt><tt>statementDescription.phoneNumber</tt></dt> <dd>Merchant contact phone number. </dd>
* <dt><tt>token</tt></dt> <dd>If specified, card associated with card token will be used. [max length: 255] </dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.<i/>
* @return Authorization a Authorization object.
*/
static public function createAuthorization($hash, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$instance = new Simplify_Authorization();
$instance->setAll($hash);
$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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
*
* @return true
*/
public function deleteAuthorization($authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
$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:<dl style="padding-left:10px;">
* <dt><tt>filter</tt></dt> <dd>Filters to apply to the list. </dd>
* <dt><tt>max</tt></dt> <dd>Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] </dd>
* <dt><tt>offset</tt></dt> <dd>Used in pagination of the list. This is the start offset of the page. [min value: 0, default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> dateCreated</tt><tt> amount</tt><tt> id</tt><tt> description</tt><tt> paymentDate</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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);
$val = new Simplify_Authorization();
$list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication);
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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return Authorization a Authorization object
*/
static public function findAuthorization($id, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$val = new Simplify_Authorization();
$val->id = $id;
$obj = Simplify_PaymentsApi::findObject($val, $authentication);
return $obj;
}
/**
* @ignore
*/
public function getClazz() {
return "Authorization";
}
}

View File

@ -1,94 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
class Simplify_CardToken extends Simplify_Object {
/**
* Creates an Simplify_CardToken object
* @param array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;">
* <dt><tt>callback</tt></dt> <dd>The URL callback for the cardtoken </dd>
* <dt><tt>card.addressCity</tt></dt> <dd>City of the cardholder. [max length: 50, min length: 2] </dd>
* <dt><tt>card.addressCountry</tt></dt> <dd>Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2] </dd>
* <dt><tt>card.addressLine1</tt></dt> <dd>Address of the cardholder. [max length: 255] </dd>
* <dt><tt>card.addressLine2</tt></dt> <dd>Address of the cardholder if needed. [max length: 255] </dd>
* <dt><tt>card.addressState</tt></dt> <dd>State of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, min length: 2] </dd>
* <dt><tt>card.addressZip</tt></dt> <dd>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] </dd>
* <dt><tt>card.cvc</tt></dt> <dd>CVC security code of the card. This is the code on the back of the card. Example: 123 </dd>
* <dt><tt>card.expMonth</tt></dt> <dd>Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] <strong>required </strong></dd>
* <dt><tt>card.expYear</tt></dt> <dd>Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] <strong>required </strong></dd>
* <dt><tt>card.name</tt></dt> <dd>Name as appears on the card. [max length: 50, min length: 2] </dd>
* <dt><tt>card.number</tt></dt> <dd>Card number as it appears on the card. [max length: 19, min length: 13] <strong>required </strong></dd>
* <dt><tt>key</tt></dt> <dd>Key used to create the card token. </dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.<i/>
* @return CardToken a CardToken object.
*/
static public function createCardToken($hash, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$instance = new Simplify_CardToken();
$instance->setAll($hash);
$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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return CardToken a CardToken object
*/
static public function findCardToken($id, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$val = new Simplify_CardToken();
$val->id = $id;
$obj = Simplify_PaymentsApi::findObject($val, $authentication);
return $obj;
}
/**
* @ignore
*/
public function getClazz() {
return "CardToken";
}
}

View File

@ -1,86 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
class Simplify_Chargeback extends Simplify_Object {
/**
* Retrieve Simplify_Chargeback objects.
* @param array criteria a map of parameters; valid keys are:<dl style="padding-left:10px;">
* <dt><tt>filter</tt></dt> <dd>Filters to apply to the list. </dd>
* <dt><tt>max</tt></dt> <dd>Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] </dd>
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> id</tt><tt> amount</tt><tt> description</tt><tt> dateCreated</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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);
$val = new Simplify_Chargeback();
$list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication);
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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return Chargeback a Chargeback object
*/
static public function findChargeback($id, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$val = new Simplify_Chargeback();
$val->id = $id;
$obj = Simplify_PaymentsApi::findObject($val, $authentication);
return $obj;
}
/**
* @ignore
*/
public function getClazz() {
return "Chargeback";
}
}

View File

@ -1,58 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
/**
* Constant values.
*/
class Simplify_Constants
{
/**
* @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_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 endpoint
*/
const OAUTH_BASE_URL = 'https://www.simplify.com/commerce/oauth';
}

View File

@ -1,151 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
class Simplify_Coupon extends Simplify_Object {
/**
* Creates an Simplify_Coupon object
* @param array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;">
* <dt><tt>amountOff</tt></dt> <dd>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] </dd>
* <dt><tt>couponCode</tt></dt> <dd>Code that identifies the coupon to be used. [min length: 2] <strong>required </strong></dd>
* <dt><tt>description</tt></dt> <dd>A brief section that describes the coupon. </dd>
* <dt><tt>durationInMonths</tt></dt> <dd>DEPRECATED - Duration in months that the coupon will be applied after it has first been selected. [min value: 1, max value: 9999] </dd>
* <dt><tt>endDate</tt></dt> <dd>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. </dd>
* <dt><tt>maxRedemptions</tt></dt> <dd>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] </dd>
* <dt><tt>numTimesApplied</tt></dt> <dd>The number of times a coupon will be applied on a customer's subscription. [min value: 1, max value: 9999] </dd>
* <dt><tt>percentOff</tt></dt> <dd>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] </dd>
* <dt><tt>startDate</tt></dt> <dd>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. <strong>required </strong></dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.<i/>
* @return Coupon a Coupon object.
*/
static public function createCoupon($hash, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$instance = new Simplify_Coupon();
$instance->setAll($hash);
$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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
*
* @return true
*/
public function deleteCoupon($authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
$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:<dl style="padding-left:10px;">
* <dt><tt>filter</tt></dt> <dd>Filters to apply to the list. </dd>
* <dt><tt>max</tt></dt> <dd>Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] </dd>
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> dateCreated</tt><tt> maxRedemptions</tt><tt> timesRedeemed</tt><tt> id</tt><tt> startDate</tt><tt> endDate</tt><tt> percentOff</tt><tt> couponCode</tt><tt> durationInMonths</tt><tt> numTimesApplied</tt><tt> amountOff</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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);
$val = new Simplify_Coupon();
$list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication);
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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return Coupon a Coupon object
*/
static public function findCoupon($id, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$val = new Simplify_Coupon();
$val->id = $id;
$obj = Simplify_PaymentsApi::findObject($val, $authentication);
return $obj;
}
/**
* Updates an Simplify_Coupon object.
*
* The properties that can be updated:
* <dl style="padding-left:10px;">
* <dt><tt>endDate</tt></dt> <dd>The ending date in UTC millis for the coupon. This must be after the starting date of the coupon. </dd>
* <dt><tt>maxRedemptions</tt></dt> <dd>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] </dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return Coupon a Coupon object.
*/
public function updateCoupon($authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
$object = Simplify_PaymentsApi::updateObject($this, $authentication);
return $object;
}
/**
* @ignore
*/
public function getClazz() {
return "Coupon";
}
}

View File

@ -1,184 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
class Simplify_Customer extends Simplify_Object {
/**
* Creates an Simplify_Customer object
* @param array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;">
* <dt><tt>card.addressCity</tt></dt> <dd>City of the cardholder. <strong>required </strong></dd>
* <dt><tt>card.addressCountry</tt></dt> <dd>Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. <strong>required </strong></dd>
* <dt><tt>card.addressLine1</tt></dt> <dd>Address of the cardholder <strong>required </strong></dd>
* <dt><tt>card.addressLine2</tt></dt> <dd>Address of the cardholder if needed. <strong>required </strong></dd>
* <dt><tt>card.addressState</tt></dt> <dd>State of residence of the cardholder. For the US, this is a 2-digit USPS code. <strong>required </strong></dd>
* <dt><tt>card.addressZip</tt></dt> <dd>Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. <strong>required </strong></dd>
* <dt><tt>card.cvc</tt></dt> <dd>CVC security code of the card. This is the code on the back of the card. Example: 123 <strong>required </strong></dd>
* <dt><tt>card.expMonth</tt></dt> <dd>Expiration month of the card. Format is MM. Example: January = 01 <strong>required </strong></dd>
* <dt><tt>card.expYear</tt></dt> <dd>Expiration year of the card. Format is YY. Example: 2013 = 13 <strong>required </strong></dd>
* <dt><tt>card.id</tt></dt> <dd>ID of card. Unused during customer create. </dd>
* <dt><tt>card.name</tt></dt> <dd>Name as appears on the card. <strong>required </strong></dd>
* <dt><tt>card.number</tt></dt> <dd>Card number as it appears on the card. [max length: 19, min length: 13] </dd>
* <dt><tt>email</tt></dt> <dd>Email address of the customer <strong>required </strong></dd>
* <dt><tt>name</tt></dt> <dd>Customer name [min length: 2] <strong>required </strong></dd>
* <dt><tt>reference</tt></dt> <dd>Reference field for external applications use. </dd>
* <dt><tt>subscriptions.amount</tt></dt> <dd>Amount of payment in the smallest unit of your currency. Example: 100 = $1.00USD </dd>
* <dt><tt>subscriptions.billingCycle</tt></dt> <dd>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] </dd>
* <dt><tt>subscriptions.billingCycleLimit</tt></dt> <dd>The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4 </dd>
* <dt><tt>subscriptions.coupon</tt></dt> <dd>Coupon associated with the subscription for the customer. </dd>
* <dt><tt>subscriptions.currency</tt></dt> <dd>Currency code (ISO-4217). Must match the currency associated with your account. [default: USD] </dd>
* <dt><tt>subscriptions.customer</tt></dt> <dd>The customer ID to create the subscription for. Do not supply this when creating a customer. </dd>
* <dt><tt>subscriptions.frequency</tt></dt> <dd>Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY". </dd>
* <dt><tt>subscriptions.frequencyPeriod</tt></dt> <dd>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. </dd>
* <dt><tt>subscriptions.name</tt></dt> <dd>Name describing subscription </dd>
* <dt><tt>subscriptions.plan</tt></dt> <dd>The plan ID that the subscription should be created from. </dd>
* <dt><tt>subscriptions.quantity</tt></dt> <dd>Quantity of the plan for the subscription. [min value: 1] </dd>
* <dt><tt>subscriptions.renewalReminderLeadDays</tt></dt> <dd>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. </dd>
* <dt><tt>token</tt></dt> <dd>If specified, card associated with card token will be used </dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.<i/>
* @return Customer a Customer object.
*/
static public function createCustomer($hash, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$instance = new Simplify_Customer();
$instance->setAll($hash);
$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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
*
* @return true
*/
public function deleteCustomer($authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
$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:<dl style="padding-left:10px;">
* <dt><tt>filter</tt></dt> <dd>Filters to apply to the list. </dd>
* <dt><tt>max</tt></dt> <dd>Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] </dd>
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> dateCreated</tt><tt> id</tt><tt> name</tt><tt> email</tt><tt> reference</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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);
$val = new Simplify_Customer();
$list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication);
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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return Customer a Customer object
*/
static public function findCustomer($id, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$val = new Simplify_Customer();
$val->id = $id;
$obj = Simplify_PaymentsApi::findObject($val, $authentication);
return $obj;
}
/**
* Updates an Simplify_Customer object.
*
* The properties that can be updated:
* <dl style="padding-left:10px;">
* <dt><tt>card.addressCity</tt></dt> <dd>City of the cardholder. <strong>required </strong></dd>
* <dt><tt>card.addressCountry</tt></dt> <dd>Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. <strong>required </strong></dd>
* <dt><tt>card.addressLine1</tt></dt> <dd>Address of the cardholder. <strong>required </strong></dd>
* <dt><tt>card.addressLine2</tt></dt> <dd>Address of the cardholder if needed. <strong>required </strong></dd>
* <dt><tt>card.addressState</tt></dt> <dd>State of residence of the cardholder. For the US, this is a 2-digit USPS code. <strong>required </strong></dd>
* <dt><tt>card.addressZip</tt></dt> <dd>Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. <strong>required </strong></dd>
* <dt><tt>card.cvc</tt></dt> <dd>CVC security code of the card. This is the code on the back of the card. Example: 123 <strong>required </strong></dd>
* <dt><tt>card.expMonth</tt></dt> <dd>Expiration month of the card. Format is MM. Example: January = 01 <strong>required </strong></dd>
* <dt><tt>card.expYear</tt></dt> <dd>Expiration year of the card. Format is YY. Example: 2013 = 13 <strong>required </strong></dd>
* <dt><tt>card.id</tt></dt> <dd>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. </dd>
* <dt><tt>card.name</tt></dt> <dd>Name as appears on the card. <strong>required </strong></dd>
* <dt><tt>card.number</tt></dt> <dd>Card number as it appears on the card. [max length: 19, min length: 13] </dd>
* <dt><tt>email</tt></dt> <dd>Email address of the customer <strong>required </strong></dd>
* <dt><tt>name</tt></dt> <dd>Customer name [min length: 2] <strong>required </strong></dd>
* <dt><tt>reference</tt></dt> <dd>Reference field for external applications use. </dd>
* <dt><tt>token</tt></dt> <dd>If specified, card associated with card token will be added to the customer </dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return Customer a Customer object.
*/
public function updateCustomer($authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
$object = Simplify_PaymentsApi::updateObject($this, $authentication);
return $object;
}
/**
* @ignore
*/
public function getClazz() {
return "Customer";
}
}

View File

@ -1,86 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
class Simplify_Deposit extends Simplify_Object {
/**
* Retrieve Simplify_Deposit objects.
* @param array criteria a map of parameters; valid keys are:<dl style="padding-left:10px;">
* <dt><tt>filter</tt></dt> <dd>Filters to apply to the list. </dd>
* <dt><tt>max</tt></dt> <dd>Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] </dd>
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> amount</tt><tt> dateCreated</tt><tt> depositDate</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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);
$val = new Simplify_Deposit();
$list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication);
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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return Deposit a Deposit object
*/
static public function findDeposit($id, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$val = new Simplify_Deposit();
$val->id = $id;
$obj = Simplify_PaymentsApi::findObject($val, $authentication);
return $obj;
}
/**
* @ignore
*/
public function getClazz() {
return "Deposit";
}
}

View File

@ -1,68 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
class Simplify_Event extends Simplify_Object {
/**
* Creates an Event object
* @param array $hash A map of parameters; valid keys are:
* <dt><code>payload</code></dt> <dd>The raw JWS payload. </dd> <strong>required</strong>
* <dt><code>url</code></dt> <dd>The URL for the webhook. If present it must match the URL registered for the webhook.</dd>
* @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);
$paymentsApi = new Simplify_PaymentsApi();
$jsonObject = $paymentsApi->jwsDecode($hash, $authentication);
if ($jsonObject['event'] == null) {
throw new InvalidArgumentException("Incorrect data in webhook event");
}
return $paymentsApi->convertFromHashToObject($jsonObject['event'], self::getClazz());
}
/**
* @ignore
*/
static public function getClazz() {
return "Event";
}
}

View File

@ -1,294 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
/**
*
* Base class for all API exceptions.
*
*/
class Simplify_ApiException extends Exception
{
protected $errorData;
protected $status;
protected $errorCode;
protected $reference;
/**
* @ignore
*/
function __construct($message, $status = null, $errorData = null) {
parent::__construct($message);
$this->status = $status;
$this->errorCode = null;
$this->reference = null;
if ($errorData != null) {
$this->reference = $errorData['reference'];
$this->errorData = $errorData;
$error = $errorData['error'];
if ($error != null) {
$m = $error['message'];
if ($m != null) {
$this->message = $m;
}
$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;
}
/**
* 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() . ")";
}
}
/**
* Exception raised when there are communication problems contacting the API.
*/
class Simplify_ApiConnectionException extends Simplify_ApiException {
/**
* @ignore
*/
function __construct($message, $status = null, $errorData = null) {
parent::__construct($message, $status, $errorData);
}
}
/**
* Exception raised where there are problems authenticating a request.
*/
class Simplify_AuthenticationException extends Simplify_ApiException {
/**
* @ignore
*/
function __construct($message, $status = null, $errorData = null) {
parent::__construct($message, $status, $errorData);
}
}
/**
* Exception raised when the API request contains errors.
*/
class Simplify_BadRequestException extends Simplify_ApiException {
protected $fieldErrors;
/**
* @ignore
*/
function __construct($message, $status = null, $errorData = null) {
parent::__construct($message, $status, $errorData);
$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));
}
}
}
}
}
/**
* 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 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";
}
}
/**
* Represents a single error in a field of a request sent to the API.
*/
class Simplify_FieldError {
protected $field;
protected $code;
protected $message;
/**
* @ignore
*/
function __construct($errorData) {
$this->field = $errorData['field'];
$this->code = $errorData['code'];
$this->message = $errorData['message'];
}
/**
* Returns the name of the field with the error.
* @return string the field name.
*/
function getFieldName() {
return $this->field;
}
/**
* 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() . ")";
}
}
/**
* Exception when a requested object cannot be found.
*/
class Simplify_ObjectNotFoundException extends Simplify_ApiException {
/**
* @ignore
*/
function __construct($message, $status = null, $errorData = null) {
parent::__construct($message, $status, $errorData);
}
}
/**
* Exception when a request was not allowed.
*/
class Simplify_NotAllowedException extends Simplify_ApiException {
/**
* @ignore
*/
function __construct($message, $status = null, $errorData = null) {
parent::__construct($message, $status, $errorData);
}
}
/**
* Exception when there was a system error processing a request.
*/
class Simplify_SystemException extends Simplify_ApiException {
/**
* @ignore
*/
function __construct($message, $status = null, $errorData = null) {
parent::__construct($message, $status, $errorData);
}
}

View File

@ -1,122 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
class Simplify_FraudCheck extends Simplify_Object {
/**
* Creates an Simplify_FraudCheck object
* @param array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;">
* <dt><tt>amount</tt></dt> <dd>Amount of the transaction to be checked for fraud (in the smallest unit of your currency). Example: 100 = $1.00USD </dd>
* <dt><tt>card.addressCity</tt></dt> <dd>City of the cardholder. [max length: 50, min length: 2] </dd>
* <dt><tt>card.addressCountry</tt></dt> <dd>Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2] </dd>
* <dt><tt>card.addressLine1</tt></dt> <dd>Address of the cardholder. [max length: 255] </dd>
* <dt><tt>card.addressLine2</tt></dt> <dd>Address of the cardholder if needed. [max length: 255] </dd>
* <dt><tt>card.addressState</tt></dt> <dd>State of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, min length: 2] </dd>
* <dt><tt>card.addressZip</tt></dt> <dd>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] </dd>
* <dt><tt>card.cvc</tt></dt> <dd>CVC security code of the card. This is the code on the back of the card. Example: 123 </dd>
* <dt><tt>card.expMonth</tt></dt> <dd>Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] <strong>required </strong></dd>
* <dt><tt>card.expYear</tt></dt> <dd>Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] <strong>required </strong></dd>
* <dt><tt>card.name</tt></dt> <dd>Name as it appears on the card. [max length: 50, min length: 2] </dd>
* <dt><tt>card.number</tt></dt> <dd>Card number as it appears on the card. [max length: 19, min length: 13] <strong>required </strong></dd>
* <dt><tt>currency</tt></dt> <dd>Currency code (ISO-4217) for the transaction to be checked for fraud. </dd>
* <dt><tt>description</tt></dt> <dd>- Description of the fraud check. </dd>
* <dt><tt>mode</tt></dt> <dd>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] <strong>required </strong></dd>
* <dt><tt>sessionId</tt></dt> <dd>Session ID usd during data collection. [max length: 255] </dd>
* <dt><tt>token</tt></dt> <dd>Description </dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.<i/>
* @return FraudCheck a FraudCheck object.
*/
static public function createFraudCheck($hash, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$instance = new Simplify_FraudCheck();
$instance->setAll($hash);
$object = Simplify_PaymentsApi::createObject($instance, $authentication);
return $object;
}
/**
* Retrieve Simplify_FraudCheck objects.
* @param array criteria a map of parameters; valid keys are:<dl style="padding-left:10px;">
* <dt><tt>filter</tt></dt> <dd>Allows for ascending or descending sorting of the list. </dd>
* <dt><tt>max</tt></dt> <dd>Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] </dd>
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: .</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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);
$val = new Simplify_FraudCheck();
$list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication);
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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return FraudCheck a FraudCheck object
*/
static public function findFraudCheck($id, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$val = new Simplify_FraudCheck();
$val->id = $id;
$obj = Simplify_PaymentsApi::findObject($val, $authentication);
return $obj;
}
/**
* @ignore
*/
public function getClazz() {
return "FraudCheck";
}
}

View File

@ -1,411 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
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));
}
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('incorrectly 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.''
)
);
}
}

View File

@ -1,228 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
class Simplify_Invoice extends Simplify_Object {
/**
* Creates an Simplify_Invoice object
* @param array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;">
* <dt><tt>billingAddress.city</tt></dt> <dd>Billing address city of the location where the goods or services were supplied. [max length: 255, min length: 2] </dd>
* <dt><tt>billingAddress.country</tt></dt> <dd>Billing address country of the location where the goods or services were supplied. [max length: 2, min length: 2] </dd>
* <dt><tt>billingAddress.line1</tt></dt> <dd>Billing address line 1 of the location where the goods or services were supplied. [max length: 255] </dd>
* <dt><tt>billingAddress.line2</tt></dt> <dd>Billing address line 2 of the location where the goods or services were supplied. [max length: 255] </dd>
* <dt><tt>billingAddress.name</tt></dt> <dd>Billing address name of the location where the goods or services were supplied. Will use the customer name if not provided. [max length: 255] </dd>
* <dt><tt>billingAddress.state</tt></dt> <dd>Billing address state of the location where the goods or services were supplied. [max length: 255] </dd>
* <dt><tt>billingAddress.zip</tt></dt> <dd>Billing address zip of the location where the goods or services were supplied. [max length: 32] </dd>
* <dt><tt>businessAddress.city</tt></dt> <dd>Address city of the business that is sending the invoice. [max length: 255, min length: 2] </dd>
* <dt><tt>businessAddress.country</tt></dt> <dd>Address country of the business that is sending the invoice. [max length: 2, min length: 2] </dd>
* <dt><tt>businessAddress.line1</tt></dt> <dd>Address line 1 of the business that is sending the invoice. [max length: 255] </dd>
* <dt><tt>businessAddress.line2</tt></dt> <dd>Address line 2 of the business that is sending the invoice. [max length: 255] </dd>
* <dt><tt>businessAddress.name</tt></dt> <dd>The name of the business that is sending the invoice. [max length: 255] </dd>
* <dt><tt>businessAddress.state</tt></dt> <dd>Address state of the business that is sending the invoice. [max length: 255] </dd>
* <dt><tt>businessAddress.zip</tt></dt> <dd>Address zip of the business that is sending the invoice. [max length: 32] </dd>
* <dt><tt>currency</tt></dt> <dd>Currency code (ISO-4217). Must match the currency associated with your account. [max length: 3, min length: 3, default: USD] </dd>
* <dt><tt>customer</tt></dt> <dd>The customer ID of the customer we are invoicing. This is optional if invoiceToCopy or a name and email are provided </dd>
* <dt><tt>customerTaxNo</tt></dt> <dd>The tax number or VAT id of the person to whom the goods or services were supplied. [max length: 255] </dd>
* <dt><tt>discountRate</tt></dt> <dd>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] </dd>
* <dt><tt>dueDate</tt></dt> <dd>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. </dd>
* <dt><tt>email</tt></dt> <dd>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. </dd>
* <dt><tt>invoiceId</tt></dt> <dd>User defined invoice id. If not provided the system will generate a numeric id. [max length: 255] </dd>
* <dt><tt>invoiceToCopy</tt></dt> <dd>The id of an existing invoice to be copied. This is optional if customer or a name and email are provided </dd>
* <dt><tt>items.amount</tt></dt> <dd>Amount of the invoice item (the smallest unit of your currency). Example: 100 = $1.00USD [min value: -9999900, max value: 9999900] <strong>required </strong></dd>
* <dt><tt>items.description</tt></dt> <dd>The description of the invoice item. [max length: 1024] </dd>
* <dt><tt>items.invoice</tt></dt> <dd>The ID of the invoice this item belongs to. </dd>
* <dt><tt>items.product</tt></dt> <dd>The product this invoice item refers to. </dd>
* <dt><tt>items.quantity</tt></dt> <dd>Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999, default: 1] </dd>
* <dt><tt>items.reference</tt></dt> <dd>User defined reference field. [max length: 255] </dd>
* <dt><tt>items.tax</tt></dt> <dd>The tax ID of the tax charge in the invoice item. </dd>
* <dt><tt>lateFee</tt></dt> <dd>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] </dd>
* <dt><tt>memo</tt></dt> <dd>A memo that is displayed to the customer on the invoice payment screen. [max length: 4000] </dd>
* <dt><tt>name</tt></dt> <dd>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] </dd>
* <dt><tt>note</tt></dt> <dd>This field can be used to store a note that is not displayed to the customer. [max length: 4000] </dd>
* <dt><tt>reference</tt></dt> <dd>User defined reference field. [max length: 255] </dd>
* <dt><tt>shippingAddress.city</tt></dt> <dd>Address city of the location where the goods or services were supplied. [max length: 255, min length: 2] </dd>
* <dt><tt>shippingAddress.country</tt></dt> <dd>Address country of the location where the goods or services were supplied. [max length: 2, min length: 2] </dd>
* <dt><tt>shippingAddress.line1</tt></dt> <dd>Address line 1 of the location where the goods or services were supplied. [max length: 255] </dd>
* <dt><tt>shippingAddress.line2</tt></dt> <dd>Address line 2 of the location where the goods or services were supplied. [max length: 255] </dd>
* <dt><tt>shippingAddress.name</tt></dt> <dd>Address name of the location where the goods or services were supplied. [max length: 255] </dd>
* <dt><tt>shippingAddress.state</tt></dt> <dd>Address state of the location where the goods or services were supplied. [max length: 255] </dd>
* <dt><tt>shippingAddress.zip</tt></dt> <dd>Address zip of the location where the goods or services were supplied. [max length: 32] </dd>
* <dt><tt>suppliedDate</tt></dt> <dd>The date on which the goods or services were supplied. </dd>
* <dt><tt>taxNo</tt></dt> <dd>The tax number or VAT id of the person who supplied the goods or services. [max length: 255] </dd>
* <dt><tt>type</tt></dt> <dd>The type of invoice. One of WEB or MOBILE. [valid values: WEB, MOBILE, default: WEB] </dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.<i/>
* @return Invoice a Invoice object.
*/
static public function createInvoice($hash, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$instance = new Simplify_Invoice();
$instance->setAll($hash);
$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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
*
* @return true
*/
public function deleteInvoice($authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
$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:<dl style="padding-left:10px;">
* <dt><tt>filter</tt></dt> <dd>Filters to apply to the list. </dd>
* <dt><tt>max</tt></dt> <dd>Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] </dd>
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> id</tt><tt> invoiceDate</tt><tt> dueDate</tt><tt> datePaid</tt><tt> customer</tt><tt> status</tt><tt> dateCreated</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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);
$val = new Simplify_Invoice();
$list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication);
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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return Invoice a Invoice object
*/
static public function findInvoice($id, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$val = new Simplify_Invoice();
$val->id = $id;
$obj = Simplify_PaymentsApi::findObject($val, $authentication);
return $obj;
}
/**
* Updates an Simplify_Invoice object.
*
* The properties that can be updated:
* <dl style="padding-left:10px;">
* <dt><tt>billingAddress.city</tt></dt> <dd>Billing address city of the location where the goods or services were supplied. [max length: 255, min length: 2] </dd>
* <dt><tt>billingAddress.country</tt></dt> <dd>Billing address country of the location where the goods or services were supplied. [max length: 2, min length: 2] </dd>
* <dt><tt>billingAddress.line1</tt></dt> <dd>Billing address line 1 of the location where the goods or services were supplied. [max length: 255] </dd>
* <dt><tt>billingAddress.line2</tt></dt> <dd>Billing address line 2 of the location where the goods or services were supplied. [max length: 255] </dd>
* <dt><tt>billingAddress.name</tt></dt> <dd>Billing address name of the location where the goods or services were supplied. [max length: 255] </dd>
* <dt><tt>billingAddress.state</tt></dt> <dd>Billing address state of the location where the goods or services were supplied. [max length: 255] </dd>
* <dt><tt>billingAddress.zip</tt></dt> <dd>Billing address zip of the location where the goods or services were supplied. [max length: 32] </dd>
* <dt><tt>businessAddress.city</tt></dt> <dd>Business address city of the business that is sending the invoice. [max length: 255, min length: 2] </dd>
* <dt><tt>businessAddress.country</tt></dt> <dd>Business address country of the business that is sending the invoice. [max length: 2, min length: 2] </dd>
* <dt><tt>businessAddress.line1</tt></dt> <dd>Business address line 1 of the business that is sending the invoice. [max length: 255] </dd>
* <dt><tt>businessAddress.line2</tt></dt> <dd>Business address line 2 of the business that is sending the invoice. [max length: 255] </dd>
* <dt><tt>businessAddress.name</tt></dt> <dd>Business address name of the business that is sending the invoice. [max length: 255] </dd>
* <dt><tt>businessAddress.state</tt></dt> <dd>Business address state of the business that is sending the invoice. [max length: 255] </dd>
* <dt><tt>businessAddress.zip</tt></dt> <dd>Business address zip of the business that is sending the invoice. [max length: 32] </dd>
* <dt><tt>currency</tt></dt> <dd>Currency code (ISO-4217). Must match the currency associated with your account. [max length: 3, min length: 3] </dd>
* <dt><tt>customerTaxNo</tt></dt> <dd>The tax number or VAT id of the person to whom the goods or services were supplied. [max length: 255] </dd>
* <dt><tt>datePaid</tt></dt> <dd>This is the date the invoice was PAID in UTC millis. </dd>
* <dt><tt>discountRate</tt></dt> <dd>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] </dd>
* <dt><tt>dueDate</tt></dt> <dd>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. </dd>
* <dt><tt>email</tt></dt> <dd>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. </dd>
* <dt><tt>invoiceId</tt></dt> <dd>User defined invoice id. If not provided the system will generate a numeric id. [max length: 255] </dd>
* <dt><tt>items.amount</tt></dt> <dd>Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00USD [min value: -9999900, max value: 9999900] <strong>required </strong></dd>
* <dt><tt>items.description</tt></dt> <dd>The description of the invoice item. [max length: 1024] </dd>
* <dt><tt>items.invoice</tt></dt> <dd>The ID of the invoice this item belongs to. </dd>
* <dt><tt>items.product</tt></dt> <dd>The Id of the product this item refers to. </dd>
* <dt><tt>items.quantity</tt></dt> <dd>Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999, default: 1] </dd>
* <dt><tt>items.reference</tt></dt> <dd>User defined reference field. [max length: 255] </dd>
* <dt><tt>items.tax</tt></dt> <dd>The tax ID of the tax charge in the invoice item. </dd>
* <dt><tt>lateFee</tt></dt> <dd>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] </dd>
* <dt><tt>memo</tt></dt> <dd>A memo that is displayed to the customer on the invoice payment screen. [max length: 4000] </dd>
* <dt><tt>name</tt></dt> <dd>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] </dd>
* <dt><tt>note</tt></dt> <dd>This field can be used to store a note that is not displayed to the customer. [max length: 4000] </dd>
* <dt><tt>payment</tt></dt> <dd>The ID of the payment. Use this ID to query the /payment API. [max length: 255] </dd>
* <dt><tt>reference</tt></dt> <dd>User defined reference field. [max length: 255] </dd>
* <dt><tt>shippingAddress.city</tt></dt> <dd>Address city of the location where the goods or services were supplied. [max length: 255, min length: 2] </dd>
* <dt><tt>shippingAddress.country</tt></dt> <dd>Address country of the location where the goods or services were supplied. [max length: 2, min length: 2] </dd>
* <dt><tt>shippingAddress.line1</tt></dt> <dd>Address line 1 of the location where the goods or services were supplied. [max length: 255] </dd>
* <dt><tt>shippingAddress.line2</tt></dt> <dd>Address line 2 of the location where the goods or services were supplied. [max length: 255] </dd>
* <dt><tt>shippingAddress.name</tt></dt> <dd>Address name of the location where the goods or services were supplied. [max length: 255] </dd>
* <dt><tt>shippingAddress.state</tt></dt> <dd>Address state of the location where the goods or services were supplied. [max length: 255] </dd>
* <dt><tt>shippingAddress.zip</tt></dt> <dd>Address zip of the location where the goods or services were supplied. [max length: 32] </dd>
* <dt><tt>status</tt></dt> <dd>New status of the invoice. </dd>
* <dt><tt>suppliedDate</tt></dt> <dd>The date on which the goods or services were supplied. </dd>
* <dt><tt>taxNo</tt></dt> <dd>The tax number or VAT id of the person who supplied the goods or services. [max length: 255] </dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return Invoice a Invoice object.
*/
public function updateInvoice($authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
$object = Simplify_PaymentsApi::updateObject($this, $authentication);
return $object;
}
/**
* @ignore
*/
public function getClazz() {
return "Invoice";
}
}

View File

@ -1,128 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
class Simplify_InvoiceItem extends Simplify_Object {
/**
* Creates an Simplify_InvoiceItem object
* @param array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;">
* <dt><tt>amount</tt></dt> <dd>Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00USD [min value: -9999900, max value: 9999900] <strong>required </strong></dd>
* <dt><tt>description</tt></dt> <dd>Individual items of an invoice [max length: 1024] </dd>
* <dt><tt>invoice</tt></dt> <dd>The ID of the invoice this item belongs to. </dd>
* <dt><tt>product</tt></dt> <dd>Product ID this item relates to. </dd>
* <dt><tt>quantity</tt></dt> <dd>Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999, default: 1] </dd>
* <dt><tt>reference</tt></dt> <dd>User defined reference field. [max length: 255] </dd>
* <dt><tt>tax</tt></dt> <dd>The tax ID of the tax charge in the invoice item. </dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.<i/>
* @return InvoiceItem a InvoiceItem object.
*/
static public function createInvoiceItem($hash, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$instance = new Simplify_InvoiceItem();
$instance->setAll($hash);
$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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
*
* @return true
*/
public function deleteInvoiceItem($authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
$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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return InvoiceItem a InvoiceItem object
*/
static public function findInvoiceItem($id, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$val = new Simplify_InvoiceItem();
$val->id = $id;
$obj = Simplify_PaymentsApi::findObject($val, $authentication);
return $obj;
}
/**
* Updates an Simplify_InvoiceItem object.
*
* The properties that can be updated:
* <dl style="padding-left:10px;">
* <dt><tt>amount</tt></dt> <dd>Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00USD [min value: 1] </dd>
* <dt><tt>description</tt></dt> <dd>Individual items of an invoice </dd>
* <dt><tt>quantity</tt></dt> <dd>Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999] </dd>
* <dt><tt>reference</tt></dt> <dd>User defined reference field. </dd>
* <dt><tt>tax</tt></dt> <dd>The tax ID of the tax charge in the invoice item. </dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return InvoiceItem a InvoiceItem object.
*/
public function updateInvoiceItem($authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
$object = Simplify_PaymentsApi::updateObject($this, $authentication);
return $object;
}
/**
* @ignore
*/
public function getClazz() {
return "InvoiceItem";
}
}

View File

@ -1,90 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
/**
* Base class for all domain objects.
*/
class Simplify_Object {
private $properties = array();
/**
* @ignore
*
* @param string $key
*
* @return mixed
*/
public function __get($key) {
if (array_key_exists($key, $this->properties)) {
return $this->properties[$key];
} else {
return null;
}
}
/**
* @ignore
*
* @param string $key
* @param mixed $value
*/
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;
}
}
/**
* @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;
}
}

View File

@ -1,145 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
class Simplify_Payment extends Simplify_Object {
/**
* Creates an Simplify_Payment object
* @param array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;">
* <dt><tt>amount</tt></dt> <dd>Amount of the payment (in the smallest unit of your currency). Example: 100 = $1.00USD </dd>
* <dt><tt>authorization</tt></dt> <dd>The ID of the authorization being used to capture the payment. </dd>
* <dt><tt>card.addressCity</tt></dt> <dd>City of the cardholder. [max length: 50, min length: 2] </dd>
* <dt><tt>card.addressCountry</tt></dt> <dd>Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2] </dd>
* <dt><tt>card.addressLine1</tt></dt> <dd>Address of the cardholder. [max length: 255] </dd>
* <dt><tt>card.addressLine2</tt></dt> <dd>Address of the cardholder if needed. [max length: 255] </dd>
* <dt><tt>card.addressState</tt></dt> <dd>State of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, min length: 2] </dd>
* <dt><tt>card.addressZip</tt></dt> <dd>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] </dd>
* <dt><tt>card.cvc</tt></dt> <dd>CVC security code of the card. This is the code on the back of the card. Example: 123 </dd>
* <dt><tt>card.expMonth</tt></dt> <dd>Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] <strong>required </strong></dd>
* <dt><tt>card.expYear</tt></dt> <dd>Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] <strong>required </strong></dd>
* <dt><tt>card.name</tt></dt> <dd>Name as it appears on the card. [max length: 50, min length: 2] </dd>
* <dt><tt>card.number</tt></dt> <dd>Card number as it appears on the card. [max length: 19, min length: 13] <strong>required </strong></dd>
* <dt><tt>currency</tt></dt> <dd>Currency code (ISO-4217) for the transaction. Must match the currency associated with your account. [default: USD] <strong>required </strong></dd>
* <dt><tt>customer</tt></dt> <dd>ID of customer. If specified, card on file of customer will be used. </dd>
* <dt><tt>description</tt></dt> <dd>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] </dd>
* <dt><tt>invoice</tt></dt> <dd>ID of invoice for which this payment is being made. </dd>
* <dt><tt>reference</tt></dt> <dd>Custom reference field to be used with outside systems. </dd>
* <dt><tt>replayId</tt></dt> <dd>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] </dd>
* <dt><tt>statementDescription.name</tt></dt> <dd>Merchant name. <strong>required </strong></dd>
* <dt><tt>statementDescription.phoneNumber</tt></dt> <dd>Merchant contact phone number. </dd>
* <dt><tt>token</tt></dt> <dd>If specified, card associated with card token will be used. [max length: 255] </dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.<i/>
* @return Payment a Payment object.
*/
static public function createPayment($hash, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$instance = new Simplify_Payment();
$instance->setAll($hash);
$object = Simplify_PaymentsApi::createObject($instance, $authentication);
return $object;
}
/**
* Retrieve Simplify_Payment objects.
* @param array criteria a map of parameters; valid keys are:<dl style="padding-left:10px;">
* <dt><tt>filter</tt></dt> <dd>Filters to apply to the list. </dd>
* <dt><tt>max</tt></dt> <dd>Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] </dd>
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> dateCreated</tt><tt> createdBy</tt><tt> amount</tt><tt> id</tt><tt> description</tt><tt> paymentDate</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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);
$val = new Simplify_Payment();
$list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication);
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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return Payment a Payment object
*/
static public function findPayment($id, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$val = new Simplify_Payment();
$val->id = $id;
$obj = Simplify_PaymentsApi::findObject($val, $authentication);
return $obj;
}
/**
* Updates an Simplify_Payment object.
*
* The properties that can be updated:
* <dl style="padding-left:10px;"></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return Payment a Payment object.
*/
public function updatePayment($authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
$object = Simplify_PaymentsApi::updateObject($this, $authentication);
return $object;
}
/**
* @ignore
*/
public function getClazz() {
return "Payment";
}
}

View File

@ -1,358 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
class Simplify_PaymentsApi
{
/**
* @ignore
*/
public static $methodMap = array(
'create' => 'POST',
'delete' => 'DELETE',
'list' => 'GET',
'show' => 'GET',
'update' => 'PUT'
);
/**
* @ignore
*
* @param object $object
* @param object $authentication
*
* @return mixed
*/
static public function createObject($object, $authentication = null)
{
$paymentsApi = new Simplify_PaymentsApi();
$jsonObject = $paymentsApi->execute("create", $object, $authentication);
$o = $paymentsApi->convertFromHashToObject($jsonObject, $object->getClazz());
return $o;
}
/**
* @ignore
*
* @param object $object
* @param object $authentication
*
* @return mixed
*/
static public function findObject($object, $authentication = null)
{
$paymentsApi = new Simplify_PaymentsApi();
$jsonObject = $paymentsApi->execute("show", $object, $authentication);
$o = $paymentsApi->convertFromHashToObject($jsonObject, $object->getClazz());
return $o;
}
/**
* @ignore
*
* @param object $object
* @param object $authentication
*
* @return mixed
*/
static public function updateObject($object, $authentication = null) {
$paymentsApi = new Simplify_PaymentsApi();
$jsonObject = $paymentsApi->execute("update", $object, $authentication);
$o = $paymentsApi->convertFromHashToObject($jsonObject, $object->getClazz());
return $o;
}
/**
* @ignore
*
* @param object $object
* @param object $authentication
*
* @return mixed
*/
static public function deleteObject($object, $authentication = null) {
$paymentsApi = new Simplify_PaymentsApi();
$jsonObject = $paymentsApi->execute("delete", $object, $authentication);
return $jsonObject;
}
/**
* @ignore
*
* @param object $object
* @param array $criteria
* @param object $authentication
*
* @return Simplify_ResourceList
*/
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);
$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;
}
/**
* @ignore
*
* @param array $from
* @param string $toClazz
*
* @return mixed
*/
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';
}
$object->$key = $this->convertFromHashToObject($value, $newClazz);
} else {
$object->$key = $value;
}
}
return $object;
}
/**
* @ignore
*
* @param string $publicKey
* @param string $action
* @param object $object
*
* @return string
*/
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 ( 'show' == $action ) {
$url .= urlencode($object->id);
} elseif ( 'list' == $action ) {
$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 ( 'delete' == $action ) {
$url .= urlencode($object->id);
} elseif ( 'update' == $action ) {
$url .= urlencode($object->id);
} elseif ( 'create' == $action ) {
}
return $url;
}
/**
* @ignore
*
* @param string $action
*
* @return string
*/
public function getMethod($action)
{
if (array_key_exists(strtolower($action), self::$methodMap)) {
return self::$methodMap[strtolower($action)];
}
return 'GET';
}
/**
* @ignore
*
* @param string $action
* @param object $object
* @param object $authentication
*
* @return mixed
*/
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()));
}
/**
* @ignore
*
* @param string $hash
* @param object $authentication
*
* @return mixed
*/
public function jwsDecode($hash, $authentication)
{
$http = new Simplify_HTTP();
$data = $http->jwsDecode($authentication, $hash);
return json_decode($data, true);
}
/**
* @ignore
*
* @param string $url
*
* @return string
*/
private function fixUrl($url)
{
if ($this->endsWith($url, '/')) {
return $url;
}
return $url . '/';
}
/**
* @ignore
*
* @param string $k
*
* @return bool
*/
private function isLiveKey($k) {
return strpos($k, "lvpb") === 0;
}
/**
* @ignore
*
* @param string $s
* @param string $c
*
* @return bool
*/
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){
if(sizeof($args) > $expectedArgCount) {
$authentication = new Simplify_Authentication($args[$expectedArgCount-1], $args[$expectedArgCount]);
}
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;
}
return $authentication;
}
}

View File

@ -1,151 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
class Simplify_Plan extends Simplify_Object {
/**
* Creates an Simplify_Plan object
* @param array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;">
* <dt><tt>amount</tt></dt> <dd>Amount of payment for the plan in the smallest unit of your currency. Example: 100 = $1.00USD <strong>required </strong></dd>
* <dt><tt>billingCycle</tt></dt> <dd>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] </dd>
* <dt><tt>billingCycleLimit</tt></dt> <dd>The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4 </dd>
* <dt><tt>currency</tt></dt> <dd>Currency code (ISO-4217) for the plan. Must match the currency associated with your account. [default: USD] <strong>required </strong></dd>
* <dt><tt>frequency</tt></dt> <dd>Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY". [default: MONTHLY] <strong>required </strong></dd>
* <dt><tt>frequencyPeriod</tt></dt> <dd>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] <strong>required </strong></dd>
* <dt><tt>name</tt></dt> <dd>Name of the plan [max length: 50, min length: 2] <strong>required </strong></dd>
* <dt><tt>renewalReminderLeadDays</tt></dt> <dd>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. </dd>
* <dt><tt>trialPeriod</tt></dt> <dd>Plan free trial period selection. Must be Days, Weeks, or Month [default: NONE] <strong>required </strong></dd>
* <dt><tt>trialPeriodQuantity</tt></dt> <dd>Quantity of the trial period. Must be greater than 0 and a whole number. [min value: 1] </dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.<i/>
* @return Plan a Plan object.
*/
static public function createPlan($hash, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$instance = new Simplify_Plan();
$instance->setAll($hash);
$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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
*
* @return true
*/
public function deletePlan($authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
$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:<dl style="padding-left:10px;">
* <dt><tt>filter</tt></dt> <dd>Filters to apply to the list. </dd>
* <dt><tt>max</tt></dt> <dd>Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] </dd>
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> dateCreated</tt><tt> amount</tt><tt> frequency</tt><tt> name</tt><tt> id</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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);
$val = new Simplify_Plan();
$list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication);
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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return Plan a Plan object
*/
static public function findPlan($id, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$val = new Simplify_Plan();
$val->id = $id;
$obj = Simplify_PaymentsApi::findObject($val, $authentication);
return $obj;
}
/**
* Updates an Simplify_Plan object.
*
* The properties that can be updated:
* <dl style="padding-left:10px;">
* <dt><tt>name</tt></dt> <dd>Name of the plan. [min length: 2] <strong>required </strong></dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return Plan a Plan object.
*/
public function updatePlan($authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
$object = Simplify_PaymentsApi::updateObject($this, $authentication);
return $object;
}
/**
* @ignore
*/
public function getClazz() {
return "Plan";
}
}

View File

@ -1,112 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
class Simplify_Refund extends Simplify_Object {
/**
* Creates an Simplify_Refund object
* @param array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;">
* <dt><tt>amount</tt></dt> <dd>Amount of the refund in the smallest unit of your currency. Example: 100 = $1.00USD [min value: 1] <strong>required </strong></dd>
* <dt><tt>payment</tt></dt> <dd>ID of the payment for the refund <strong>required </strong></dd>
* <dt><tt>reason</tt></dt> <dd>Reason for the refund </dd>
* <dt><tt>reference</tt></dt> <dd>Custom reference field to be used with outside systems. </dd>
* <dt><tt>replayId</tt></dt> <dd>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] </dd>
* <dt><tt>statementDescription.name</tt></dt> <dd>Merchant name. <strong>required </strong></dd>
* <dt><tt>statementDescription.phoneNumber</tt></dt> <dd>Merchant contact phone number. </dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.<i/>
* @return Refund a Refund object.
*/
static public function createRefund($hash, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$instance = new Simplify_Refund();
$instance->setAll($hash);
$object = Simplify_PaymentsApi::createObject($instance, $authentication);
return $object;
}
/**
* Retrieve Simplify_Refund objects.
* @param array criteria a map of parameters; valid keys are:<dl style="padding-left:10px;">
* <dt><tt>filter</tt></dt> <dd>Filters to apply to the list. </dd>
* <dt><tt>max</tt></dt> <dd>Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] </dd>
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> id</tt><tt> amount</tt><tt> description</tt><tt> dateCreated</tt><tt> paymentDate</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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);
$val = new Simplify_Refund();
$list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication);
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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return Refund a Refund object
*/
static public function findRefund($id, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$val = new Simplify_Refund();
$val->id = $id;
$obj = Simplify_PaymentsApi::findObject($val, $authentication);
return $obj;
}
/**
* @ignore
*/
public function getClazz() {
return "Refund";
}
}

View File

@ -1,48 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
/**
* Class Simplify_ResourceList represents a collection of domain objects returned by one of the list<Domain>() methods.
*/
class Simplify_ResourceList {
/**
* @var array $list the list of domain objects.
*/
public $list = array();
/**
* @var int $total the total number of object available.
*/
public $total = 0;
}

View File

@ -1,164 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
class Simplify_Subscription extends Simplify_Object {
/**
* Creates an Simplify_Subscription object
* @param array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;">
* <dt><tt>amount</tt></dt> <dd>Amount of the payment in the smallest unit of your currency. Example: 100 = $1.00USD </dd>
* <dt><tt>billingCycle</tt></dt> <dd>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] </dd>
* <dt><tt>billingCycleLimit</tt></dt> <dd>The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4 </dd>
* <dt><tt>coupon</tt></dt> <dd>Coupon ID associated with the subscription </dd>
* <dt><tt>currency</tt></dt> <dd>Currency code (ISO-4217). Must match the currency associated with your account. [default: USD] </dd>
* <dt><tt>customer</tt></dt> <dd>Customer that is enrolling in the subscription. </dd>
* <dt><tt>frequency</tt></dt> <dd>Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY". </dd>
* <dt><tt>frequencyPeriod</tt></dt> <dd>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. </dd>
* <dt><tt>name</tt></dt> <dd>Name describing subscription </dd>
* <dt><tt>plan</tt></dt> <dd>The ID of the plan that should be used for the subscription. </dd>
* <dt><tt>quantity</tt></dt> <dd>Quantity of the plan for the subscription. [min value: 1] </dd>
* <dt><tt>renewalReminderLeadDays</tt></dt> <dd>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. </dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.<i/>
* @return Subscription a Subscription object.
*/
static public function createSubscription($hash, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$instance = new Simplify_Subscription();
$instance->setAll($hash);
$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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
*
* @return true
*/
public function deleteSubscription($authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
$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:<dl style="padding-left:10px;">
* <dt><tt>filter</tt></dt> <dd>Filters to apply to the list. </dd>
* <dt><tt>max</tt></dt> <dd>Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] </dd>
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> id</tt><tt> plan</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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);
$val = new Simplify_Subscription();
$list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication);
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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return Subscription a Subscription object
*/
static public function findSubscription($id, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$val = new Simplify_Subscription();
$val->id = $id;
$obj = Simplify_PaymentsApi::findObject($val, $authentication);
return $obj;
}
/**
* Updates an Simplify_Subscription object.
*
* The properties that can be updated:
* <dl style="padding-left:10px;">
* <dt><tt>amount</tt></dt> <dd>Amount of the payment in the smallest unit of your currency. Example: 100 = $1.00USD </dd>
* <dt><tt>billingCycle</tt></dt> <dd>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] </dd>
* <dt><tt>billingCycleLimit</tt></dt> <dd>The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4 </dd>
* <dt><tt>coupon</tt></dt> <dd>Coupon being assigned to this subscription </dd>
* <dt><tt>currency</tt></dt> <dd>Currency code (ISO-4217). Must match the currency associated with your account. [default: USD] </dd>
* <dt><tt>frequency</tt></dt> <dd>Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY". </dd>
* <dt><tt>frequencyPeriod</tt></dt> <dd>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] </dd>
* <dt><tt>name</tt></dt> <dd>Name describing subscription </dd>
* <dt><tt>plan</tt></dt> <dd>Plan that should be used for the subscription. </dd>
* <dt><tt>prorate</tt></dt> <dd>Whether to prorate existing subscription. [default: true] <strong>required </strong></dd>
* <dt><tt>quantity</tt></dt> <dd>Quantity of the plan for the subscription. [min value: 1] </dd>
* <dt><tt>renewalReminderLeadDays</tt></dt> <dd>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. </dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return Subscription a Subscription object.
*/
public function updateSubscription($authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
$object = Simplify_PaymentsApi::updateObject($this, $authentication);
return $object;
}
/**
* @ignore
*/
public function getClazz() {
return "Subscription";
}
}

View File

@ -1,124 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
class Simplify_Tax extends Simplify_Object {
/**
* Creates an Simplify_Tax object
* @param array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;">
* <dt><tt>label</tt></dt> <dd>The label of the tax object. [max length: 255] <strong>required </strong></dd>
* <dt><tt>rate</tt></dt> <dd>The tax rate. Decimal value up three decimal places. e.g 12.501. [max length: 6] <strong>required </strong></dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.<i/>
* @return Tax a Tax object.
*/
static public function createTax($hash, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$instance = new Simplify_Tax();
$instance->setAll($hash);
$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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
*
* @return true
*/
public function deleteTax($authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
$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:<dl style="padding-left:10px;">
* <dt><tt>filter</tt></dt> <dd>Filters to apply to the list. </dd>
* <dt><tt>max</tt></dt> <dd>Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] </dd>
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> id</tt><tt> label</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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);
$val = new Simplify_Tax();
$list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication);
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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return Tax a Tax object
*/
static public function findTax($id, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$val = new Simplify_Tax();
$val->id = $id;
$obj = Simplify_PaymentsApi::findObject($val, $authentication);
return $obj;
}
/**
* @ignore
*/
public function getClazz() {
return "Tax";
}
}

View File

@ -1,141 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
class Simplify_TransactionReview extends Simplify_Object {
/**
* Creates an Simplify_TransactionReview object
* @param array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;"></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.<i/>
* @return TransactionReview a TransactionReview object.
*/
static public function createTransactionReview($hash, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$instance = new Simplify_TransactionReview();
$instance->setAll($hash);
$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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
*
* @return true
*/
public function deleteTransactionReview($authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
$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:<dl style="padding-left:10px;">
* <dt><tt>filter</tt></dt> <dd>Allows for ascending or descending sorting of the list. </dd>
* <dt><tt>max</tt></dt> <dd>Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] </dd>
* <dt><tt>offset</tt></dt> <dd>Filters to apply to the list. [min value: 0, default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> dateCreated</tt><tt> status</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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);
$val = new Simplify_TransactionReview();
$list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication);
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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return TransactionReview a TransactionReview object
*/
static public function findTransactionReview($id, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$val = new Simplify_TransactionReview();
$val->id = $id;
$obj = Simplify_PaymentsApi::findObject($val, $authentication);
return $obj;
}
/**
* Updates an Simplify_TransactionReview object.
*
* The properties that can be updated:
* <dl style="padding-left:10px;">
* <dt><tt>status</tt></dt> <dd>Status of the transaction review. </dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return TransactionReview a TransactionReview object.
*/
public function updateTransactionReview($authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
$object = Simplify_PaymentsApi::updateObject($this, $authentication);
return $object;
}
/**
* @ignore
*/
public function getClazz() {
return "TransactionReview";
}
}

View File

@ -1,142 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Copyright (c) 2013 - 2015 MasterCard International Incorporated
* All rights reserved.
*
* 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
* 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
* 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
* 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,
* 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
* SUCH DAMAGE.
*/
class Simplify_Webhook extends Simplify_Object {
/**
* Creates an Simplify_Webhook object
* @param array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;">
* <dt><tt>url</tt></dt> <dd>Endpoint URL <strong>required </strong></dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.<i/>
* @return Webhook a Webhook object.
*/
static public function createWebhook($hash, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$instance = new Simplify_Webhook();
$instance->setAll($hash);
$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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
*
* @return true
*/
public function deleteWebhook($authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
$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:<dl style="padding-left:10px;">
* <dt><tt>filter</tt></dt> <dd>Filters to apply to the list. </dd>
* <dt><tt>max</tt></dt> <dd>Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] </dd>
* <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] </dd>
* <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> dateCreated</tt>.</dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @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);
$val = new Simplify_Webhook();
$list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication);
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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return Webhook a Webhook object
*/
static public function findWebhook($id, $authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
$val = new Simplify_Webhook();
$val->id = $id;
$obj = Simplify_PaymentsApi::findObject($val, $authentication);
return $obj;
}
/**
* Updates an Simplify_Webhook object.
*
* The properties that can be updated:
* <dl style="padding-left:10px;">
* <dt><tt>url</tt></dt> <dd>Endpoint URL <strong>required </strong></dd></dl>
* @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. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
* @return Webhook a Webhook object.
*/
public function updateWebhook($authentication = null) {
$args = func_get_args();
$authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
$object = Simplify_PaymentsApi::updateObject($this, $authentication);
return $object;
}
/**
* @ignore
*/
public function getClazz() {
return "Webhook";
}
}

View File

@ -5,7 +5,6 @@
<!-- Exclude paths -->
<exclude-pattern>tests/cli/</exclude-pattern>
<exclude-pattern>apigen/</exclude-pattern>
<exclude-pattern>includes/gateways/simplify-commerce</exclude-pattern>
<exclude-pattern>includes/libraries/</exclude-pattern>
<exclude-pattern>includes/legacy/</exclude-pattern>
<exclude-pattern>includes/api/legacy/</exclude-pattern>

View File

@ -27,7 +27,6 @@
<directory suffix=".php">./includes/admin/views</directory>
<directory suffix=".php">./includes/api/legacy</directory>
<directory suffix=".php">./includes/api/v1</directory>
<directory suffix=".php">./includes/gateways/simplify-commerce/includes</directory>
<directory suffix=".php">./includes/legacy</directory>
<directory suffix=".php">./includes/libraries</directory>
<directory suffix=".php">./includes/shipping/legacy-flat-rate</directory>

View File

@ -2,7 +2,7 @@
if [[ ${RUN_PHPCS} == 1 ]]; then
CHANGED_FILES=`git diff --name-only --diff-filter=ACMR $TRAVIS_COMMIT_RANGE | grep \\\\.php | awk '{print}' ORS=' '`
IGNORE="tests/cli/,apigen/,includes/gateways/simplify-commerce/includes/,includes/libraries/,includes/api/legacy/"
IGNORE="tests/cli/,apigen/,includes/libraries/,includes/api/legacy/"
if [ "$CHANGED_FILES" != "" ]; then
echo "Running Code Sniffer."