From 5691dc2500421bbfaf7f20825789386a57403250 Mon Sep 17 00:00:00 2001 From: Andreas Radloff Date: Mon, 17 Jun 2024 13:46:53 +0200 Subject: [PATCH] Clone payment methods for use in connected stripe account --- .../ClonePaymentMethodRequest.php | 48 +++++++++++++++++++ src/PaymentIntentsGateway.php | 10 ++++ 2 files changed, 58 insertions(+) create mode 100644 src/Message/PaymentIntents/ClonePaymentMethodRequest.php diff --git a/src/Message/PaymentIntents/ClonePaymentMethodRequest.php b/src/Message/PaymentIntents/ClonePaymentMethodRequest.php new file mode 100644 index 00000000..a01e5f23 --- /dev/null +++ b/src/Message/PaymentIntents/ClonePaymentMethodRequest.php @@ -0,0 +1,48 @@ +validate('customerReference', 'paymentMethod'); + + $data['payment_method'] = $this->getPaymentMethod(); + $data['customer'] = $this->getCustomerReference(); + + return $data; + } + + /** + * @inheritdoc + */ + public function getEndpoint() + { + return $this->endpoint.'/payment_methods'; + } + + /** + * @inheritdoc + */ + protected function createResponse($data, $headers = []) + { + return $this->response = new Response($this, $data, $headers); + } +} diff --git a/src/PaymentIntentsGateway.php b/src/PaymentIntentsGateway.php index e6ecea2f..0b9e7d08 100644 --- a/src/PaymentIntentsGateway.php +++ b/src/PaymentIntentsGateway.php @@ -166,6 +166,16 @@ public function deleteCard(array $parameters = array()) return $this->createRequest('\Omnipay\Stripe\Message\PaymentIntents\DetachPaymentMethodRequest', $parameters); } + /** + * Clone a Payment Method to a Connected Stripe account. + * + * @return \Omnipay\Stripe\Message\PaymentIntents\ClonePaymentMethodRequest + */ + public function clonePaymentMethod(array $parameters = array()) + { + return $this->createRequest('\Omnipay\Stripe\Message\PaymentIntents\ClonePaymentMethodRequest', $parameters); + } + // Setup Intent /**