Skip to content

Commit 68b4903

Browse files
author
Alexander (SASh) Alexiev
committed
add: restrieve setup intent and fix the setup intents response
1 parent 23f998e commit 68b4903

File tree

4 files changed

+80
-3
lines changed

4 files changed

+80
-3
lines changed

src/Message/SetupIntents/AbstractRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ abstract class AbstractRequest extends \Omnipay\Stripe\Message\AbstractRequest
2525
*/
2626
public function setSetupIntentReference($value)
2727
{
28-
return $this->setParameter('paymentIntentReference', $value);
28+
return $this->setParameter('setupIntentReference', $value);
2929
}
3030

3131
/**
3232
* @return mixed
3333
*/
3434
public function getSetupIntentReference()
3535
{
36-
return $this->getParameter('paymentIntentReference');
36+
return $this->getParameter('setupIntentReference');
3737
}
3838

3939
}

src/Message/SetupIntents/Response.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function getCustomerReference()
7474
public function isSuccessful()
7575
{
7676
if (isset($this->data['object']) && 'setup_intent' === $this->data['object']) {
77-
return in_array($this->getStatus(), ['succeeded', 'requires_capture']);
77+
return in_array($this->getStatus(), ['succeeded', 'requires_payment_method']);
7878
}
7979

8080
return parent::isSuccessful();
@@ -127,4 +127,18 @@ public function getSetupIntentReference()
127127

128128
return null;
129129
}
130+
131+
/**
132+
* Get the payment intent reference.
133+
*
134+
* @return string|null
135+
*/
136+
public function getPaymentMethod()
137+
{
138+
if (isset($this->data['object']) && 'setup_intent' === $this->data['object']) {
139+
return $this->data['payment_method'];
140+
}
141+
142+
return null;
143+
}
130144
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
/**
4+
* Stripe Create Payment Method Request.
5+
*/
6+
namespace Omnipay\Stripe\Message\SetupIntents;
7+
8+
/**
9+
* Stripe create setup intent
10+
*
11+
* ### Example
12+
*
13+
* <code>
14+
*
15+
* </code>
16+
*
17+
* @see \Omnipay\Stripe\Message\PaymentIntents\AttachPaymentMethodRequest
18+
* @see \Omnipay\Stripe\Message\PaymentIntents\DetachPaymentMethodRequest
19+
* @see \Omnipay\Stripe\Message\PaymentIntents\UpdatePaymentMethodRequest
20+
* @link https://stripe.com/docs/api/setup_intents/create
21+
*/
22+
class RetrieveSetupIntentRequest extends AbstractRequest
23+
{
24+
/**
25+
* @inheritdoc
26+
*/
27+
public function getData()
28+
{
29+
$this->validate('setupIntentReference');
30+
31+
return [];
32+
}
33+
34+
/**
35+
* @inheritdoc
36+
*/
37+
public function getEndpoint()
38+
{
39+
return $this->endpoint.'/setup_intents/'.$this->getSetupIntentReference();
40+
}
41+
42+
public function getHttpMethod()
43+
{
44+
return 'GET';
45+
}
46+
47+
/**
48+
* @inheritdoc
49+
*/
50+
protected function createResponse($data, $headers = [])
51+
{
52+
return $this->response = new Response($this, $data, $headers);
53+
}
54+
}

src/PaymentIntentsGateway.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,13 @@ public function createSetupIntent(array $parameters = array())
178178
{
179179
return $this->createRequest('\Omnipay\Stripe\Message\SetupIntents\CreateSetupIntentRequest', $parameters);
180180
}
181+
/**
182+
* @inheritdoc
183+
*
184+
* @return \Omnipay\Stripe\Message\SetupIntents\CreateSetupIntentRequest
185+
*/
186+
public function retrieveSetupIntent(array $parameters = array())
187+
{
188+
return $this->createRequest('\Omnipay\Stripe\Message\SetupIntents\RetrieveSetupIntentRequest', $parameters);
189+
}
181190
}

0 commit comments

Comments
 (0)