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
<?php
defined( 'ABSPATH' ) || exit();
if ( ! class_exists( 'WC_Payment_Token_Braintree' ) ) {
exit();
}
class WC_Payment_Token_Braintree_Venmo extends WC_Payment_Token_Braintree {
protected $type = 'Braintree_Venmo';
protected $braintree_data = array(
'venmo_user_id' => '',
'username' => '',
'source_description',
'method_type' => 'Venmo',
);
public function init_from_payment_method( $method ) {
$this->set_source_description( $method->sourceDescription );
$this->set_username( $method->username );
$this->set_venmo_user_id( $method->venmoUserId );
$this->set_method_type( 'Venmo' );
$this->set_payment_instrument_type( \Braintree\PaymentInstrumentType::VENMO_ACCOUNT );
$this->set_token( $method->token );
}
public function set_username( $value ) {
$this->set_prop( 'username', $value );
}
public function get_username( $context = 'view' ) {
return $this->get_prop( 'username', $context );
}
public function set_venmo_user_id( $value ) {
$this->set_prop( 'venmo_user_id', $value );
}
public function get_venmo_user_id( $context = 'view' ) {
return $this->get_prop( 'venmo_user_id', $context );
}
public function set_source_description( $value ) {
$this->set_prop( 'source_description', $value );
}
public function get_source_description( $context = 'view' ) {
return $this->get_prop( 'source_description', $context );
}
public function init_payment_formats() {
$this->payment_formats = array(
'type_and_user' => array(
'label' => __( 'Type and User ID', 'woo-payment-gateway' ),
'example' => 'Venmo - john.smith1990',
'format' => __( 'Venmo - {username}', 'woo-payment-gateway' ),
),
'source_description' => array(
'label' => __( 'Account Description', 'woo-payment-gateway' ),
'example' => 'Venmo Account: john.smith1990',
'format' => '{sourceDescription}',
),
'basic' => array(
'label' => __( 'Basic', 'woo-payment-gateway' ),
'example' => __( 'Venmo', 'woo-payment-gateway' ),
'format' => __( 'Venmo', 'woo-payment-gateway' )
)
);
}
}