1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
<?php
defined( 'ABSPATH' ) || exit();
if ( ! class_exists( 'WC_Payment_Token_Braintree_CC' ) ) {
exit();
}
class WC_Payment_Token_Braintree_GooglePay extends WC_Payment_Token_Braintree_CC {
protected $type = 'Braintree_GooglePay';
protected $braintree_data = array(
'source_description' => '',
'virtual_card_last4' => '',
'virtual_card_type' => '',
);
public function init_from_payment_method( $method ) {
$this->set_card_type( $method->sourceCardType );
$this->set_method_type( 'GooglePay' );
$this->set_expiry_month( $method->expirationMonth );
$this->set_expiry_year( $method->expirationYear );
$this->set_bin( $method->bin );
$this->set_last4( $method->sourceCardLast4 );
$this->set_source_description( $method->sourceDescription );
$this->set_virtual_card_type( $method->virtualCardType );
$this->set_virtual_last4( $method->virtualCardLast4 );
$this->set_masked_number( $this->get_bin() . '******' . $this->get_last4() );
$this->set_payment_instrument_type( \Braintree\PaymentInstrumentType::ANDROID_PAY_CARD );
$this->set_token( $method->token );
}
public function set_source_description( $value ) {
$this->set_prop( 'source_description', $value );
}
public function get_source_description() {
return $this->get_prop( 'source_description' );
}
public function set_virtual_last4( $value ) {
$this->set_prop( 'virtual_card_last4', $value );
}
public function get_virtual_card_last4() {
$this->get_prop( 'virtual_card_last4' );
}
public function set_virtual_card_type( $value ) {
$this->set_prop( 'virtual_card_type', $value );
}
public function get_virtual_card_type() {
return $this->get_prop( 'virtual_card_type' );
}
public function init_payment_formats() {
$this->payment_formats = array(
'type_ending_in' => array(
'label' => __( 'Type Ending In', 'woo-payment-gateway' ),
'example' => 'Visa ending in 1111',
'format' => __( '{card_type} ending in {last4}', 'woo-payment-gateway' ),
),
'google_type_last4' => array(
'label' => __( 'Type and Last Four', 'woo-payment-gateway' ),
'example' => 'Google Pay - Visa 1111',
'format' => 'Google Pay - {card_type} {last4}',
),
'type_last4' => array(
'label' => __( 'Type and Last Four', 'woo-payment-gateway' ),
'example' => 'Visa 1111',
'format' => '{card_type} {last4}',
),
'basic' => array(
'label' => __( 'Basic', 'woo-payment-gateway' ),
'example' => __( 'Google Pay', 'woo-payment-gateway' ),
'format' => __( 'Google Pay', 'woo-payment-gateway' )
)
);
}
}