Skip to content

Commit

Permalink
Fix rediretions
Browse files Browse the repository at this point in the history
  • Loading branch information
subiabre committed Jul 10, 2024
1 parent d6d6cc4 commit 7cef34f
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions src/Omnipay/Stripe/Subscription/Message/SubscriptionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@ public function sendData($data)
$customer = $this->getStripeCustomer($user)->id;
$metadata = $this->getMetadata($invest);

$successUrl = sprintf('%s?session_id={CHECKOUT_SESSION_ID}', $this->getRedirectUrl(
'invest',
$metadata['project'],
$invest->id,
'complete'
));
$successUrl = $this->getRedirectUrl('pool', $invest->id, 'complete');
if ($invest->getProject()) {
$successUrl = $this->getRedirectUrl(
'invest',
$metadata['project'],
$invest->id,
'complete'
);
}

$redirectUrl = $this->getRedirectUrl('dashboard', 'wallet');
if ($invest->getProject()) {
Expand All @@ -55,7 +58,7 @@ public function sendData($data)

$checkout = $this->stripe->checkout->sessions->create([
'customer' => $customer,
'success_url' => $successUrl,
'success_url' => sprintf('%s?session_id={CHECKOUT_SESSION_ID}', $successUrl),
'cancel_url' => $redirectUrl,
'mode' => CheckoutSession::MODE_SUBSCRIPTION,
'line_items' => [
Expand Down Expand Up @@ -99,15 +102,25 @@ public function completePurchase(array $options = [])
return new SubscriptionResponse($this, $checkout, $subscription);
}

$donationCheckout = $this->stripe->checkout->sessions->create([
'customer' => $this->getStripeCustomer(User::get($metadata['user']))->id,
'success_url' => sprintf('%s?session_id={CHECKOUT_SESSION_ID}', $this->getRedirectUrl(
$successUrl = $this->getRedirectUrl('pool', $metadata['invest']);
if ($metadata['project'] !== '') {
$successUrl = $this->getRedirectUrl(
'invest',
$metadata['project'],
$metadata['invest'],
'complete'
)),
'cancel_url' => $this->getRedirectUrl('project', $metadata['project']->id),
);
}

$cancelUrl = $this->getRedirectUrl('dashboard', 'wallet');
if ($metadata['project'] !== '') {
$cancelUrl = $this->getRedirectUrl('project', $metadata['project']);
}

$donationCheckout = $this->stripe->checkout->sessions->create([
'customer' => $this->getStripeCustomer(User::get($metadata['user']))->id,
'success_url' => sprintf('%s?session_id={CHECKOUT_SESSION_ID}', $successUrl),
'cancel_url' => $cancelUrl,
'mode' => CheckoutSession::MODE_PAYMENT,
'line_items' => [
[
Expand Down

0 comments on commit 7cef34f

Please sign in to comment.