Conditions | 1 |
Paths | 1 |
Total Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
22 | public static function create_token( $payment_method, $user_id = null, $gateway = WC_Payment_Gateway_WCPay::GATEWAY_ID ) { |
||
23 | $token = new WC_Payment_Token_CC(); |
||
24 | $token->set_token( $payment_method ); |
||
25 | $token->set_gateway_id( $gateway ); |
||
26 | $token->set_user_id( $user_id ?? get_current_user_id() ); |
||
27 | $token->set_card_type( 'visa' ); |
||
28 | $token->set_last4( '4242' ); |
||
29 | $token->set_expiry_month( 6 ); |
||
30 | $token->set_expiry_year( intval( gmdate( 'Y' ) ) + 1 ); |
||
31 | $token->save(); |
||
32 | |||
33 | return WC_Payment_Tokens::get( $token->get_id() ); |
||
34 | } |
||
35 | } |
||
36 |