Skip to content

Commit

Permalink
Add missing doc blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
asumaran committed Jan 30, 2025
1 parent 051c4b2 commit 383393f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,23 @@ public function is_enabled_at_checkout( $order_id = null, $account_domestic_curr
return parent::is_enabled_at_checkout( $order_id, $account_domestic_currency );
}

/**
* Returns a string representing payment method type to query for when retrieving saved payment methods from Stripe.
*
* @return string The payment method type.
*/
public function get_retrievable_type() {
return $this->get_id();
}

/**
* Creates a Bacs Direct Debit payment token for the customer.
*
* @param int $user_id The customer ID the payment token is associated with.
* @param stdClass $payment_method The payment method object.
*
* @return WC_Payment_Token The payment token created.
*/
public function create_payment_token_for_user( $user_id, $payment_method ) {
$token = new WC_Payment_Token_Bacs_Debit();
$token->set_token( $payment_method->id );
Expand Down
38 changes: 38 additions & 0 deletions includes/payment-tokens/class-wc-stripe-bacs-payment-token.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,30 @@
class WC_Payment_Token_Bacs_Debit extends WC_Payment_Token implements WC_Stripe_Payment_Method_Comparison_Interface {
use WC_Stripe_Fingerprint_Trait;

/**
* Token Type.
*
* @var string
*/
protected $type = WC_Stripe_Payment_Methods::BACS_DEBIT;

/**
* Bacs Debit payment token data.
*
* @var array
*/
protected $extra_data = [
'last4' => '',
'payment_method_type' => WC_Stripe_Payment_Methods::BACS_DEBIT,
'fingerprint' => '',
];

/**
* Checks if the payment method token is equal a provided payment method.
*
* @param object $payment_method Payment method object.
* @return bool
*/
public function is_equal_payment_method( $payment_method ): bool {
if ( WC_Stripe_Payment_Methods::BACS_DEBIT === $payment_method->type
&& ( $payment_method->bacs_debit->fingerprint ?? null ) === $this->get_fingerprint() ) {
Expand All @@ -25,18 +41,40 @@ public function is_equal_payment_method( $payment_method ): bool {
return false;
}

/**
* Set the last four digits for the Bacs Debit Token.
*
* @param string $last4
*/
public function set_last4( $last4 ) {
$this->set_prop( 'last4', $last4 );
}

/**
* Returns the last four digits of the Bacs Debit Token.
*
* @param string $context What the value is for. Valid values are view and edit.
* @return string The last 4 digits.
*/
public function get_last4( $context = 'view' ) {
return $this->get_prop( 'last4', $context );
}

/**
* Set Stripe payment method type.
*
* @param string $type Payment method type.
*/
public function set_payment_method_type( $type ) {
$this->set_prop( 'payment_method_type', $type );
}

/**
* Returns Stripe payment method type.
*
* @param string $context What the value is for. Valid values are view and edit.
* @return string $payment_method_type
*/
public function get_payment_method_type( $context = 'view' ) {
return $this->get_prop( 'payment_method_type', $context );
}
Expand Down

0 comments on commit 383393f

Please sign in to comment.