Version Description
2017/04/04 =
Adicionado suporte ao WooCommerce 3.0.
Alterado o tipo dos campos para
telno Checkout Transparente. (Possvel com a ajuda de Thiago Guimares).Correo nas mscaras do campos devido a mudana do plugin no woocommerce-extra-checkout-fields-for-brazil. (Possvel com a ajuda de Thiago Guimares).
Download this release
Release Info
| Developer | claudiosanches |
| Plugin | |
| Version | 2.12.0 |
| Comparing to | |
| See all releases | |
Code changes from version 2.11.5 to 2.12.0
- assets/js/transparent-checkout.js +12 -14
- assets/js/transparent-checkout.min.js +1 -1
- includes/class-wc-pagseguro-api.php +41 -10
- includes/class-wc-pagseguro-gateway.php +91 -86
- includes/class-wc-pagseguro-xml.php +133 -7
- languages/woocommerce-pagseguro.pot +2 -2
- readme.txt +15 -9
- templates/transparent-checkout-form.php +7 -7
- woocommerce-pagseguro.php +11 -15
assets/js/transparent-checkout.js
CHANGED
|
@@ -86,24 +86,22 @@
|
|
| 86 |
pagSeguroShowHideMethodForm( $( '#pagseguro-payment-methods input[type=radio]:checked' ).val() );
|
| 87 |
|
| 88 |
// CPF.
|
| 89 |
-
$( '#pagseguro-card-holder-cpf' ).mask( '
|
| 90 |
|
| 91 |
// Birth Date.
|
| 92 |
-
$( '#pagseguro-card-holder-birth-date' ).mask( '
|
| 93 |
|
| 94 |
// Phone.
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
}
|
| 106 |
-
}).trigger( 'focusout' );
|
| 107 |
|
| 108 |
$( '#pagseguro-bank-transfer-form input[type=radio]:checked' ).parent( 'label' ).parent( 'li' ).addClass( 'active' );
|
| 109 |
}
|
| 86 |
pagSeguroShowHideMethodForm( $( '#pagseguro-payment-methods input[type=radio]:checked' ).val() );
|
| 87 |
|
| 88 |
// CPF.
|
| 89 |
+
$( '#pagseguro-card-holder-cpf' ).mask( '000.000.000-00' );
|
| 90 |
|
| 91 |
// Birth Date.
|
| 92 |
+
$( '#pagseguro-card-holder-birth-date' ).mask( '00/00/0000' );
|
| 93 |
|
| 94 |
// Phone.
|
| 95 |
+
var MaskBehavior = function( val ) {
|
| 96 |
+
return val.replace( /\D/g, '' ).length === 11 ? '(00) 00000-0000' : '(00) 0000-00009';
|
| 97 |
+
},
|
| 98 |
+
maskOptions = {
|
| 99 |
+
onKeyPress: function( val, e, field, options ) {
|
| 100 |
+
field.mask( MaskBehavior.apply( {}, arguments ), options );
|
| 101 |
+
}
|
| 102 |
+
};
|
| 103 |
+
|
| 104 |
+
$( '#pagseguro-card-holder-phone' ).mask( MaskBehavior, maskOptions );
|
|
|
|
|
|
|
| 105 |
|
| 106 |
$( '#pagseguro-bank-transfer-form input[type=radio]:checked' ).parent( 'label' ).parent( 'li' ).addClass( 'active' );
|
| 107 |
}
|
assets/js/transparent-checkout.min.js
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
!function(a){"use strict";a(function(){function b(b){a("#pagseguro-credit-card-form").attr("data-credit-card-brand",b)}function c(a){return"R$ "+parseFloat(a,10).toFixed(2).replace(".",",").toString()}function d(a){var b=!0===a.interestFree?" "+wc_pagseguro_params.interest_free:"";return'<option value="'+a.quantity+'" data-installment-value="'+a.installmentAmount+'">'+a.quantity+"x "+c(a.installmentAmount)+b+"</option>"}function e(b){var c=a("#pagseguro-credit-card-form");a(".woocommerce-error",c).remove(),c.prepend('<div class="woocommerce-error" style="margin-bottom: 0.5em !important;">'+b+"</div>")}function f(){var b=a("#pagseguro-payment-methods");1===a("input[type=radio]",b).length&&b.hide()}function g(b){a(".pagseguro-method-form").hide(),a("#pagseguro-payment-methods li").removeClass("active"),a("#pagseguro-"+b+"-form").show(),a("#pagseguro-payment-method-"+b).parent("label").parent("li").addClass("active")}function h(){f(),a("#pagseguro-payment-form").show(),g(a("#pagseguro-payment-methods input[type=radio]:checked").val()),a("#pagseguro-card-holder-cpf").mask("
|
| 1 |
+
!function(a){"use strict";a(function(){function b(b){a("#pagseguro-credit-card-form").attr("data-credit-card-brand",b)}function c(a){return"R$ "+parseFloat(a,10).toFixed(2).replace(".",",").toString()}function d(a){var b=!0===a.interestFree?" "+wc_pagseguro_params.interest_free:"";return'<option value="'+a.quantity+'" data-installment-value="'+a.installmentAmount+'">'+a.quantity+"x "+c(a.installmentAmount)+b+"</option>"}function e(b){var c=a("#pagseguro-credit-card-form");a(".woocommerce-error",c).remove(),c.prepend('<div class="woocommerce-error" style="margin-bottom: 0.5em !important;">'+b+"</div>")}function f(){var b=a("#pagseguro-payment-methods");1===a("input[type=radio]",b).length&&b.hide()}function g(b){a(".pagseguro-method-form").hide(),a("#pagseguro-payment-methods li").removeClass("active"),a("#pagseguro-"+b+"-form").show(),a("#pagseguro-payment-method-"+b).parent("label").parent("li").addClass("active")}function h(){f(),a("#pagseguro-payment-form").show(),g(a("#pagseguro-payment-methods input[type=radio]:checked").val()),a("#pagseguro-card-holder-cpf").mask("000.000.000-00"),a("#pagseguro-card-holder-birth-date").mask("00/00/0000");var b=function(a){return 11===a.replace(/\D/g,"").length?"(00) 00000-0000":"(00) 0000-00009"},c={onKeyPress:function(a,c,d,e){d.mask(b.apply({},arguments),e)}};a("#pagseguro-card-holder-phone").mask(b,c),a("#pagseguro-bank-transfer-form input[type=radio]:checked").parent("label").parent("li").addClass("active")}function i(){if(j)return j=!1,!0;if(!a("#payment_method_pagseguro").is(":checked"))return!0;if("credit-card"!==a("body li.payment_method_pagseguro input[name=pagseguro_payment_method]:checked").val())return a("form.checkout, form#order_review").append(a('<input name="pagseguro_sender_hash" type="hidden" />').val(PagSeguroDirectPayment.getSenderHash())),!0;var b=a("form.checkout, form#order_review"),c=a("#pagseguro-credit-card-form",b),d=!1,f="",g=c.attr("data-credit-card-brand"),h=a("#pagseguro-card-number",b).val().replace(/[^\d]/g,""),i=a("#pagseguro-card-cvc",b).val(),k=a("#pagseguro-card-expiry",b).val().replace(/[^\d]/g,"").substr(0,2),l=a("#pagseguro-card-expiry",b).val().replace(/[^\d]/g,"").substr(2),m=a("#pagseguro-card-installments",b),n=new Date;return f+="<ul>",("undefined"==typeof g||"error"===g)&&(f+="<li>"+wc_pagseguro_params.invalid_card+"</li>",d=!0),(2!==k.length||4!==l.length)&&(f+="<li>"+wc_pagseguro_params.invalid_expiry+"</li>",d=!0),2===k.length&&4===l.length&&(k>12||l<=n.getFullYear()-1||l>=n.getFullYear()+20||k<n.getMonth()+2&&l.toString()===n.getFullYear().toString())&&(f+="<li>"+wc_pagseguro_params.expired_date+"</li>",d=!0),"0"===m.val()&&(f+="<li>"+wc_pagseguro_params.empty_installments+"</li>",d=!0),f+="</ul>",d?e(f):PagSeguroDirectPayment.createCardToken({brand:g,cardNumber:h,cvv:i,expirationMonth:k,expirationYear:l,success:function(c){a("input[name=pagseguro_credit_card_hash], input[name=pagseguro_credit_card_hash], input[name=pagseguro_installment_value]",b).remove(),b.append(a('<input name="pagseguro_credit_card_hash" type="hidden" />').val(c.card.token)),b.append(a('<input name="pagseguro_sender_hash" type="hidden" />').val(PagSeguroDirectPayment.getSenderHash())),b.append(a('<input name="pagseguro_installment_value" type="hidden" />').val(a("option:selected",m).attr("data-installment-value"))),j=!0,b.submit()},error:function(){e(wc_pagseguro_params.general_error)}}),!1}var j=!1;wc_pagseguro_params.session_id?(PagSeguroDirectPayment.setSessionId(wc_pagseguro_params.session_id),"1"===wc_checkout_params.is_checkout?a("body").on("updated_checkout",function(){h()}):h(),a("body").on("click","#pagseguro-bank-transfer-form input[type=radio]",function(){a("#pagseguro-bank-transfer-form li").removeClass("active"),a(this).parent("label").parent("li").addClass("active")}),a("body").on("click","#pagseguro-payment-methods input[type=radio]",function(){g(a(this).val())}),a("body").on("focusout","#pagseguro-card-number",function(){var c=a(this).val().replace(/[^\d]/g,"").substr(0,6),d=a("body #pagseguro-card-installments");6===c.length&&(d.empty(),d.attr("disabled","disabled"),PagSeguroDirectPayment.getBrand({cardBin:c,success:function(c){a("body").trigger("pagseguro_credit_card_brand",c.brand.name),b(c.brand.name)},error:function(){a("body").trigger("pagseguro_credit_card_brand","error"),b("error")}}))}),a("body").on("focus","#pagseguro-card-number, #pagseguro-card-expiry",function(){a("#pagseguro-credit-card-form .woocommerce-error").remove()}),a("body").on("pagseguro_credit_card_brand",function(b,c){"error"!==c?PagSeguroDirectPayment.getInstallments({amount:a("body #pagseguro-cart-total").val(),brand:c,success:function(b){var f=a("body #pagseguro-card-installments");!1===b.error?(f.empty(),f.removeAttr("disabled"),f.append('<option value="0">--</option>'),a.each(b.installments[c],function(a,b){f.append(d(b))})):e(wc_pagseguro_params.invalid_card)},error:function(){e(wc_pagseguro_params.invalid_card)}}):e(wc_pagseguro_params.invalid_card)}),a("form.checkout").on("checkout_place_order_pagseguro",function(){return i()}),a("form#order_review").submit(function(){return i()})):a("body").on("updated_checkout",function(){a("#pagseguro-payment-form").remove()})})}(jQuery);
|
includes/class-wc-pagseguro-api.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
* WooCommerce PagSeguro API class
|
| 4 |
*
|
| 5 |
* @package WooCommerce_PagSeguro/Classes/API
|
| 6 |
-
* @version 2.
|
| 7 |
*/
|
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) {
|
|
@@ -387,7 +387,7 @@ class WC_PagSeguro_API {
|
|
| 387 |
foreach ( $order->get_items() as $order_item ) {
|
| 388 |
if ( $order_item['qty'] ) {
|
| 389 |
$item_total = $order->get_item_total( $order_item, false );
|
| 390 |
-
if ( 0 >= $item_total ) {
|
| 391 |
continue;
|
| 392 |
}
|
| 393 |
|
|
@@ -415,6 +415,10 @@ class WC_PagSeguro_API {
|
|
| 415 |
// Fees.
|
| 416 |
if ( 0 < count( $order->get_fees() ) ) {
|
| 417 |
foreach ( $order->get_fees() as $fee ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 418 |
$items[] = array(
|
| 419 |
'description' => $this->sanitize_description( $fee['name'] ),
|
| 420 |
'amount' => $this->money_format( $fee['line_total'] ),
|
|
@@ -426,9 +430,14 @@ class WC_PagSeguro_API {
|
|
| 426 |
// Taxes.
|
| 427 |
if ( 0 < count( $order->get_taxes() ) ) {
|
| 428 |
foreach ( $order->get_taxes() as $tax ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 429 |
$items[] = array(
|
| 430 |
'description' => $this->sanitize_description( $tax['label'] ),
|
| 431 |
-
'amount' => $this->money_format( $
|
| 432 |
'quantity' => 1,
|
| 433 |
);
|
| 434 |
}
|
|
@@ -469,9 +478,18 @@ class WC_PagSeguro_API {
|
|
| 469 |
// Creates the checkout xml.
|
| 470 |
$xml = new WC_PagSeguro_XML( '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><checkout></checkout>' );
|
| 471 |
$xml->add_currency( get_woocommerce_currency() );
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 475 |
$xml->add_items( $data['items'] );
|
| 476 |
$xml->add_extra_amount( $data['extra_amount'] );
|
| 477 |
|
|
@@ -508,15 +526,23 @@ class WC_PagSeguro_API {
|
|
| 508 |
$xml = new WC_PagSeguro_XML( '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><payment></payment>' );
|
| 509 |
$xml->add_mode( 'default' );
|
| 510 |
$xml->add_method( $method );
|
| 511 |
-
$xml->add_sender_data( $order, $hash );
|
| 512 |
$xml->add_currency( get_woocommerce_currency() );
|
| 513 |
if ( ! in_array( $this->is_localhost(), array( 'localhost', '127.0.0.1' ) ) ) {
|
| 514 |
$xml->add_notification_url( WC()->api_request_url( 'WC_PagSeguro_Gateway' ) );
|
| 515 |
}
|
| 516 |
$xml->add_items( $data['items'] );
|
| 517 |
$xml->add_extra_amount( $data['extra_amount'] );
|
| 518 |
-
|
| 519 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 520 |
|
| 521 |
// Items related to the payment method.
|
| 522 |
if ( 'creditCard' == $method ) {
|
|
@@ -532,7 +558,12 @@ class WC_PagSeguro_API {
|
|
| 532 |
'phone' => isset( $posted['pagseguro_card_holder_phone'] ) ? sanitize_text_field( $posted['pagseguro_card_holder_phone'] ) : '',
|
| 533 |
);
|
| 534 |
|
| 535 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 536 |
} elseif ( 'eft' == $method ) {
|
| 537 |
$bank_name = isset( $posted['pagseguro_bank_transfer'] ) ? sanitize_text_field( $posted['pagseguro_bank_transfer'] ) : '';
|
| 538 |
$xml->add_bank_data( $bank_name );
|
| 3 |
* WooCommerce PagSeguro API class
|
| 4 |
*
|
| 5 |
* @package WooCommerce_PagSeguro/Classes/API
|
| 6 |
+
* @version 2.12.0
|
| 7 |
*/
|
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) {
|
| 387 |
foreach ( $order->get_items() as $order_item ) {
|
| 388 |
if ( $order_item['qty'] ) {
|
| 389 |
$item_total = $order->get_item_total( $order_item, false );
|
| 390 |
+
if ( 0 >= (float) $item_total ) {
|
| 391 |
continue;
|
| 392 |
}
|
| 393 |
|
| 415 |
// Fees.
|
| 416 |
if ( 0 < count( $order->get_fees() ) ) {
|
| 417 |
foreach ( $order->get_fees() as $fee ) {
|
| 418 |
+
if ( 0 >= (float) $fee['line_total'] ) {
|
| 419 |
+
continue;
|
| 420 |
+
}
|
| 421 |
+
|
| 422 |
$items[] = array(
|
| 423 |
'description' => $this->sanitize_description( $fee['name'] ),
|
| 424 |
'amount' => $this->money_format( $fee['line_total'] ),
|
| 430 |
// Taxes.
|
| 431 |
if ( 0 < count( $order->get_taxes() ) ) {
|
| 432 |
foreach ( $order->get_taxes() as $tax ) {
|
| 433 |
+
$tax_total = $tax['tax_amount'] + $tax['shipping_tax_amount'];
|
| 434 |
+
if ( 0 >= (float) $tax_total ) {
|
| 435 |
+
continue;
|
| 436 |
+
}
|
| 437 |
+
|
| 438 |
$items[] = array(
|
| 439 |
'description' => $this->sanitize_description( $tax['label'] ),
|
| 440 |
+
'amount' => $this->money_format( $tax_total ),
|
| 441 |
'quantity' => 1,
|
| 442 |
);
|
| 443 |
}
|
| 478 |
// Creates the checkout xml.
|
| 479 |
$xml = new WC_PagSeguro_XML( '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><checkout></checkout>' );
|
| 480 |
$xml->add_currency( get_woocommerce_currency() );
|
| 481 |
+
|
| 482 |
+
// WooCommerce 3.0 or later.
|
| 483 |
+
if ( method_exists( $order, 'get_id' ) ) {
|
| 484 |
+
$xml->add_reference( $this->gateway->invoice_prefix . $order->get_id() );
|
| 485 |
+
$xml->add_sender_data( $order );
|
| 486 |
+
$xml->add_shipping_data( $order, $ship_to, $data['shipping_cost'] );
|
| 487 |
+
} else {
|
| 488 |
+
$xml->add_reference( $this->gateway->invoice_prefix . $order->id );
|
| 489 |
+
$xml->add_legacy_sender_data( $order );
|
| 490 |
+
$xml->add_legacy_shipping_data( $order, $ship_to, $data['shipping_cost'] );
|
| 491 |
+
}
|
| 492 |
+
|
| 493 |
$xml->add_items( $data['items'] );
|
| 494 |
$xml->add_extra_amount( $data['extra_amount'] );
|
| 495 |
|
| 526 |
$xml = new WC_PagSeguro_XML( '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><payment></payment>' );
|
| 527 |
$xml->add_mode( 'default' );
|
| 528 |
$xml->add_method( $method );
|
|
|
|
| 529 |
$xml->add_currency( get_woocommerce_currency() );
|
| 530 |
if ( ! in_array( $this->is_localhost(), array( 'localhost', '127.0.0.1' ) ) ) {
|
| 531 |
$xml->add_notification_url( WC()->api_request_url( 'WC_PagSeguro_Gateway' ) );
|
| 532 |
}
|
| 533 |
$xml->add_items( $data['items'] );
|
| 534 |
$xml->add_extra_amount( $data['extra_amount'] );
|
| 535 |
+
|
| 536 |
+
// WooCommerce 3.0 or later.
|
| 537 |
+
if ( method_exists( $order, 'get_id' ) ) {
|
| 538 |
+
$xml->add_reference( $this->gateway->invoice_prefix . $order->get_id() );
|
| 539 |
+
$xml->add_sender_data( $order, $hash );
|
| 540 |
+
$xml->add_shipping_data( $order, $ship_to, $data['shipping_cost'] );
|
| 541 |
+
} else {
|
| 542 |
+
$xml->add_reference( $this->gateway->invoice_prefix . $order->id );
|
| 543 |
+
$xml->add_legacy_sender_data( $order, $hash );
|
| 544 |
+
$xml->add_legacy_shipping_data( $order, $ship_to, $data['shipping_cost'] );
|
| 545 |
+
}
|
| 546 |
|
| 547 |
// Items related to the payment method.
|
| 548 |
if ( 'creditCard' == $method ) {
|
| 558 |
'phone' => isset( $posted['pagseguro_card_holder_phone'] ) ? sanitize_text_field( $posted['pagseguro_card_holder_phone'] ) : '',
|
| 559 |
);
|
| 560 |
|
| 561 |
+
// WooCommerce 3.0 or later.
|
| 562 |
+
if ( method_exists( $order, 'get_id' ) ) {
|
| 563 |
+
$xml->add_credit_card_data( $order, $credit_card_token, $installment, $holder_data );
|
| 564 |
+
} else {
|
| 565 |
+
$xml->add_legacy_credit_card_data( $order, $credit_card_token, $installment, $holder_data );
|
| 566 |
+
}
|
| 567 |
} elseif ( 'eft' == $method ) {
|
| 568 |
$bank_name = isset( $posted['pagseguro_bank_transfer'] ) ? sanitize_text_field( $posted['pagseguro_bank_transfer'] ) : '';
|
| 569 |
$xml->add_bank_data( $bank_name );
|
includes/class-wc-pagseguro-gateway.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
* WooCommerce PagSeguro Gateway class
|
| 4 |
*
|
| 5 |
* @package WooCommerce_PagSeguro/Classes/Gateway
|
| 6 |
-
* @version 2.
|
| 7 |
*/
|
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) {
|
|
@@ -360,7 +360,7 @@ class WC_PagSeguro_Gateway extends WC_Payment_Gateway {
|
|
| 360 |
* @return array
|
| 361 |
*/
|
| 362 |
public function process_payment( $order_id ) {
|
| 363 |
-
$order =
|
| 364 |
|
| 365 |
if ( 'lightbox' != $this->method ) {
|
| 366 |
if ( isset( $_POST['pagseguro_sender_hash'] ) && 'transparent' == $this->method ) {
|
|
@@ -407,7 +407,7 @@ class WC_PagSeguro_Gateway extends WC_Payment_Gateway {
|
|
| 407 |
* @param int $order_id Order ID.
|
| 408 |
*/
|
| 409 |
public function receipt_page( $order_id ) {
|
| 410 |
-
$order =
|
| 411 |
$request_data = $_POST;
|
| 412 |
if ( isset( $_GET['use_shipping'] ) && true == $_GET['use_shipping'] ) {
|
| 413 |
$request_data['ship_to_different_address'] = true;
|
|
@@ -462,91 +462,85 @@ class WC_PagSeguro_Gateway extends WC_Payment_Gateway {
|
|
| 462 |
}
|
| 463 |
}
|
| 464 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 465 |
/**
|
| 466 |
* Update order status.
|
| 467 |
*
|
| 468 |
* @param array $posted PagSeguro post data.
|
| 469 |
*/
|
| 470 |
public function update_order_status( $posted ) {
|
| 471 |
-
|
| 472 |
if ( isset( $posted->reference ) ) {
|
| 473 |
-
$
|
| 474 |
-
$order
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 475 |
|
| 476 |
// Checks whether the invoice number matches the order.
|
| 477 |
// If true processes the payment.
|
| 478 |
-
if ( $
|
| 479 |
-
|
| 480 |
-
if ( 'yes' == $this->debug ) {
|
| 481 |
$this->log->add( $this->id, 'PagSeguro payment status for order ' . $order->get_order_number() . ' is: ' . intval( $posted->status ) );
|
| 482 |
}
|
| 483 |
|
| 484 |
-
//
|
| 485 |
-
$
|
| 486 |
-
'type' => '',
|
| 487 |
-
'method' => '',
|
| 488 |
-
'installments' => '',
|
| 489 |
-
'link' => '',
|
| 490 |
-
);
|
| 491 |
-
|
| 492 |
-
if ( isset( $posted->code ) ) {
|
| 493 |
-
update_post_meta(
|
| 494 |
-
$order->id,
|
| 495 |
-
__( 'PagSeguro Transaction ID', 'woocommerce-pagseguro' ),
|
| 496 |
-
(string) $posted->code
|
| 497 |
-
);
|
| 498 |
-
}
|
| 499 |
-
if ( isset( $posted->sender->email ) ) {
|
| 500 |
-
update_post_meta(
|
| 501 |
-
$order->id,
|
| 502 |
-
__( 'Payer email', 'woocommerce-pagseguro' ),
|
| 503 |
-
(string) $posted->sender->email
|
| 504 |
-
);
|
| 505 |
-
}
|
| 506 |
-
if ( isset( $posted->sender->name ) ) {
|
| 507 |
-
update_post_meta(
|
| 508 |
-
$order->id,
|
| 509 |
-
__( 'Payer name', 'woocommerce-pagseguro' ),
|
| 510 |
-
(string) $posted->sender->name
|
| 511 |
-
);
|
| 512 |
-
}
|
| 513 |
-
if ( isset( $posted->paymentMethod->type ) ) {
|
| 514 |
-
$order_details['type'] = intval( $posted->paymentMethod->type );
|
| 515 |
-
update_post_meta(
|
| 516 |
-
$order->id,
|
| 517 |
-
__( 'Payment type', 'woocommerce-pagseguro' ),
|
| 518 |
-
$this->api->get_payment_name_by_type( $order_details['type'] )
|
| 519 |
-
);
|
| 520 |
-
}
|
| 521 |
-
if ( isset( $posted->paymentMethod->code ) ) {
|
| 522 |
-
$order_details['method'] = $this->api->get_payment_method_name( intval( $posted->paymentMethod->code ) );
|
| 523 |
-
update_post_meta(
|
| 524 |
-
$order->id,
|
| 525 |
-
__( 'Payment method', 'woocommerce-pagseguro' ),
|
| 526 |
-
$order_details['method']
|
| 527 |
-
);
|
| 528 |
-
}
|
| 529 |
-
if ( isset( $posted->installmentCount ) ) {
|
| 530 |
-
$order_details['installments'] = (string) $posted->installmentCount;
|
| 531 |
-
update_post_meta(
|
| 532 |
-
$order->id,
|
| 533 |
-
__( 'Installments', 'woocommerce-pagseguro' ),
|
| 534 |
-
$order_details['installments']
|
| 535 |
-
);
|
| 536 |
-
}
|
| 537 |
-
if ( isset( $posted->paymentLink ) ) {
|
| 538 |
-
$order_details['link'] = (string) $posted->paymentLink;
|
| 539 |
-
update_post_meta(
|
| 540 |
-
$order->id,
|
| 541 |
-
__( 'Payment url', 'woocommerce-pagseguro' ),
|
| 542 |
-
$order_details['link']
|
| 543 |
-
);
|
| 544 |
-
}
|
| 545 |
-
|
| 546 |
-
// Save/update payment information for transparente checkout.
|
| 547 |
-
if ( 'transparent' == $this->method ) {
|
| 548 |
-
update_post_meta( $order->id, '_wc_pagseguro_payment_data', $order_details );
|
| 549 |
-
}
|
| 550 |
|
| 551 |
switch ( intval( $posted->status ) ) {
|
| 552 |
case 1 :
|
|
@@ -560,11 +554,8 @@ class WC_PagSeguro_Gateway extends WC_Payment_Gateway {
|
|
| 560 |
case 3 :
|
| 561 |
$order->add_order_note( __( 'PagSeguro: Payment approved.', 'woocommerce-pagseguro' ) );
|
| 562 |
|
| 563 |
-
// For WooCommerce 2.2 or later.
|
| 564 |
-
add_post_meta( $order->id, '_transaction_id', (string) $posted->code, true );
|
| 565 |
-
|
| 566 |
// Changing the order for processing and reduces the stock.
|
| 567 |
-
$order->payment_complete();
|
| 568 |
|
| 569 |
break;
|
| 570 |
case 4 :
|
|
@@ -595,11 +586,10 @@ class WC_PagSeguro_Gateway extends WC_Payment_Gateway {
|
|
| 595 |
break;
|
| 596 |
|
| 597 |
default :
|
| 598 |
-
// No action xD.
|
| 599 |
break;
|
| 600 |
}
|
| 601 |
} else {
|
| 602 |
-
if ( 'yes'
|
| 603 |
$this->log->add( $this->id, 'Error: Order Key does not match with PagSeguro reference.' );
|
| 604 |
}
|
| 605 |
}
|
|
@@ -612,7 +602,13 @@ class WC_PagSeguro_Gateway extends WC_Payment_Gateway {
|
|
| 612 |
* @param int $order_id Order ID.
|
| 613 |
*/
|
| 614 |
public function thankyou_page( $order_id ) {
|
| 615 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 616 |
|
| 617 |
if ( isset( $data['type'] ) ) {
|
| 618 |
wc_get_template( 'payment-instructions.php', array(
|
|
@@ -634,11 +630,20 @@ class WC_PagSeguro_Gateway extends WC_Payment_Gateway {
|
|
| 634 |
* @return string Payment instructions.
|
| 635 |
*/
|
| 636 |
public function email_instructions( $order, $sent_to_admin, $plain_text = false ) {
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
|
|
|
|
|
|
| 640 |
|
| 641 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 642 |
|
| 643 |
if ( isset( $data['type'] ) ) {
|
| 644 |
if ( $plain_text ) {
|
| 3 |
* WooCommerce PagSeguro Gateway class
|
| 4 |
*
|
| 5 |
* @package WooCommerce_PagSeguro/Classes/Gateway
|
| 6 |
+
* @version 2.12.0
|
| 7 |
*/
|
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) {
|
| 360 |
* @return array
|
| 361 |
*/
|
| 362 |
public function process_payment( $order_id ) {
|
| 363 |
+
$order = wc_get_order( $order_id );
|
| 364 |
|
| 365 |
if ( 'lightbox' != $this->method ) {
|
| 366 |
if ( isset( $_POST['pagseguro_sender_hash'] ) && 'transparent' == $this->method ) {
|
| 407 |
* @param int $order_id Order ID.
|
| 408 |
*/
|
| 409 |
public function receipt_page( $order_id ) {
|
| 410 |
+
$order = wc_get_order( $order_id );
|
| 411 |
$request_data = $_POST;
|
| 412 |
if ( isset( $_GET['use_shipping'] ) && true == $_GET['use_shipping'] ) {
|
| 413 |
$request_data['ship_to_different_address'] = true;
|
| 462 |
}
|
| 463 |
}
|
| 464 |
|
| 465 |
+
/**
|
| 466 |
+
* Save payment meta data.
|
| 467 |
+
*
|
| 468 |
+
* @param WC_Order $order Order instance.
|
| 469 |
+
* @param array $posted Posted data.
|
| 470 |
+
*/
|
| 471 |
+
protected function save_payment_meta_data( $order, $posted ) {
|
| 472 |
+
$meta_data = array();
|
| 473 |
+
$payment_data = array(
|
| 474 |
+
'type' => '',
|
| 475 |
+
'method' => '',
|
| 476 |
+
'installments' => '',
|
| 477 |
+
'link' => '',
|
| 478 |
+
);
|
| 479 |
+
|
| 480 |
+
if ( isset( $posted->sender->email ) ) {
|
| 481 |
+
$meta_data[ __( 'Payer email', 'woocommerce-pagseguro' ) ] = sanitize_text_field( (string) $posted->sender->email );
|
| 482 |
+
}
|
| 483 |
+
if ( isset( $posted->sender->name ) ) {
|
| 484 |
+
$meta_data[ __( 'Payer name', 'woocommerce-pagseguro' ) ] = sanitize_text_field( (string) $posted->sender->name );
|
| 485 |
+
}
|
| 486 |
+
if ( isset( $posted->paymentMethod->type ) ) {
|
| 487 |
+
$payment_data['type'] = intval( $posted->paymentMethod->type );
|
| 488 |
+
$meta_data[ __( 'Payment type', 'woocommerce-pagseguro' ) ] = $this->api->get_payment_name_by_type( $payment_data['type'] );
|
| 489 |
+
}
|
| 490 |
+
if ( isset( $posted->paymentMethod->code ) ) {
|
| 491 |
+
$payment_data['method'] = $this->api->get_payment_method_name( intval( $posted->paymentMethod->code ) );
|
| 492 |
+
$meta_data[ __( 'Payment method', 'woocommerce-pagseguro' ) ] = $payment_data['method'];
|
| 493 |
+
}
|
| 494 |
+
if ( isset( $posted->installmentCount ) ) {
|
| 495 |
+
$payment_data['installments'] = sanitize_text_field( (string) $posted->installmentCount );
|
| 496 |
+
$meta_data[ __( 'Payment method', 'woocommerce-pagseguro' ) ] = $payment_data['installments'];
|
| 497 |
+
}
|
| 498 |
+
if ( isset( $posted->paymentLink ) ) {
|
| 499 |
+
$payment_data['link'] = sanitize_text_field( (string) $posted->paymentLink );
|
| 500 |
+
$meta_data[ __( 'Payment method', 'woocommerce-pagseguro' ) ] = $payment_data['link'];
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
$meta_data['_wc_pagseguro_payment_data'] = $payment_data;
|
| 504 |
+
|
| 505 |
+
// WooCommerce 3.0 or later.
|
| 506 |
+
if ( method_exists( $order, 'update_meta_data' ) ) {
|
| 507 |
+
foreach ( $meta_data as $key => $value ) {
|
| 508 |
+
$order->update_meta_data( $key, $value );
|
| 509 |
+
}
|
| 510 |
+
$order->save();
|
| 511 |
+
} else {
|
| 512 |
+
foreach ( $meta_data as $key => $value ) {
|
| 513 |
+
update_post_meta( $order->id, $key, $value );
|
| 514 |
+
}
|
| 515 |
+
}
|
| 516 |
+
}
|
| 517 |
+
|
| 518 |
/**
|
| 519 |
* Update order status.
|
| 520 |
*
|
| 521 |
* @param array $posted PagSeguro post data.
|
| 522 |
*/
|
| 523 |
public function update_order_status( $posted ) {
|
|
|
|
| 524 |
if ( isset( $posted->reference ) ) {
|
| 525 |
+
$id = (int) str_replace( $this->invoice_prefix, '', $posted->reference );
|
| 526 |
+
$order = wc_get_order( $id );
|
| 527 |
+
|
| 528 |
+
// Check if order exists.
|
| 529 |
+
if ( ! $order ) {
|
| 530 |
+
return;
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
+
$order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
|
| 534 |
|
| 535 |
// Checks whether the invoice number matches the order.
|
| 536 |
// If true processes the payment.
|
| 537 |
+
if ( $order_id === $id ) {
|
| 538 |
+
if ( 'yes' === $this->debug ) {
|
|
|
|
| 539 |
$this->log->add( $this->id, 'PagSeguro payment status for order ' . $order->get_order_number() . ' is: ' . intval( $posted->status ) );
|
| 540 |
}
|
| 541 |
|
| 542 |
+
// Save meta data.
|
| 543 |
+
$this->save_payment_meta_data( $order, $posted );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 544 |
|
| 545 |
switch ( intval( $posted->status ) ) {
|
| 546 |
case 1 :
|
| 554 |
case 3 :
|
| 555 |
$order->add_order_note( __( 'PagSeguro: Payment approved.', 'woocommerce-pagseguro' ) );
|
| 556 |
|
|
|
|
|
|
|
|
|
|
| 557 |
// Changing the order for processing and reduces the stock.
|
| 558 |
+
$order->payment_complete( $posted->code );
|
| 559 |
|
| 560 |
break;
|
| 561 |
case 4 :
|
| 586 |
break;
|
| 587 |
|
| 588 |
default :
|
|
|
|
| 589 |
break;
|
| 590 |
}
|
| 591 |
} else {
|
| 592 |
+
if ( 'yes' === $this->debug ) {
|
| 593 |
$this->log->add( $this->id, 'Error: Order Key does not match with PagSeguro reference.' );
|
| 594 |
}
|
| 595 |
}
|
| 602 |
* @param int $order_id Order ID.
|
| 603 |
*/
|
| 604 |
public function thankyou_page( $order_id ) {
|
| 605 |
+
$order = wc_get_order( $order_id );
|
| 606 |
+
// WooCommerce 3.0 or later.
|
| 607 |
+
if ( method_exists( $order, 'get_meta' ) ) {
|
| 608 |
+
$data = $order->get_meta( '_wc_pagseguro_payment_data' );
|
| 609 |
+
} else {
|
| 610 |
+
$data = get_post_meta( $order->id, '_wc_pagseguro_payment_data', true );
|
| 611 |
+
}
|
| 612 |
|
| 613 |
if ( isset( $data['type'] ) ) {
|
| 614 |
wc_get_template( 'payment-instructions.php', array(
|
| 630 |
* @return string Payment instructions.
|
| 631 |
*/
|
| 632 |
public function email_instructions( $order, $sent_to_admin, $plain_text = false ) {
|
| 633 |
+
// WooCommerce 3.0 or later.
|
| 634 |
+
if ( method_exists( $order, 'get_meta' ) ) {
|
| 635 |
+
if ( $sent_to_admin || 'on-hold' !== $order->get_status() || $this->id !== $order->get_payment_method() ) {
|
| 636 |
+
return;
|
| 637 |
+
}
|
| 638 |
|
| 639 |
+
$data = $order->get_meta( '_wc_pagseguro_payment_data' );
|
| 640 |
+
} else {
|
| 641 |
+
if ( $sent_to_admin || 'on-hold' !== $order->status || $this->id !== $order->payment_method ) {
|
| 642 |
+
return;
|
| 643 |
+
}
|
| 644 |
+
|
| 645 |
+
$data = get_post_meta( $order->id, '_wc_pagseguro_payment_data', true );
|
| 646 |
+
}
|
| 647 |
|
| 648 |
if ( isset( $data['type'] ) ) {
|
| 649 |
if ( $plain_text ) {
|
includes/class-wc-pagseguro-xml.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
* WooCommerce PagSeguro SimpleXMLElement class
|
| 4 |
*
|
| 5 |
* @package WooCommerce_PagSeguro/Classes/XML
|
| 6 |
-
* @version 2.
|
| 7 |
*/
|
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) {
|
|
@@ -111,12 +111,12 @@ class WC_PagSeguro_XML extends SimpleXMLElement {
|
|
| 111 |
}
|
| 112 |
|
| 113 |
/**
|
| 114 |
-
* Add sender data.
|
| 115 |
*
|
| 116 |
* @param WC_Order $order Order data.
|
| 117 |
* @param string $hash Sender hash.
|
| 118 |
*/
|
| 119 |
-
public function
|
| 120 |
$name = $order->billing_first_name . ' ' . $order->billing_last_name;
|
| 121 |
$sender = $this->addChild( 'sender' );
|
| 122 |
$sender->addChild( 'email' )->add_cdata( $order->billing_email );
|
|
@@ -153,13 +153,55 @@ class WC_PagSeguro_XML extends SimpleXMLElement {
|
|
| 153 |
}
|
| 154 |
|
| 155 |
/**
|
| 156 |
-
* Add
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
*
|
| 158 |
* @param WC_Order $order Order data.
|
| 159 |
* @param bool $ship_to Ship to (true = shipping address, false = billing address).
|
| 160 |
* @param float $shipping_cost Shipping cost.
|
| 161 |
*/
|
| 162 |
-
public function
|
| 163 |
$type = ( $ship_to ) ? 'shipping' : 'billing';
|
| 164 |
|
| 165 |
$shipping = $this->addChild( 'shipping' );
|
|
@@ -190,6 +232,44 @@ class WC_PagSeguro_XML extends SimpleXMLElement {
|
|
| 190 |
$shipping->addChild( 'cost', $shipping_cost );
|
| 191 |
}
|
| 192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
/**
|
| 194 |
* Add order items.
|
| 195 |
*
|
|
@@ -220,14 +300,14 @@ class WC_PagSeguro_XML extends SimpleXMLElement {
|
|
| 220 |
}
|
| 221 |
|
| 222 |
/**
|
| 223 |
-
* Add credit card data.
|
| 224 |
*
|
| 225 |
* @param WC_Order $order Order data.
|
| 226 |
* @param string $credit_card_token Credit card token.
|
| 227 |
* @param array $installment_data Installment data (quantity and value).
|
| 228 |
* @param array $holder_data Holder data (name, cpf, birth_date and phone).
|
| 229 |
*/
|
| 230 |
-
public function
|
| 231 |
$credit_card = $this->addChild( 'creditCard' );
|
| 232 |
|
| 233 |
$credit_card->addChild( 'token', $credit_card_token );
|
|
@@ -265,6 +345,52 @@ class WC_PagSeguro_XML extends SimpleXMLElement {
|
|
| 265 |
$billing_address->addChild( 'postalCode', $this->get_numbers( $order->billing_postcode ) );
|
| 266 |
}
|
| 267 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
/**
|
| 269 |
* Add bank data.
|
| 270 |
*
|
| 3 |
* WooCommerce PagSeguro SimpleXMLElement class
|
| 4 |
*
|
| 5 |
* @package WooCommerce_PagSeguro/Classes/XML
|
| 6 |
+
* @version 2.12.0
|
| 7 |
*/
|
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) {
|
| 111 |
}
|
| 112 |
|
| 113 |
/**
|
| 114 |
+
* Legacy - Add sender data.
|
| 115 |
*
|
| 116 |
* @param WC_Order $order Order data.
|
| 117 |
* @param string $hash Sender hash.
|
| 118 |
*/
|
| 119 |
+
public function add_legacy_sender_data( $order, $hash = '' ) {
|
| 120 |
$name = $order->billing_first_name . ' ' . $order->billing_last_name;
|
| 121 |
$sender = $this->addChild( 'sender' );
|
| 122 |
$sender->addChild( 'email' )->add_cdata( $order->billing_email );
|
| 153 |
}
|
| 154 |
|
| 155 |
/**
|
| 156 |
+
* Add sender data.
|
| 157 |
+
*
|
| 158 |
+
* @param WC_Order $order Order data.
|
| 159 |
+
* @param string $hash Sender hash.
|
| 160 |
+
*/
|
| 161 |
+
public function add_sender_data( $order, $hash = '' ) {
|
| 162 |
+
$name = $order->get_billing_first_name() . ' ' . $order->get_billing_last_name();
|
| 163 |
+
$sender = $this->addChild( 'sender' );
|
| 164 |
+
$sender->addChild( 'email' )->add_cdata( $order->get_billing_email() );
|
| 165 |
+
|
| 166 |
+
$wcbcf_settings = get_option( 'wcbcf_settings' );
|
| 167 |
+
$wcbcf_settings = isset( $wcbcf_settings['person_type'] ) ? intval( $wcbcf_settings['person_type'] ) : 0;
|
| 168 |
+
|
| 169 |
+
if ( ( 0 === $wcbcf_settings || 2 === $wcbcf_settings ) && '' !== $order->get_meta( '_billing_cpf' ) ) {
|
| 170 |
+
$this->add_cpf( $order->get_meta( '_billing_cpf' ), $sender );
|
| 171 |
+
} else if ( ( 0 === $wcbcf_settings || 3 === $wcbcf_settings ) && '' !== $order->get_meta( '_billing_cnpj' ) ) {
|
| 172 |
+
$name = $order->get_billing_company();
|
| 173 |
+
$this->add_cnpj( $order->get_meta( '_billing_cnpj' ), $sender );
|
| 174 |
+
} else if ( '' !== $order->get_meta( '_billing_persontype' ) ) {
|
| 175 |
+
if ( 1 === intval( $order->get_meta( '_billing_persontype' ) ) && '' !== $order->get_meta( '_billing_cpf' ) ) {
|
| 176 |
+
$this->add_cpf( $order->get_meta( '_billing_cpf' ), $sender );
|
| 177 |
+
} else if ( 2 === intval( $order->get_meta( '_billing_persontype' ) ) && '' !== $order->get_meta( '_billing_cnpj' ) ) {
|
| 178 |
+
$name = $order->get_billing_company();
|
| 179 |
+
$this->add_cnpj( $order->get_meta( '_billing_cnpj' ), $sender );
|
| 180 |
+
}
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
$sender->addChild( 'name' )->add_cdata( $name );
|
| 184 |
+
|
| 185 |
+
if ( '' !== $order->get_billing_phone() ) {
|
| 186 |
+
$phone_number = $this->get_numbers( $order->get_billing_phone() );
|
| 187 |
+
$phone = $sender->addChild( 'phone' );
|
| 188 |
+
$phone->addChild( 'areaCode', substr( $phone_number, 0, 2 ) );
|
| 189 |
+
$phone->addChild( 'number', substr( $phone_number, 2 ) );
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
if ( '' != $hash ) {
|
| 193 |
+
$sender->addChild( 'hash', $hash );
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
/**
|
| 198 |
+
* Legacy - Add shipping data.
|
| 199 |
*
|
| 200 |
* @param WC_Order $order Order data.
|
| 201 |
* @param bool $ship_to Ship to (true = shipping address, false = billing address).
|
| 202 |
* @param float $shipping_cost Shipping cost.
|
| 203 |
*/
|
| 204 |
+
public function add_legacy_shipping_data( $order, $ship_to = false, $shipping_cost = 0 ) {
|
| 205 |
$type = ( $ship_to ) ? 'shipping' : 'billing';
|
| 206 |
|
| 207 |
$shipping = $this->addChild( 'shipping' );
|
| 232 |
$shipping->addChild( 'cost', $shipping_cost );
|
| 233 |
}
|
| 234 |
|
| 235 |
+
/**
|
| 236 |
+
* Add shipping data.
|
| 237 |
+
*
|
| 238 |
+
* @param WC_Order $order Order data.
|
| 239 |
+
* @param bool $ship_to Ship to (true = shipping address, false = billing address).
|
| 240 |
+
* @param float $shipping_cost Shipping cost.
|
| 241 |
+
*/
|
| 242 |
+
public function add_shipping_data( $order, $ship_to = false, $shipping_cost = 0 ) {
|
| 243 |
+
$type = ( $ship_to ) ? 'shipping' : 'billing';
|
| 244 |
+
|
| 245 |
+
$shipping = $this->addChild( 'shipping' );
|
| 246 |
+
$shipping->addChild( 'type', 3 );
|
| 247 |
+
|
| 248 |
+
if ( '' !== $order->{ 'get_' . $type . '_postcode' }() ) {
|
| 249 |
+
$address = $shipping->addChild( 'address' );
|
| 250 |
+
$address->addChild( 'street' )->add_cdata( $order->{ 'get_' . $type . '_address_1' }() );
|
| 251 |
+
|
| 252 |
+
if ( '' !== $order->get_meta( '_' . $type . '_number' ) ) {
|
| 253 |
+
$address->addChild( 'number', $order->get_meta( '_' . $type . '_number' ) );
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
if ( '' !== $order->{ 'get_' . $type . '_address_2' }() ) {
|
| 257 |
+
$address->addChild( 'complement' )->add_cdata( $order->{ 'get_' . $type . '_address_2' }() );
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
if ( '' !== $order->get_meta( '_' . $type . '_neighborhood' ) ) {
|
| 261 |
+
$address->addChild( 'district' )->add_cdata( $order->get_meta( '_' . $type . '_neighborhood' ) );
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
$address->addChild( 'postalCode', $this->get_numbers( $order->{ 'get_' . $type . '_postcode' }() ) );
|
| 265 |
+
$address->addChild( 'city' )->add_cdata( $order->{ 'get_' . $type . '_city' }() );
|
| 266 |
+
$address->addChild( 'state', $order->{ 'get_' . $type . '_state' }() );
|
| 267 |
+
$address->addChild( 'country', 'BRA' );
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
$shipping->addChild( 'cost', $shipping_cost );
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
/**
|
| 274 |
* Add order items.
|
| 275 |
*
|
| 300 |
}
|
| 301 |
|
| 302 |
/**
|
| 303 |
+
* Legacy - Add credit card data.
|
| 304 |
*
|
| 305 |
* @param WC_Order $order Order data.
|
| 306 |
* @param string $credit_card_token Credit card token.
|
| 307 |
* @param array $installment_data Installment data (quantity and value).
|
| 308 |
* @param array $holder_data Holder data (name, cpf, birth_date and phone).
|
| 309 |
*/
|
| 310 |
+
public function add_legacy_credit_card_data( $order, $credit_card_token, $installment_data, $holder_data ) {
|
| 311 |
$credit_card = $this->addChild( 'creditCard' );
|
| 312 |
|
| 313 |
$credit_card->addChild( 'token', $credit_card_token );
|
| 345 |
$billing_address->addChild( 'postalCode', $this->get_numbers( $order->billing_postcode ) );
|
| 346 |
}
|
| 347 |
|
| 348 |
+
/**
|
| 349 |
+
* Add credit card data.
|
| 350 |
+
*
|
| 351 |
+
* @param WC_Order $order Order data.
|
| 352 |
+
* @param string $credit_card_token Credit card token.
|
| 353 |
+
* @param array $installment_data Installment data (quantity and value).
|
| 354 |
+
* @param array $holder_data Holder data (name, cpf, birth_date and phone).
|
| 355 |
+
*/
|
| 356 |
+
public function add_credit_card_data( $order, $credit_card_token, $installment_data, $holder_data ) {
|
| 357 |
+
$credit_card = $this->addChild( 'creditCard' );
|
| 358 |
+
|
| 359 |
+
$credit_card->addChild( 'token', $credit_card_token );
|
| 360 |
+
|
| 361 |
+
$installment = $credit_card->addChild( 'installment' );
|
| 362 |
+
$installment->addChild( 'quantity', $installment_data['quantity'] );
|
| 363 |
+
$installment->addChild( 'value', $installment_data['value'] );
|
| 364 |
+
|
| 365 |
+
$holder = $credit_card->addChild( 'holder' );
|
| 366 |
+
$holder->addChild( 'name' )->add_cdata( $holder_data['name'] );
|
| 367 |
+
$documents = $holder->addChild( 'documents' );
|
| 368 |
+
$document = $documents->addChild( 'document' );
|
| 369 |
+
$document->addChild( 'type', 'CPF' );
|
| 370 |
+
$document->addChild( 'value', $this->get_numbers( $holder_data['cpf'] ) );
|
| 371 |
+
$holder->addChild( 'birthDate', str_replace( ' ', '', $holder_data['birth_date'] ) );
|
| 372 |
+
$phone_number = $this->get_numbers( $holder_data['phone'] );
|
| 373 |
+
$phone = $holder->addChild( 'phone' );
|
| 374 |
+
$phone->addChild( 'areaCode', substr( $phone_number, 0, 2 ) );
|
| 375 |
+
$phone->addChild( 'number', substr( $phone_number, 2 ) );
|
| 376 |
+
|
| 377 |
+
$billing_address = $credit_card->addChild( 'billingAddress' );
|
| 378 |
+
$billing_address->addChild( 'street' )->add_cdata( $order->get_billing_address_1() );
|
| 379 |
+
if ( '' !== $order->get_meta( '_billing_number' ) ) {
|
| 380 |
+
$billing_address->addChild( 'number', $order->get_meta( '_billing_number' ) );
|
| 381 |
+
}
|
| 382 |
+
if ( '' !== $order->get_billing_address_2() ) {
|
| 383 |
+
$billing_address->addChild( 'complement' )->add_cdata( $order->get_billing_address_2() );
|
| 384 |
+
}
|
| 385 |
+
if ( '' !== $order->get_meta( '_billing_neighborhood' ) ) {
|
| 386 |
+
$billing_address->addChild( 'district' )->add_cdata( $order->get_meta( '_billing_neighborhood' ) );
|
| 387 |
+
}
|
| 388 |
+
$billing_address->addChild( 'city' )->add_cdata( $order->get_billing_city() );
|
| 389 |
+
$billing_address->addChild( 'state', $order->get_billing_state() );
|
| 390 |
+
$billing_address->addChild( 'country', 'BRA' );
|
| 391 |
+
$billing_address->addChild( 'postalCode', $this->get_numbers( $order->get_billing_postcode() ) );
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
/**
|
| 395 |
* Add bank data.
|
| 396 |
*
|
languages/woocommerce-pagseguro.pot
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
# This file is distributed under the GPLv2 or later.
|
| 3 |
msgid ""
|
| 4 |
msgstr ""
|
| 5 |
-
"Project-Id-Version: WooCommerce PagSeguro 2.11.
|
| 6 |
"Report-Msgid-Bugs-To: "
|
| 7 |
"https://wordpress.org/support/plugin/woocommerce-pagseguro\n"
|
| 8 |
"POT-Creation-Date: 2017-01-18 00:15:30+00:00\n"
|
|
@@ -758,4 +758,4 @@ msgstr ""
|
|
| 758 |
|
| 759 |
#. Author URI of the plugin/theme
|
| 760 |
msgid "http://claudiosmweb.com/"
|
| 761 |
-
msgstr ""
|
| 2 |
# This file is distributed under the GPLv2 or later.
|
| 3 |
msgid ""
|
| 4 |
msgstr ""
|
| 5 |
+
"Project-Id-Version: WooCommerce PagSeguro 2.11.6\n"
|
| 6 |
"Report-Msgid-Bugs-To: "
|
| 7 |
"https://wordpress.org/support/plugin/woocommerce-pagseguro\n"
|
| 8 |
"POT-Creation-Date: 2017-01-18 00:15:30+00:00\n"
|
| 758 |
|
| 759 |
#. Author URI of the plugin/theme
|
| 760 |
msgid "http://claudiosmweb.com/"
|
| 761 |
+
msgstr ""
|
readme.txt
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
=== WooCommerce PagSeguro ===
|
| 2 |
Contributors: claudiosanches, Gabriel Reguly
|
| 3 |
-
Donate link:
|
| 4 |
Tags: woocommerce, pagseguro, payment
|
| 5 |
Requires at least: 4.0
|
| 6 |
Tested up to: 4.7
|
| 7 |
-
Stable tag: 2.
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
|
@@ -42,7 +42,7 @@ Além que é possível utilizar o novo [sandbox do PagSeguro](https://sandbox.pa
|
|
| 42 |
|
| 43 |
= Compatibilidade =
|
| 44 |
|
| 45 |
-
Compatível desde a versão 2.
|
| 46 |
|
| 47 |
Este plugin também é compatível com o [WooCommerce Extra Checkout Fields for Brazil](http://wordpress.org/plugins/woocommerce-extra-checkout-fields-for-brazil/), desta forma é possível enviar os campos de "CPF", "número do endereço" e "bairro" (para o Checkout Transparente é obrigatório o uso deste plugin).
|
| 48 |
|
|
@@ -189,7 +189,7 @@ Para produtos baixáveis a configuração padrão do WooCommerce é permitir o a
|
|
| 189 |
|
| 190 |
= Ao tentar finalizar a compra aparece a mensagem "PagSeguro: Um erro ocorreu ao processar o seu pagamento, por favor, tente novamente ou entre em contato para obter ajuda." o que fazer? =
|
| 191 |
|
| 192 |
-
Esta mensagem geralmente aparece por causa que não foi configurado um **Token válido**.
|
| 193 |
Gere um novo Token no PagSeguro em "Preferências" > "[Integrações](https://pagseguro.uol.com.br/preferencias/integracoes.jhtml)" e adicione ele nas configurações do plugin.
|
| 194 |
|
| 195 |
Outro erro comum é gerar um token e cadastrar nas configurações do plugin um e-mail que não é o proprietário do token, então tenha certeza que estes dados estão realmente corretos!
|
|
@@ -200,10 +200,10 @@ Se você tem certeza que o Token e Login estão corretos você deve acessar a p
|
|
| 200 |
|
| 201 |
Para quem estiver utilizando o **Checkout Transparente** é obrigatório o uso do plugin [WooCommerce Extra Checkout Fields for Brazil](http://wordpress.org/plugins/woocommerce-extra-checkout-fields-for-brazil/) para enviar o CPF ao PagSeguro, caso o contrário será impossível de finalizar o pedido, veja no [guia de instalação](http://wordpress.org/plugins/woocommerce-pagseguro/installation/) como fazer isso.
|
| 202 |
|
| 203 |
-
Por último é possível ativar a opção de **Log de depuração** nas configurações do plugin e tentar novamente fechar um pedido (você deve tentar fechar um pedido para que o log será gerado e o erro gravado nele).
|
| 204 |
Com o log é possível saber exatamente o que esta dando de errado com a sua instalação.
|
| 205 |
|
| 206 |
-
Caso você não entenda o conteúdo do log não tem problema, você pode me abrir um [tópico no fórum do plugin](https://wordpress.org/support/plugin/woocommerce-pagseguro#postform) com o link do log (utilize o [pastebin.com](http://pastebin.com) ou o [gist.github.com](http://gist.github.com) para salvar o conteúdo do log).
|
| 207 |
|
| 208 |
= O status do pedido não é alterado automaticamente? =
|
| 209 |
|
|
@@ -225,7 +225,7 @@ Sim, basta ativar esta nas opções do plugin.
|
|
| 225 |
|
| 226 |
= Funciona com o checkout transparente do PagSeguro? =
|
| 227 |
|
| 228 |
-
Sim, funciona. Você deve ativar nas opções do plugin.
|
| 229 |
Note que é necessário aprovação do PagSeguro para utilizar o Checkout Transparente, saiba mais em "[Como receber pagamentos pelo PagSeguro](https://pagseguro.uol.com.br/receba-pagamentos.jhtml)".
|
| 230 |
|
| 231 |
= Funciona com o Sandbox do PagSeguro? =
|
|
@@ -255,6 +255,12 @@ Por favor, caso você tenha algum problema com o funcionamento do plugin, [abra
|
|
| 255 |
|
| 256 |
== Changelog ==
|
| 257 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
= 2.11.5 - 2017/01/17 =
|
| 259 |
|
| 260 |
* Adicionada nota dizendo que o pedido esta sendo feito no Brasil durante o Checkout Transparente.
|
|
@@ -286,6 +292,6 @@ Por favor, caso você tenha algum problema com o funcionamento do plugin, [abra
|
|
| 286 |
|
| 287 |
== Upgrade Notice ==
|
| 288 |
|
| 289 |
-
= 2.
|
| 290 |
|
| 291 |
-
*
|
| 1 |
=== WooCommerce PagSeguro ===
|
| 2 |
Contributors: claudiosanches, Gabriel Reguly
|
| 3 |
+
Donate link: https://claudiosanches.com/doacoes/
|
| 4 |
Tags: woocommerce, pagseguro, payment
|
| 5 |
Requires at least: 4.0
|
| 6 |
Tested up to: 4.7
|
| 7 |
+
Stable tag: 2.12.0
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
| 42 |
|
| 43 |
= Compatibilidade =
|
| 44 |
|
| 45 |
+
Compatível desde a versão 2.4.x até 3.0.x do WooCommerce.
|
| 46 |
|
| 47 |
Este plugin também é compatível com o [WooCommerce Extra Checkout Fields for Brazil](http://wordpress.org/plugins/woocommerce-extra-checkout-fields-for-brazil/), desta forma é possível enviar os campos de "CPF", "número do endereço" e "bairro" (para o Checkout Transparente é obrigatório o uso deste plugin).
|
| 48 |
|
| 189 |
|
| 190 |
= Ao tentar finalizar a compra aparece a mensagem "PagSeguro: Um erro ocorreu ao processar o seu pagamento, por favor, tente novamente ou entre em contato para obter ajuda." o que fazer? =
|
| 191 |
|
| 192 |
+
Esta mensagem geralmente aparece por causa que não foi configurado um **Token válido**.
|
| 193 |
Gere um novo Token no PagSeguro em "Preferências" > "[Integrações](https://pagseguro.uol.com.br/preferencias/integracoes.jhtml)" e adicione ele nas configurações do plugin.
|
| 194 |
|
| 195 |
Outro erro comum é gerar um token e cadastrar nas configurações do plugin um e-mail que não é o proprietário do token, então tenha certeza que estes dados estão realmente corretos!
|
| 200 |
|
| 201 |
Para quem estiver utilizando o **Checkout Transparente** é obrigatório o uso do plugin [WooCommerce Extra Checkout Fields for Brazil](http://wordpress.org/plugins/woocommerce-extra-checkout-fields-for-brazil/) para enviar o CPF ao PagSeguro, caso o contrário será impossível de finalizar o pedido, veja no [guia de instalação](http://wordpress.org/plugins/woocommerce-pagseguro/installation/) como fazer isso.
|
| 202 |
|
| 203 |
+
Por último é possível ativar a opção de **Log de depuração** nas configurações do plugin e tentar novamente fechar um pedido (você deve tentar fechar um pedido para que o log será gerado e o erro gravado nele).
|
| 204 |
Com o log é possível saber exatamente o que esta dando de errado com a sua instalação.
|
| 205 |
|
| 206 |
+
Caso você não entenda o conteúdo do log não tem problema, você pode me abrir um [tópico no fórum do plugin](https://wordpress.org/support/plugin/woocommerce-pagseguro#postform) com o link do log (utilize o [pastebin.com](http://pastebin.com) ou o [gist.github.com](http://gist.github.com) para salvar o conteúdo do log).
|
| 207 |
|
| 208 |
= O status do pedido não é alterado automaticamente? =
|
| 209 |
|
| 225 |
|
| 226 |
= Funciona com o checkout transparente do PagSeguro? =
|
| 227 |
|
| 228 |
+
Sim, funciona. Você deve ativar nas opções do plugin.
|
| 229 |
Note que é necessário aprovação do PagSeguro para utilizar o Checkout Transparente, saiba mais em "[Como receber pagamentos pelo PagSeguro](https://pagseguro.uol.com.br/receba-pagamentos.jhtml)".
|
| 230 |
|
| 231 |
= Funciona com o Sandbox do PagSeguro? =
|
| 255 |
|
| 256 |
== Changelog ==
|
| 257 |
|
| 258 |
+
= 2.12.0 - 2017/04/04 =
|
| 259 |
+
|
| 260 |
+
* Adicionado suporte ao WooCommerce 3.0.
|
| 261 |
+
* Alterado o tipo dos campos para `tel` no Checkout Transparente. (Possível com a ajuda de [Thiago Guimarães](https://github.com/thiagogsr)).
|
| 262 |
+
* Correção nas máscaras do campos devido a mudança do plugin no [woocommerce-extra-checkout-fields-for-brazil](https://github.com/claudiosanches/woocommerce-extra-checkout-fields-for-brazil/pull/49). (Possível com a ajuda de [Thiago Guimarães](https://github.com/thiagogsr)).
|
| 263 |
+
|
| 264 |
= 2.11.5 - 2017/01/17 =
|
| 265 |
|
| 266 |
* Adicionada nota dizendo que o pedido esta sendo feito no Brasil durante o Checkout Transparente.
|
| 292 |
|
| 293 |
== Upgrade Notice ==
|
| 294 |
|
| 295 |
+
= 2.12.0 =
|
| 296 |
|
| 297 |
+
* Suporte ao WooCommerce 3.0, correção dos tipos de campo do Checkout Transparente e correção das máscaras.
|
templates/transparent-checkout-form.php
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
*
|
| 5 |
* @author Claudio_Sanches
|
| 6 |
* @package WooCommerce_PagSeguro/Templates
|
| 7 |
-
* @version 2.
|
| 8 |
*/
|
| 9 |
|
| 10 |
if ( ! defined( 'ABSPATH' ) ) {
|
|
@@ -38,16 +38,16 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
| 38 |
</p>
|
| 39 |
<p id="pagseguro-card-number-field" class="form-row form-row-last">
|
| 40 |
<label for="pagseguro-card-number"><?php _e( 'Card Number', 'woocommerce-pagseguro' ); ?> <span class="required">*</span></label>
|
| 41 |
-
<input id="pagseguro-card-number" class="input-text wc-credit-card-form-card-number" type="
|
| 42 |
</p>
|
| 43 |
<div class="clear"></div>
|
| 44 |
<p id="pagseguro-card-expiry-field" class="form-row form-row-first">
|
| 45 |
<label for="pagseguro-card-expiry"><?php _e( 'Expiry (MM/YYYY)', 'woocommerce-pagseguro' ); ?> <span class="required">*</span></label>
|
| 46 |
-
<input id="pagseguro-card-expiry" class="input-text wc-credit-card-form-card-expiry" type="
|
| 47 |
</p>
|
| 48 |
<p id="pagseguro-card-cvc-field" class="form-row form-row-last">
|
| 49 |
<label for="pagseguro-card-cvc"><?php _e( 'Security Code', 'woocommerce-pagseguro' ); ?> <span class="required">*</span></label>
|
| 50 |
-
<input id="pagseguro-card-cvc" class="input-text wc-credit-card-form-card-cvc" type="
|
| 51 |
</p>
|
| 52 |
<div class="clear"></div>
|
| 53 |
<p id="pagseguro-card-installments-field" class="form-row form-row-first">
|
|
@@ -58,16 +58,16 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
| 58 |
</p>
|
| 59 |
<p id="pagseguro-card-holder-cpf-field" class="form-row form-row-last">
|
| 60 |
<label for="pagseguro-card-holder-cpf"><?php _e( 'Card Holder CPF', 'woocommerce-pagseguro' ); ?> <span class="required">*</span></label>
|
| 61 |
-
<input id="pagseguro-card-holder-cpf" name="pagseguro_card_holder_cpf" class="input-text wecfb-cpf-field" type="
|
| 62 |
</p>
|
| 63 |
<div class="clear"></div>
|
| 64 |
<p id="pagseguro-card-holder-birth-date-field" class="form-row form-row-first">
|
| 65 |
<label for="pagseguro-card-holder-birth-date"><?php _e( 'Card Holder Birth Date', 'woocommerce-pagseguro' ); ?> <span class="required">*</span></label>
|
| 66 |
-
<input id="pagseguro-card-holder-birth-date" name="pagseguro_card_holder_birth_date" class="input-text" type="
|
| 67 |
</p>
|
| 68 |
<p id="pagseguro-card-holder-phone-field" class="form-row form-row-last">
|
| 69 |
<label for="pagseguro-card-holder-phone"><?php _e( 'Card Holder Phone', 'woocommerce-pagseguro' ); ?> <span class="required">*</span></label>
|
| 70 |
-
<input id="pagseguro-card-holder-phone" name="pagseguro_card_holder_phone" class="input-text" type="
|
| 71 |
</p>
|
| 72 |
<div class="clear"></div>
|
| 73 |
</div>
|
| 4 |
*
|
| 5 |
* @author Claudio_Sanches
|
| 6 |
* @package WooCommerce_PagSeguro/Templates
|
| 7 |
+
* @version 2.12.0
|
| 8 |
*/
|
| 9 |
|
| 10 |
if ( ! defined( 'ABSPATH' ) ) {
|
| 38 |
</p>
|
| 39 |
<p id="pagseguro-card-number-field" class="form-row form-row-last">
|
| 40 |
<label for="pagseguro-card-number"><?php _e( 'Card Number', 'woocommerce-pagseguro' ); ?> <span class="required">*</span></label>
|
| 41 |
+
<input id="pagseguro-card-number" class="input-text wc-credit-card-form-card-number" type="tel" maxlength="20" autocomplete="off" placeholder="•••• •••• •••• ••••" style="font-size: 1.5em; padding: 8px;" />
|
| 42 |
</p>
|
| 43 |
<div class="clear"></div>
|
| 44 |
<p id="pagseguro-card-expiry-field" class="form-row form-row-first">
|
| 45 |
<label for="pagseguro-card-expiry"><?php _e( 'Expiry (MM/YYYY)', 'woocommerce-pagseguro' ); ?> <span class="required">*</span></label>
|
| 46 |
+
<input id="pagseguro-card-expiry" class="input-text wc-credit-card-form-card-expiry" type="tel" autocomplete="off" placeholder="<?php _e( 'MM / YYYY', 'woocommerce-pagseguro' ); ?>" style="font-size: 1.5em; padding: 8px;" />
|
| 47 |
</p>
|
| 48 |
<p id="pagseguro-card-cvc-field" class="form-row form-row-last">
|
| 49 |
<label for="pagseguro-card-cvc"><?php _e( 'Security Code', 'woocommerce-pagseguro' ); ?> <span class="required">*</span></label>
|
| 50 |
+
<input id="pagseguro-card-cvc" class="input-text wc-credit-card-form-card-cvc" type="tel" autocomplete="off" placeholder="<?php _e( 'CVC', 'woocommerce-pagseguro' ); ?>" style="font-size: 1.5em; padding: 8px;" />
|
| 51 |
</p>
|
| 52 |
<div class="clear"></div>
|
| 53 |
<p id="pagseguro-card-installments-field" class="form-row form-row-first">
|
| 58 |
</p>
|
| 59 |
<p id="pagseguro-card-holder-cpf-field" class="form-row form-row-last">
|
| 60 |
<label for="pagseguro-card-holder-cpf"><?php _e( 'Card Holder CPF', 'woocommerce-pagseguro' ); ?> <span class="required">*</span></label>
|
| 61 |
+
<input id="pagseguro-card-holder-cpf" name="pagseguro_card_holder_cpf" class="input-text wecfb-cpf-field" type="tel" autocomplete="off" style="font-size: 1.5em; padding: 8px;" />
|
| 62 |
</p>
|
| 63 |
<div class="clear"></div>
|
| 64 |
<p id="pagseguro-card-holder-birth-date-field" class="form-row form-row-first">
|
| 65 |
<label for="pagseguro-card-holder-birth-date"><?php _e( 'Card Holder Birth Date', 'woocommerce-pagseguro' ); ?> <span class="required">*</span></label>
|
| 66 |
+
<input id="pagseguro-card-holder-birth-date" name="pagseguro_card_holder_birth_date" class="input-text" type="tel" autocomplete="off" placeholder="<?php _e( 'DD / MM / YYYY', 'woocommerce-pagseguro' ); ?>" style="font-size: 1.5em; padding: 8px;" />
|
| 67 |
</p>
|
| 68 |
<p id="pagseguro-card-holder-phone-field" class="form-row form-row-last">
|
| 69 |
<label for="pagseguro-card-holder-phone"><?php _e( 'Card Holder Phone', 'woocommerce-pagseguro' ); ?> <span class="required">*</span></label>
|
| 70 |
+
<input id="pagseguro-card-holder-phone" name="pagseguro_card_holder_phone" class="input-text" type="tel" autocomplete="off" placeholder="<?php _e( '(xx) xxxx-xxxx', 'woocommerce-pagseguro' ); ?>" style="font-size: 1.5em; padding: 8px;" />
|
| 71 |
</p>
|
| 72 |
<div class="clear"></div>
|
| 73 |
</div>
|
woocommerce-pagseguro.php
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* Plugin Name: WooCommerce PagSeguro
|
| 4 |
-
* Plugin URI: http://github.com/
|
| 5 |
* Description: Gateway de pagamento PagSeguro para WooCommerce.
|
| 6 |
* Author: Claudio Sanches
|
| 7 |
-
* Author URI: http://
|
| 8 |
-
* Version: 2.
|
| 9 |
* License: GPLv2 or later
|
| 10 |
* Text Domain: woocommerce-pagseguro
|
| 11 |
* Domain Path: languages/
|
|
@@ -29,7 +29,7 @@ if ( ! class_exists( 'WC_PagSeguro' ) ) :
|
|
| 29 |
*
|
| 30 |
* @var string
|
| 31 |
*/
|
| 32 |
-
const VERSION = '2.
|
| 33 |
|
| 34 |
/**
|
| 35 |
* Instance of this class.
|
|
@@ -69,7 +69,7 @@ if ( ! class_exists( 'WC_PagSeguro' ) ) :
|
|
| 69 |
*/
|
| 70 |
public static function get_instance() {
|
| 71 |
// If the single instance hasn't been set, set it now.
|
| 72 |
-
if ( null
|
| 73 |
self::$instance = new self;
|
| 74 |
}
|
| 75 |
|
|
@@ -100,13 +100,8 @@ if ( ! class_exists( 'WC_PagSeguro' ) ) :
|
|
| 100 |
* @return array
|
| 101 |
*/
|
| 102 |
public function plugin_action_links( $links ) {
|
| 103 |
-
$plugin_links
|
| 104 |
-
|
| 105 |
-
if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '2.1', '>=' ) ) {
|
| 106 |
-
$plugin_links[] = '<a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=pagseguro' ) ) . '">' . __( 'Settings', 'woocommerce-pagseguro' ) . '</a>';
|
| 107 |
-
} else {
|
| 108 |
-
$plugin_links[] = '<a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=wc_pagseguro_gateway' ) ) . '">' . __( 'Settings', 'woocommerce-pagseguro' ) . '</a>';
|
| 109 |
-
}
|
| 110 |
|
| 111 |
return array_merge( $plugin_links, $links );
|
| 112 |
}
|
|
@@ -141,9 +136,8 @@ if ( ! class_exists( 'WC_PagSeguro' ) ) :
|
|
| 141 |
* @return array New Available Gateways.
|
| 142 |
*/
|
| 143 |
public function hides_when_is_outside_brazil( $available_gateways ) {
|
| 144 |
-
|
| 145 |
// Remove PagSeguro gateway.
|
| 146 |
-
if ( isset( $_REQUEST['country'] ) && 'BR'
|
| 147 |
unset( $available_gateways['pagseguro'] );
|
| 148 |
}
|
| 149 |
|
|
@@ -159,7 +153,9 @@ if ( ! class_exists( 'WC_PagSeguro' ) ) :
|
|
| 159 |
* @return bool
|
| 160 |
*/
|
| 161 |
public function stop_cancel_unpaid_orders( $cancel, $order ) {
|
| 162 |
-
|
|
|
|
|
|
|
| 163 |
return false;
|
| 164 |
}
|
| 165 |
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* Plugin Name: WooCommerce PagSeguro
|
| 4 |
+
* Plugin URI: http://github.com/claudiosanches/woocommerce-pagseguro
|
| 5 |
* Description: Gateway de pagamento PagSeguro para WooCommerce.
|
| 6 |
* Author: Claudio Sanches
|
| 7 |
+
* Author URI: http://claudiosanches.com/
|
| 8 |
+
* Version: 2.12.0
|
| 9 |
* License: GPLv2 or later
|
| 10 |
* Text Domain: woocommerce-pagseguro
|
| 11 |
* Domain Path: languages/
|
| 29 |
*
|
| 30 |
* @var string
|
| 31 |
*/
|
| 32 |
+
const VERSION = '2.12.0';
|
| 33 |
|
| 34 |
/**
|
| 35 |
* Instance of this class.
|
| 69 |
*/
|
| 70 |
public static function get_instance() {
|
| 71 |
// If the single instance hasn't been set, set it now.
|
| 72 |
+
if ( null === self::$instance ) {
|
| 73 |
self::$instance = new self;
|
| 74 |
}
|
| 75 |
|
| 100 |
* @return array
|
| 101 |
*/
|
| 102 |
public function plugin_action_links( $links ) {
|
| 103 |
+
$plugin_links = array();
|
| 104 |
+
$plugin_links[] = '<a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=pagseguro' ) ) . '">' . __( 'Settings', 'woocommerce-pagseguro' ) . '</a>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
return array_merge( $plugin_links, $links );
|
| 107 |
}
|
| 136 |
* @return array New Available Gateways.
|
| 137 |
*/
|
| 138 |
public function hides_when_is_outside_brazil( $available_gateways ) {
|
|
|
|
| 139 |
// Remove PagSeguro gateway.
|
| 140 |
+
if ( isset( $_REQUEST['country'] ) && 'BR' !== $_REQUEST['country'] ) {
|
| 141 |
unset( $available_gateways['pagseguro'] );
|
| 142 |
}
|
| 143 |
|
| 153 |
* @return bool
|
| 154 |
*/
|
| 155 |
public function stop_cancel_unpaid_orders( $cancel, $order ) {
|
| 156 |
+
$payment_method = method_exists( $order, 'get_payment_method' ) ? $order->get_payment_method() : $order->payment_method;
|
| 157 |
+
|
| 158 |
+
if ( 'pagseguro' === $payment_method ) {
|
| 159 |
return false;
|
| 160 |
}
|
| 161 |
|
