2016-11-14 14:20:41 +00:00
|
|
|
<?php
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Legacy Payment Tokens.
|
|
|
|
* Payment Tokens were introduced in 2.6.0 with create and update as methods.
|
2017-03-14 19:21:51 +00:00
|
|
|
* Major CRUD changes occurred in 3.0, so these were deprecated (save and delete still work).
|
2016-11-14 14:20:41 +00:00
|
|
|
* This legacy class is for backwards compatibility in case any code called ->read, ->update or ->create
|
|
|
|
* directly on the object.
|
|
|
|
*
|
2017-03-14 19:21:51 +00:00
|
|
|
* @version 3.0.0
|
2016-11-14 14:20:41 +00:00
|
|
|
* @package WooCommerce/Classes
|
|
|
|
* @category Class
|
|
|
|
* @author WooCommerce
|
|
|
|
*/
|
|
|
|
abstract class WC_Legacy_Payment_Token extends WC_Data {
|
|
|
|
|
2017-03-14 19:21:51 +00:00
|
|
|
/**
|
|
|
|
* Sets the type of this payment token (CC, eCheck, or something else).
|
|
|
|
*
|
|
|
|
* @param string Payment Token Type (CC, eCheck)
|
|
|
|
*/
|
|
|
|
public function set_type( $type ) {
|
|
|
|
wc_deprecated_function( 'WC_Payment_Token::set_type', '3.0.0', 'Type cannot be overwritten.' );
|
|
|
|
}
|
|
|
|
|
2016-11-14 14:20:41 +00:00
|
|
|
/**
|
2016-11-14 17:08:46 +00:00
|
|
|
* Read a token by ID.
|
2017-03-14 19:21:51 +00:00
|
|
|
* @deprecated 3.0.0 - Init a token class with an ID.
|
2016-11-14 14:20:41 +00:00
|
|
|
*/
|
|
|
|
public function read( $token_id ) {
|
2017-03-14 19:21:51 +00:00
|
|
|
wc_deprecated_function( 'WC_Payment_Token::read', '3.0.0', 'a new token class initialized with an ID.' );
|
2016-11-14 14:20:41 +00:00
|
|
|
$this->set_id( $token_id );
|
|
|
|
$data_store = WC_Data_Store::load( 'payment-token' );
|
|
|
|
$data_store->read( $this );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-11-14 17:13:55 +00:00
|
|
|
* Update a token.
|
2017-03-14 19:21:51 +00:00
|
|
|
* @deprecated 3.0.0 - Use ::save instead.
|
2016-11-14 14:20:41 +00:00
|
|
|
*/
|
|
|
|
public function update() {
|
2017-03-14 19:21:51 +00:00
|
|
|
wc_deprecated_function( 'WC_Payment_Token::update', '3.0.0', '::save instead.' );
|
2016-11-14 14:20:41 +00:00
|
|
|
$data_store = WC_Data_Store::load( 'payment-token' );
|
|
|
|
try {
|
|
|
|
$data_store->update( $this );
|
|
|
|
} catch ( Exception $e ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-11-14 17:08:46 +00:00
|
|
|
* Create a token.
|
2017-03-14 19:21:51 +00:00
|
|
|
* @deprecated 3.0.0 - Use ::save instead.
|
2016-11-14 14:20:41 +00:00
|
|
|
*/
|
|
|
|
public function create() {
|
2017-03-14 19:21:51 +00:00
|
|
|
wc_deprecated_function( 'WC_Payment_Token::create', '3.0.0', '::save instead.' );
|
2016-11-14 14:20:41 +00:00
|
|
|
$data_store = WC_Data_Store::load( 'payment-token' );
|
|
|
|
try {
|
|
|
|
$data_store->create( $this );
|
|
|
|
} catch ( Exception $e ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|