Merge pull request #9553 from woothemes/issue/simplify-commerce-address-fields

Fix - address fields were not properly being passed to Simplify via t…
This commit is contained in:
Claudio Sanches 2015-11-09 22:43:11 -02:00
commit 3959d4fe3e
4 changed files with 35 additions and 34 deletions

View File

@ -17,9 +17,16 @@
}
});
var card = $( '#simplify_commerce-card-number' ).val(),
cvc = $( '#simplify_commerce-card-cvc' ).val(),
expiry = $.payment.cardExpiryVal( $( '#simplify_commerce-card-expiry' ).val() );
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(),
name = $form.find( '#billing_first_name' ).val() + ' ' + $form.find( '#billing_last_name' ).val();
card = card.replace( /\s/g, '' );
@ -29,7 +36,14 @@
number: card,
cvc: cvc,
expMonth: expiry.month,
expYear: ( expiry.year - 2000 )
expYear: ( expiry.year - 2000 ),
addressLine1: address1,
addressLine2: address2,
addressCountry: addressCountry,
addressState: addressState,
addressZip: addressZip,
addressCity: addressCity,
name: name
}
}, simplifyResponseHandler );

View File

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

View File

@ -304,13 +304,7 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
'customer' => $customer_id,
'description' => sprintf( __( '%s - Order #%s', 'woocommerce' ), esc_html( get_bloginfo( 'name', 'display' ) ), $order->get_order_number() ),
'currency' => strtoupper( get_woocommerce_currency() ),
'reference' => $order->id,
'card.addressCity' => $order->billing_city,
'card.addressCountry' => $order->billing_country,
'card.addressLine1' => $order->billing_address_1,
'card.addressLine2' => $order->billing_address_2,
'card.addressState' => $order->billing_state,
'card.addressZip' => $order->billing_postcode
'reference' => $order->id
) );
} catch ( Exception $e ) {
@ -445,13 +439,7 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
'customer' => $customer_id,
'description' => trim( substr( $pre_order_name, 0, 1024 ) ),
'currency' => strtoupper( get_woocommerce_currency() ),
'reference' => $order->id,
'card.addressCity' => $order->billing_city,
'card.addressCountry' => $order->billing_country,
'card.addressLine1' => $order->billing_address_1,
'card.addressLine2' => $order->billing_address_2,
'card.addressState' => $order->billing_state,
'card.addressZip' => $order->billing_postcode
'reference' => $order->id
) );
if ( 'APPROVED' == $payment->paymentStatus ) {

View File

@ -327,13 +327,7 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
'token' => $cart_token,
'description' => sprintf( __( '%s - Order #%s', 'woocommerce' ), esc_html( get_bloginfo( 'name', 'display' ) ), $order->get_order_number() ),
'currency' => strtoupper( get_woocommerce_currency() ),
'reference' => $order->id,
'card.addressCity' => $order->billing_city,
'card.addressCountry' => $order->billing_country,
'card.addressLine1' => $order->billing_address_1,
'card.addressLine2' => $order->billing_address_2,
'card.addressState' => $order->billing_state,
'card.addressZip' => $order->billing_postcode
'reference' => $order->id
) );
$order_complete = $this->process_order_status( $order, $payment->id, $payment->paymentStatus, $payment->authCode );
@ -404,14 +398,19 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
*/
protected function get_hosted_payments_args( $order ) {
$args = apply_filters( 'woocommerce_simplify_commerce_hosted_args', array(
'sc-key' => $this->public_key,
'amount' => $order->order_total * 100,
'reference' => $order->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' )
'sc-key' => $this->public_key,
'amount' => $order->order_total * 100,
'reference' => $order->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->billing_address_1 . ' ' . $order->billing_address_2,
'address-city' => $order->billing_city,
'address-state' => $order->billing_state,
'address-zip' => $order->billing_postcode,
'address-country' => $order->billing_country
), $order->id );
return $args;