Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Jan 31, 2024
1 parent 9d877cc commit 8b28347
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 52 deletions.
41 changes: 17 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,29 @@ composer require conedevelopment/bazar-stripe
```ini
STRIPE_API_KEY=
STRIPE_SECRET=
STRIPE_SUCCESS_URL=
STRIPE_CANCEL_URL=
```

### Customizing Redirect URL After Payment Intent
### Bazar Config

```php
namespace App\Providers;

use Cone\Bazar\Models\Order;
use Cone\Bazar\Models\Transaction;
use Cone\Bazar\Stripe\StripeDriver;

class AppServiceProvider extends ServiceProvider
{
public function register(): void
{
StripeDriver::redirectUrlAfterPayment(function (Order $order, string $status, Transaction $transaction = null): string {
return match ($status) {
'success' => '/shop/account/orders/'.$order->uuid,
default => '/shop/retry-checkout?order='.$order->uuid;
};
});
}
}
// config/bazar.php

'gateway' => [
'drivers' => [
// ...
'stripe' => [
'test_mode' => env('STRIPE_TEST_MODE', false),
'api_key' => env('STRIPE_API_KEY'),
'secret' => env('STRIPE_SECRET'),
'success_url' => env('STRIPE_SUCCESS_URL', '/'),
'failure_url' => env('STRIPE_FAILURE_URL', '/'),
],
],
],

// ...
```

> [!NOTE]
> The `redirectUrlAfterPayment` method overrides `STRIPE_SUCCESS_URL` and `STRIPE_CANCEL_URL` values for the given order.
## Webhook Events

```sh
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"require": {
"php": "^8.2 || ^8.3",
"conedevelopment/bazar": "@dev",
"conedevelopment/bazar": "dev-master || ^1.0.0-beta",
"stripe/stripe-php": "^13.1"
},
"require-dev": {
Expand Down
15 changes: 0 additions & 15 deletions config/bazar_stripe.php

This file was deleted.

13 changes: 1 addition & 12 deletions src/StripeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@ class StripeServiceProvider extends ServiceProvider
*/
public function register(): void
{
if (! $this->app->configurationIsCached()) {
$this->mergeConfigFrom(__DIR__.'/../config/bazar_stripe.php', 'bazar_stripe');
}

Gateway::extend('stripe', static function (Application $app): StripeDriver {
return new StripeDriver($app['config']->get('bazar_stripe'));
return new StripeDriver($app['config']->get('bazar.gateway.drivers.stripe', []));
});
}

Expand All @@ -27,13 +23,6 @@ public function register(): void
*/
public function boot(): void
{
if ($this->app->runningInConsole()) {
$this->publishes(
[__DIR__.'/../config/bazar_stripe.php' => $this->app->configPath('bazar_stripe.php')],
'bazar-stripe-config'
);
}

$this->app['events']->listen(
Events\StripeWebhookInvoked::class, Listeners\HandlePaymentIntentSuccededEvent::class
);
Expand Down

0 comments on commit 8b28347

Please sign in to comment.