diff --git a/src/Concerns/ManagesPaymentMethods.php b/src/Concerns/ManagesPaymentMethods.php index c1240d7b..4f222063 100644 --- a/src/Concerns/ManagesPaymentMethods.php +++ b/src/Concerns/ManagesPaymentMethods.php @@ -88,12 +88,12 @@ public function addPaymentMethod($paymentMethod) } /** - * Remove a payment method from the customer. + * Delete a payment method from the customer. * * @param \Stripe\PaymentMethod|string $paymentMethod * @return void */ - public function removePaymentMethod($paymentMethod) + public function deletePaymentMethod($paymentMethod) { $this->assertCustomerExists(); @@ -118,6 +118,19 @@ public function removePaymentMethod($paymentMethod) } } + /** + * Remove a payment method from the customer. + * + * @param \Stripe\PaymentMethod|string $paymentMethod + * @return void + * + * @deprecated Will be removed in a future Cashier Stripe version. Use deletePaymentMethod() instead. + */ + public function removePaymentMethod($paymentMethod) + { + return $this->deletePaymentMethod($paymentMethod); + } + /** * Get the default payment method for the customer. * diff --git a/src/PaymentMethod.php b/src/PaymentMethod.php index 05091093..6d014cdf 100644 --- a/src/PaymentMethod.php +++ b/src/PaymentMethod.php @@ -50,7 +50,7 @@ public function __construct($owner, StripePaymentMethod $paymentMethod) */ public function delete() { - return $this->owner->removePaymentMethod($this->paymentMethod); + return $this->owner->deletePaymentMethod($this->paymentMethod); } /** diff --git a/tests/Feature/PaymentMethodsTest.php b/tests/Feature/PaymentMethodsTest.php index ea63f419..80f6f3f9 100644 --- a/tests/Feature/PaymentMethodsTest.php +++ b/tests/Feature/PaymentMethodsTest.php @@ -57,9 +57,9 @@ public function test_we_can_add_default_sepa_payment_method() $this->assertTrue($user->hasDefaultPaymentMethod()); } - public function test_we_can_remove_payment_methods() + public function test_we_can_delete_payment_methods() { - $user = $this->createCustomer('we_can_remove_payment_methods'); + $user = $this->createCustomer('we_can_delete_payment_methods'); $user->createAsStripeCustomer(); $paymentMethod = $user->addPaymentMethod('pm_card_visa'); @@ -67,15 +67,15 @@ public function test_we_can_remove_payment_methods() $this->assertCount(1, $user->paymentMethods()); $this->assertTrue($user->hasPaymentMethod()); - $user->removePaymentMethod($paymentMethod->asStripePaymentMethod()); + $user->deletePaymentMethod($paymentMethod->asStripePaymentMethod()); $this->assertCount(0, $user->paymentMethods()); $this->assertFalse($user->hasPaymentMethod()); } - public function test_we_can_remove_the_default_payment_method() + public function test_we_can_delete_the_default_payment_method() { - $user = $this->createCustomer('we_can_remove_the_default_payment_method'); + $user = $this->createCustomer('we_can_delete_the_default_payment_method'); $user->createAsStripeCustomer(); $paymentMethod = $user->updateDefaultPaymentMethod('pm_card_visa'); @@ -84,7 +84,7 @@ public function test_we_can_remove_the_default_payment_method() $this->assertTrue($user->hasPaymentMethod()); $this->assertTrue($user->hasDefaultPaymentMethod()); - $user->removePaymentMethod($paymentMethod->asStripePaymentMethod()); + $user->deletePaymentMethod($paymentMethod->asStripePaymentMethod()); $this->assertCount(0, $user->paymentMethods()); $this->assertNull($user->defaultPaymentMethod());