1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
<?php
defined( 'ABSPATH' ) || exit();
trait WC_Payment_Token_Source_Trait {
public function save_payment_method() {
return WC_Stripe_Gateway::load()->customers->createSource( $this->get_customer_id(), array( 'source' => $this->get_token() ) );
}
public function delete_from_stripe() {
return WC_Stripe_Gateway::load()->sources->mode( $this->get_environment() )->detach( $this->get_customer_id(), $this->get_token() );
}
}
trait WC_Payment_Token_Payment_Method_Trait {
public function save_payment_method() {
return WC_Stripe_Gateway::load()->paymentMethods->attach( $this->get_token(), array( 'customer' => $this->get_customer_id() ) );
}
public function delete_from_stripe() {
return WC_Stripe_Gateway::load()->paymentMethods->mode( $this->get_environment() )->detach( $this->get_token() );
}
}