Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/Message/Checkout/PurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@
*/
class PurchaseRequest extends AbstractRequest
{
/**
* Create response
*
* @param string $data
* @param array $headers
*
* @return Response
*/
protected function createResponse($data, $headers = [])
{
return $this->response = new Response($this, $data, $headers);
}

/**
* Set the success url
*
Expand Down
33 changes: 33 additions & 0 deletions src/Message/Checkout/Response.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php namespace Omnipay\Stripe\Message\Checkout;

use Omnipay\Common\Message\AbstractResponse;
use Omnipay\Common\Message\RedirectResponseInterface;
use Omnipay\Common\Message\RequestInterface;

/**
* Stripe Checkout Response - https://stripe.com/docs/api/checkout/sessions/create
*
* @see \Omnipay\Stripe\Gateway
*/
class Response extends \Omnipay\Stripe\Message\Response
{
/**
* @return bool
*/
public function isRedirect()
{
return $this->getRedirectUrl() !== null;
}

/**
* @return mixed
*/
public function getRedirectUrl()
{
if (isset($this->data['object']) && 'checkout.session' !== $this->data['object']) {
return null;
}

return !empty($this->data['url']) ? $this->data['url'] : null;
}
}