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();
class WC_Payment_Token_Stripe_ACH extends WC_Payment_Token_Stripe {
use WC_Payment_Token_Source_Trait;
protected $type = 'Stripe_ACH';
protected $stripe_payment_type = 'source';
protected $stripe_data = array(
'bank_name' => '',
'routing_number' => '',
'last4' => '',
);
public function details_to_props( $details ) {
if ( isset( $details['ach_debit'] ) ) {
$bank = $details['ach_debit'];
} elseif ( $details instanceof \Stripe\BankAccount ) {
$bank = $details;
}
$this->set_brand( $bank['bank_name'] );
$this->set_bank_name( $bank['bank_name'] );
$this->set_last4( $bank['last4'] );
$this->set_routing_number( $bank['routing_number'] );
}
public function get_bank_name( $context = 'view' ) {
return $this->get_prop( 'bank_name', $context );
}
public function get_routing_number( $context = 'view' ) {
return $this->get_prop( 'routing_number', $context );
}
public function get_last4( $context = 'view' ) {
return $this->get_prop( 'last4', $context );
}
public function set_bank_name( $value ) {
$this->set_prop( 'bank_name', $value );
}
public function set_routing_number( $value ) {
$this->set_prop( 'routing_number', $value );
}
public function set_last4( $value ) {
$this->set_prop( 'last4', $value );
}
public function get_formats() {
return apply_filters( 'wc_stripe_get_token_formats', array(
'type_ending_in' => array(
'label' => __( 'Type Ending In', 'woo-stripe-payment' ),
'example' => 'Chase ending in 3434',
'format' => __( '{bank_name} ending in {last4}', 'woo-stripe-payment' ),
),
'name_masked_last4' => array(
'label' => __( 'Type Ending In', 'woo-stripe-payment' ),
'example' => 'Chase **** 3434',
'format' => __( '{bank_name} **** {last4}', 'woo-stripe-payment' ),
),
'short_title' => array(
'label' => __( 'Gateway Title', 'woo-stripe-payment' ),
'example' => $this->get_basic_payment_method_title(),
'format' => '{short_title}'
)
), $this );
}
public function get_html_classes() {
return 'wc-stripe-ach';
}
public function get_basic_payment_method_title() {
return __( 'Bank Payment', 'woo-stripe-payment' );
}
}