-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redirect to a second checkout on subscriptions with donation
- Loading branch information
Showing
4 changed files
with
125 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/Omnipay/Stripe/Subscription/Message/DonationResponse.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Omnipay\Stripe\Subscription\Message; | ||
|
||
use Goteo\Application\Config; | ||
use Omnipay\Common\Message\AbstractResponse; | ||
use Omnipay\Common\Message\RedirectResponseInterface; | ||
use Omnipay\Common\Message\RequestInterface; | ||
use Stripe\Checkout\Session as StripeSession; | ||
use Stripe\StripeClient; | ||
|
||
class DonationResponse extends AbstractResponse implements RedirectResponseInterface | ||
{ | ||
private StripeClient $stripe; | ||
|
||
private StripeSession $checkout; | ||
|
||
public function __construct(RequestInterface $request, string $checkoutSessionId) | ||
{ | ||
parent::__construct($request, $checkoutSessionId); | ||
|
||
$this->stripe = new StripeClient(Config::get('payments.stripe.secretKey')); | ||
$this->checkout = $this->stripe->checkout->sessions->retrieve($checkoutSessionId); | ||
} | ||
|
||
public function isSuccessful() | ||
{ | ||
return $this->checkout->status === StripeSession::STATUS_COMPLETE; | ||
} | ||
|
||
public function isRedirect() | ||
{ | ||
return true; | ||
} | ||
|
||
public function getRedirectUrl() | ||
{ | ||
return $this->checkout->url; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters