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.
|
|
|
|
* Major CRUD changes occurred in 2.7, so these were deprecated (save and delete still work).
|
|
|
|
* This legacy class is for backwards compatibility in case any code called ->read, ->update or ->create
|
|
|
|
* directly on the object.
|
|
|
|
*
|
|
|
|
* @version 2.7.0
|
|
|
|
* @package WooCommerce/Classes
|
|
|
|
* @category Class
|
|
|
|
* @author WooCommerce
|
|
|
|
*/
|
|
|
|
abstract class WC_Legacy_Payment_Token extends WC_Data {
|
|
|
|
|
|
|
|
/**
|
2016-11-14 17:08:46 +00:00
|
|
|
* Read a token by ID.
|
|
|
|
* @deprecated 2.7.0 - Init a token class with an ID.
|
2016-11-14 14:20:41 +00:00
|
|
|
*/
|
|
|
|
public function read( $token_id ) {
|
2016-11-17 20:07:58 +00:00
|
|
|
// wc_soft_deprecated_function( 'WC_Payment_Token::read', '2.7', '2.8', 'Init a token class 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.
|
2016-11-14 17:08:46 +00:00
|
|
|
* @deprecated 2.7.0 - Use ::save instead.
|
2016-11-14 14:20:41 +00:00
|
|
|
*/
|
|
|
|
public function update() {
|
2016-11-17 20:07:58 +00:00
|
|
|
// wc_soft_deprecated_function( 'WC_Payment_Token::update', '2.7', '2.8', 'Use ::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.
|
|
|
|
* @deprecated 2.7.0 - Use ::save instead.
|
2016-11-14 14:20:41 +00:00
|
|
|
*/
|
|
|
|
public function create() {
|
2016-11-17 20:07:58 +00:00
|
|
|
// wc_soft_deprecated_function( 'WC_Payment_Token::create', '2.7', '2.8', 'Use ::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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|