class-wc-payment-token-data-store-interface.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * Payment Token Data Store Interface
  4. *
  5. * @version 3.0.0
  6. * @package WooCommerce/Interface
  7. */
  8. if ( ! defined( 'ABSPATH' ) ) {
  9. exit;
  10. }
  11. /**
  12. * WC Payment Token Data Store Interface
  13. *
  14. * Functions that must be defined by payment token store classes.
  15. *
  16. * @version 3.0.0
  17. */
  18. interface WC_Payment_Token_Data_Store_Interface {
  19. /**
  20. * Returns an array of objects (stdObject) matching specific token criteria.
  21. * Accepts token_id, user_id, gateway_id, and type.
  22. * Each object should contain the fields token_id, gateway_id, token, user_id, type, is_default.
  23. *
  24. * @param array $args Arguments.
  25. * @return array
  26. */
  27. public function get_tokens( $args );
  28. /**
  29. * Returns an stdObject of a token for a user's default token.
  30. * Should contain the fields token_id, gateway_id, token, user_id, type, is_default.
  31. *
  32. * @param int $user_id User ID.
  33. * @return object
  34. */
  35. public function get_users_default_token( $user_id );
  36. /**
  37. * Returns an stdObject of a token.
  38. * Should contain the fields token_id, gateway_id, token, user_id, type, is_default.
  39. *
  40. * @param int $token_id Token ID.
  41. * @return object
  42. */
  43. public function get_token_by_id( $token_id );
  44. /**
  45. * Returns metadata for a specific payment token.
  46. *
  47. * @param int $token_id Token ID.
  48. * @return array
  49. */
  50. public function get_metadata( $token_id );
  51. /**
  52. * Get a token's type by ID.
  53. *
  54. * @param int $token_id Token ID.
  55. * @return string
  56. */
  57. public function get_token_type_by_id( $token_id );
  58. /**
  59. * Update's a tokens default status in the database. Used for quickly
  60. * looping through tokens and setting their statuses instead of creating a bunch
  61. * of objects.
  62. *
  63. * @param int $token_id Token ID.
  64. * @param bool $status If should update status.
  65. * @return string
  66. */
  67. public function set_default_status( $token_id, $status = true );
  68. }