Skip to content

Commit

Permalink
Merge pull request #6 from ahmetarsiv/master
Browse files Browse the repository at this point in the history
Bugs fixed & upgrades
  • Loading branch information
karabayyazilim authored Apr 17, 2024
2 parents 5e9142a + 12f7b6c commit 6b67084
Show file tree
Hide file tree
Showing 11 changed files with 174 additions and 27 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/node_modules
/npm-debug.log
/package-lock.json

.idea
.vscode
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Codenteq
Copyright (c) 2024 Codenteq

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<p align="center"><a href="https://codenteq.com" target="_blank"><img src="src/Resources/assets/images/stripe.svg" width="288"></a></p>

# Stripe Payment Gateway
[![License](https://poser.pugx.org/codenteq/stripe-payment-gateway/license)](https://github.com/codenteq/stripe-payment-gateway/blob/master/LICENSE)
<a href="https://packagist.org/packages/codenteq/stripe-payment-gateway"><img src="https://poser.pugx.org/codenteq/stripe-payment-gateway/d/total" alt="Total Downloads"></a>
[![Total Downloads](https://poser.pugx.org/codenteq/stripe-payment-gateway/d/total)](https://packagist.org/packages/codenteq/stripe-payment-gateway)

## 1. Introduction:

Install this package now to receive secure payments in your online store. Stripe offers an easy and secure payment gateway

## 2. Requirements:

* **PHP**: 8.0 or higher.
* **Bagisto**: v1.5.*
* **PHP**: 8.1 or higher.
* **Bagisto**: v2.*
* **Composer**: 1.6.5 or higher.

## 3. Installation:
Expand Down Expand Up @@ -75,3 +77,6 @@ sk_test_4eC39HqLyjWDarjtT1zdp7dc
```

> That's it, now just execute the project on your specified domain.
## How to contribute
Stripe Payment Gateway is always open for direct contributions. Contributions can be in the form of design suggestions, documentation improvements, new component suggestions, code improvements, adding new features or fixing problems. For more information please check our [Contribution Guideline document.](https://github.com/codenteq/stripe-payment-gateway/blob/master/CONTRIBUTING.md)
3 changes: 3 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Release Instructions

[Releases](https://github.com/codenteq/stripe-payment-gateway/releases) are done by [@codenteq](https://github.com/codenteq) for this repository.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"email": "[email protected]"
},
"require": {
"stripe/stripe-php": "^13.10"
"stripe/stripe-php": "^14.1"
},
"funding": [
{
Expand Down
78 changes: 78 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"axios": "^1.4.0",
"laravel-vite-plugin": "^0.7.2",
"vite": "^4.0.0",
"vue": "^3.2.47"
},
"dependencies": {
"@vee-validate/i18n": "^4.9.1",
"@vee-validate/rules": "^4.9.1",
"@vitejs/plugin-vue": "^4.2.3",
"mitt": "^3.0.1",
"vee-validate": "^4.9.1"
}
}
35 changes: 15 additions & 20 deletions src/Http/Controllers/PaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,29 @@
use Webkul\Checkout\Facades\Cart;
use Webkul\Sales\Repositories\InvoiceRepository;
use Webkul\Sales\Repositories\OrderRepository;
use Webkul\Sales\Transformers\OrderResource;

class PaymentController extends Controller
{
/**
* OrderRepository $orderRepository
* Create a new controller instance.
*
* @var \Webkul\Sales\Repositories\OrderRepository
*/
protected $orderRepository;

/**
* InvoiceRepository $invoiceRepository
* @return void
*
* @var \Webkul\Sales\Repositories\InvoiceRepository
* @var OrderRepository
* @var InvoiceRepository
*/
protected $invoiceRepository;

/**
* Create a new controller instance.
*/
public function __construct(OrderRepository $orderRepository, InvoiceRepository $invoiceRepository)
{
$this->orderRepository = $orderRepository;
$this->invoiceRepository = $invoiceRepository;
public function __construct(
protected OrderRepository $orderRepository,
protected InvoiceRepository $invoiceRepository,
) {
//
}

/**
* Redirects to the Stripe server.
*/
public function redirect(): \Illuminate\Http\RedirectResponse
public function redirect(): RedirectResponse
{
$cart = Cart::getCart();
$billingAddress = $cart->billing_address;
Expand Down Expand Up @@ -73,9 +66,11 @@ public function redirect(): \Illuminate\Http\RedirectResponse
*/
public function success(): RedirectResponse
{
$order = $this->orderRepository->create(Cart::prepareDataForOrder());
$cart = Cart::getCart();

$data = (new OrderResource($cart))->jsonSerialize();

$this->orderRepository->update(['status' => 'processing'], $order->id);
$order = $this->orderRepository->create($data);

if ($order->canInvoice()) {
$this->invoiceRepository->create($this->prepareInvoiceData($order));
Expand Down
4 changes: 2 additions & 2 deletions src/Payment/Stripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public function getRedirectUrl(): string
}

/**
* Returns payment method image
* Returns payment method image.
*/
public function getImage(): string
{
$url = $this->getConfigData('image');

return Storage::url($url);
return $url ? Storage::url($url) : bagisto_asset('images/money-transfer.png', 'shop');
}
}
4 changes: 4 additions & 0 deletions src/Resources/assets/js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* This will track all the images and fonts for publishing.
*/
import.meta.glob(["../images/**"]);
36 changes: 36 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import laravel from "laravel-vite-plugin";

export default defineConfig(({ mode }) => {
const envDir = "../../../";

Object.assign(process.env, loadEnv(mode, envDir));

return {
build: {
emptyOutDir: true,
},

envDir,

server: {
host: process.env.VITE_HOST || "localhost",
port: process.env.VITE_PORT || 5173,
},

plugins: [
vue(),

laravel({
hotFile: "../../../public/stripe-default-vite.hot",
publicDirectory: "../../../public",
buildDirectory: "themes/stripe/default/build",
input: [
"src/Resources/assets/js/app.js",
],
refresh: true,
}),
],
};
});

0 comments on commit 6b67084

Please sign in to comment.