• Resolved tmendes

    (@thaissamendes)


    Hi,

    I needed to be able to save the last 4 digits of the customer’s credit card. I added the following lines to the woo-paypal-pro-gateway-class.php file. It would be good to have this integrated with the plugin, as well as have a way to enable/disable this from administration. Or at least have some hooks added to those places, so we can save any kind of information we need, without the need to actually edit the plugin.

    I added a way to show that information on order emails, order edit page and thank you page, but I did that directly on my customization plugin.

    The line numbers refer to 2.9.5 plugin version.

    @@ -19,6 +19,7 @@ class WC_PP_PRO_Gateway extends WC_Payment_Gateway {
         protected $apiusername          = '';
         protected $apipassword          = '';
         protected $apisigniture             = '';
    +    protected $cc_last_digits = null;
     
         public function __construct() {
        $this->id        = 'paypalpro'; //ID needs to be ALL lowercase or it doens't work
    @@ -220,6 +221,7 @@ class WC_PP_PRO_Gateway extends WC_Payment_Gateway {
        global $woocommerce;
        $this->order         = new WC_Order( $order_id );
        $gatewayRequestData  = $this->create_paypal_request();
    +    $this->cc_last_digits = $this->get_cc_last_digits( $gatewayRequestData['ACCT'] );
     
        if ( $gatewayRequestData AND $this->verify_paypal_payment( $gatewayRequestData ) ) {
            $this->do_order_complete_tasks();
    @@ -256,6 +258,8 @@ class WC_PP_PRO_Gateway extends WC_Payment_Gateway {
        $this->order->payment_complete();
        $woocommerce->cart->empty_cart();
     
    +    update_post_meta( $this->order->get_id(), '_cc_last_digits', $this->cc_last_digits );
    +
        $this->order->add_order_note(
        sprintf( "Paypal Credit Card payment completed with Transaction Id of '%s'", $this->transactionId )
        );
    @@ -409,5 +413,8 @@ class WC_PP_PRO_Gateway extends WC_Payment_Gateway {
             return $payment_info_params;
         }
     
    +    private function get_cc_last_digits( $cc_number ) {
    +        return substr( $cc_number, -4 );
    +    }
     }
     //End of class
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Saving 4 last digits of CC’ is closed to new replies.