{"id":19423212,"url":"https://github.com/atomjoy/payu","last_synced_at":"2025-09-16T20:50:44.658Z","repository":{"id":63470862,"uuid":"567623111","full_name":"atomjoy/payu","owner":"atomjoy","description":"Płatności PayU w Laravel. Jak utworzyć link do płatności za zamówienie w payu api.","archived":false,"fork":false,"pushed_at":"2024-02-01T13:34:51.000Z","size":207,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-08-15T21:36:40.618Z","etag":null,"topics":["laravel-payments","laravel-payu","payu","payu-integration","payu-laravel","payu-php"],"latest_commit_sha":null,"homepage":"https://github.com/atomjoy/payu","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atomjoy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-11-18T07:34:09.000Z","updated_at":"2025-05-26T11:06:09.000Z","dependencies_parsed_at":"2025-04-24T16:30:56.845Z","dependency_job_id":"12eb550c-90c2-4d2e-b090-be7e25225dd5","html_url":"https://github.com/atomjoy/payu","commit_stats":{"total_commits":37,"total_committers":1,"mean_commits":37.0,"dds":0.0,"last_synced_commit":"7b4355f14f21638b01391b25211ce28ee100e5cb"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/atomjoy/payu","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomjoy%2Fpayu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomjoy%2Fpayu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomjoy%2Fpayu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomjoy%2Fpayu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atomjoy","download_url":"https://codeload.github.com/atomjoy/payu/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomjoy%2Fpayu/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275483330,"owners_count":25473110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-16T02:00:10.229Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel-payments","laravel-payu","payu","payu-integration","payu-laravel","payu-php"],"created_at":"2024-11-10T13:37:24.520Z","updated_at":"2025-09-16T20:50:44.627Z","avatar_url":"https://github.com/atomjoy.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Payu Laravel\n\nPłatności PayU w Laravel. Jak utworzyć link do płatności za zamówienie w payu api.\n\n## Payu dokumentacja, sandbox\n\n\u003chttps://developers.payu.com/pl/overview.html#sandbox\u003e\n\n## Instalacja pakietu Laravela\n\nZainstaluj php composera ze strony \u003chttps://getcomposer.org/download\u003e\n\n```sh\ncomposer require atomjoy/payu \"^3.0.0\"\ncomposer update\ncomposer dump-autoload -o\n```\n\n## Konfiguracja Laravel\n\n### Dodaj bazę danych\n\nmysql -u root\n\n```sql\nCREATE DATABASE IF NOT EXISTS laravel CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;\nGRANT ALL PRIVILEGES ON laravel.* TO root@localhost IDENTIFIED BY 'toor' WITH GRANT OPTION;\nGRANT ALL PRIVILEGES ON laravel.* TO root@127.0.0.1 IDENTIFIED BY 'toor' WITH GRANT OPTION;\nFLUSH PRIVILEGES;\n\n# Clear or change password\nSET PASSWORD FOR root@localhost=PASSWORD('');\n\n# Change password\nALTER USER 'testing'@'localhost' IDENTIFIED BY 'toor';\nFLUSH PRIVILEGES;\n```\n\n### Konfiguracja .env\n\n```php\nDB_CONNECTION=mysql\nDB_HOST=127.0.0.1\nDB_PORT=3306\nDB_DATABASE=laravel\nDB_USERNAME=root\nDB_PASSWORD=toor\n```\n\n### Utwórz model Order\n\n```sh\nphp artisan make:model Order -a\n```\n\n### Migracja tabeli klasy Order\n\nDodaj kolumny w tabeli.\n\n```php\n\u003c?php\nuse Illuminate\\Database\\Migrations\\Migration;\nuse Illuminate\\Database\\Schema\\Blueprint;\nuse Illuminate\\Support\\Facades\\Schema;\n\nreturn new class extends Migration\n{\n  public function up()\n  {\n    Schema::create('orders', function (Blueprint $table) {\n      $table-\u003eid();\n      $table-\u003edecimal('cost', 15, 2)-\u003enullable()-\u003edefault(0.00);\n      $table-\u003eenum('payment_method', ['money', 'card', 'online', 'cashback'])-\u003enullable()-\u003edefault('money');\n      $table-\u003eenum('payment_gateway', ['payu'])-\u003enullable(true);\n      $table-\u003estring('firstname');\n      $table-\u003estring('lastname');\n      $table-\u003estring('phone');\n      $table-\u003estring('email');\n      $table-\u003etimestamps();\n      $table-\u003esoftDeletes();\n      $table-\u003eunsignedBigInteger('user_id')-\u003enullable(true);\n      $table-\u003eforeign('user_id')-\u003ereferences('id')-\u003eon('users')-\u003eonDelete('cascade')-\u003eonUpdate('cascade');\n    });\n  }\n\n  public function down()\n  {\n    Schema::dropIfExists('orders');\n  }\n};\n```\n\n### Klasa modelu Order\n\nDodaj interfejs do klasy zamówień i uzupełnij wymagane metody.\n\n```php\n\u003c?php\n\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Database\\Eloquent\\SoftDeletes;\nuse Payu\\Interfaces\\PayuOrderInterface;\nuse Payu\\Models\\Payment;\n\nclass Order extends Model implements PayuOrderInterface\n{\n  use HasFactory, SoftDeletes;\n\n  protected $guarded = [];\n\n  public function payments()\n  {\n    return $this-\u003ehasMany(Payment::class)-\u003ewithTrashed();\n  }\n\n  public function paid_payment()\n  {\n    return $this-\u003ehasOne(Payment::class)-\u003ewhere('status', 'COMPLETED')-\u003ewithTrashed()-\u003elatest();\n  }\n\n  // Wymagane metody poniżej\n  function orderId()\n  {\n    return $this-\u003eid;\n  }\n\n  function orderCost()\n  {\n    return $this-\u003ecost;\n  }\n\n  function orderFirstname()\n  {\n    return $this-\u003efirstname;\n  }\n\n  function orderLastname()\n  {\n    return $this-\u003elastname;\n  }\n\n  function orderPhone()\n  {\n    return $this-\u003ephone;\n  }\n\n  function orderEmail()\n  {\n    return $this-\u003eemail;\n  }\n}\n```\n\n### Utwórz tabele w bazie danych\n\n```sh\n# Aktualizuj tabelki\nphp artisan migrate\nphp artisan migrate --env=testing\n```\n\n### Utwórz i edytuj plik konfiguracyjny Payu Api\n\nconfig/payu.php\n\n```sh\nphp artisan vendor:publish --tag=payu-config\n```\n\n### Aktualizacja cache dir linux (gdy błędy)\n\n```sh\nsudo mkdir -p storage/framework/cache/payu\nsudo chown -R www-data:www-data storage/framework/cache/payu\nsudo chmod -R 770 storage/framework/cache/payu\n```\n\n### Edytuj strony potwierdzeń płatności (opcjonalnie)\n\nresources/views/vendor/payu\n\n```sh\nphp artisan vendor:publish --tag=payu-pages\n```\n\n### Dodaj folder logo payu (opcjonalnie)\n\npublic/vendor/payu\n\n```sh\nphp artisan vendor:publish --tag=payu-public --force\n```\n\n## Testy\n\n### Dodaj w phpunit.xml\n\n```xml\n\u003ctestsuite name=\"Payu\"\u003e\n  \u003cdirectory suffix=\"Test.php\"\u003e./vendor/atomjoy/payu/tests/Payu\u003c/directory\u003e\n\u003c/testsuite\u003e\n```\n\n### Tests tylko dla sandbox config(['payu.env' =\u003e 'sandbox'])\n\nUtworzy link do płatności w bazie danych w tabeli payments (do przekierowania klienta sklepu).\n\n```sh\nphp artisan test --testsuite=Payu --stop-on-failure\n```\n\n## Laravel PayU Api\n\nWyłączyć w panelu administracyjnym PayU automatyczny odbiór płatności jeśli chcesz potwierdzać płatności ręcznie dla statusu WAITING_FOR_CONFIRMATION na COMPLETED lub CANCELED.\n\n### Utwórz link do płatności dla zamówienia (sandbox)\n\nNumer zamówienia {orders.id} =\u003e 1, 2, 3, ...\n\n```sh\n# Utwórz zamowienie i link do płatności\nhttps://{your.domain.here}/web/payment/create\n\n# Lub utwórz link do płatności z id zamówienia\nhttps://{your.domain.here}/web/payment/url/payu/{orders.id}\n\n# Pobierz dane płatności\nhttps://{your.domain.here}/web/payment/retrive/payu/{orders.id}\n\n# Aktualizuj dane płatności\nhttps://{your.domain.here}/web/payment/refresh/payu/{orders.id}\n\n# Przyjmij płatność\nhttps://{your.domain.here}/web/payment/confirm/payu/{orders.id}\n\n# Odrzuć płatność\nhttps://{your.domain.here}/web/payment/cancel/payu/{orders.id}\n```\n\n### Lista routes do obsługi płatności (sandbox)\n\natomjoy/payu/routes/sandbox.php\n\n## Przykłady Payu Api w Laravel\n\n### Utwórz link płatności dla zamówienia (produkcja)\n\n```php\n\u003c?php\nuse App\\Models\\Order;\nuse Payu\\Facades\\Payu;\n\ntry {\n\n  // Create order here or get from db with id\n  $id = 'orders.id';\n\n  // Create payment url\n  $url = Payu::pay(Order::findOrFail($id));\n\n  // Redirect client to payment page\n  return redirect($url);\n\n} catch (QueryException | PDOException $e) {\n  report($e);\n  return response('Database Error.', 422);\n} catch (Exception $e) {\n  report($e);\n  return response($e-\u003egetMessage(), 422);\n}\n```\n\n### Potwierdź płatność (waiting_for_confirmation)\n\n```php\n\u003c?php\nuse App\\Models\\Order;\nuse Payu\\Facades\\Payu;\n\ntry {\n  $id = 'orders.id';\n  $status = Payu::confirm(Order::findOrFail($id));\n\n} catch (\\Exception $e) {\n  return $e-\u003egetMessage();\n}\n```\n\n### Odrzuć płatność (waiting_for_confirmation)\n\n```php\n\u003c?php\nuse App\\Models\\Order;\nuse Payu\\Facades\\Payu;\n\ntry {\n  $id = 'orders.id';\n  $status = Payu::cancel(Order::findOrFail($id));\n\n} catch (\\Exception $e) {\n  return $e-\u003egetMessage();\n}\n```\n\n### Aktualizuj płatność\n\n```php\n\u003c?php\nuse App\\Models\\Order;\nuse Payu\\Facades\\Payu;\n\ntry {\n  $id = 'orders.id';\n  $status = Payu::refresh(Order::findOrFail($id));\n\n} catch (\\Exception $e) {\n  return $e-\u003egetMessage();\n}\n```\n\n### Szczegóły płatności\n\n```php\n\u003c?php\nuse App\\Models\\Order;\nuse Payu\\Facades\\Payu;\n\ntry {\n  $id = 'orders.id';\n  $payment = Payu::retrive(Order::findOrFail($id));\n\n} catch (\\Exception $e) {\n  return $e-\u003egetMessage();\n}\n```\n\n### Szczegóły transakcji\n\n```php\n\u003c?php\nuse App\\Models\\Order;\nuse Payu\\Facades\\Payu;\n\ntry {\n  $id = 'orders.id';\n  $transaction = Payu::transaction(Order::findOrFail($id));\n\n} catch (\\Exception $e) {\n  return $e-\u003egetMessage();\n}\n```\n\n### Zwrot płatności w całości\n\n```php\n\u003c?php\nuse App\\Models\\Order;\nuse Payu\\Facades\\Payu;\n\ntry {\n  $id = 'orders.id';\n  $status = Payu::refund(Order::findOrFail($id));\n\n} catch (\\Exception $e) {\n  return $e-\u003egetMessage();\n}\n```\n\n### Szczegóły zwrotu płatności\n\n```php\n\u003c?php\nuse App\\Models\\Order;\nuse Payu\\Facades\\Payu;\n\ntry {\n  $id = 'orders.id';\n  $status = Payu::refunds(Order::findOrFail($id));\n\n} catch (\\Exception $e) {\n  return $e-\u003egetMessage();\n}\n```\n\n### Metody płatności lista\n\n```php\n\u003c?php\nuse Payu\\Facades\\Payu;\n\ntry {\n  $pay_methods = Payu::payments('pl');\n\n} catch (\\Exception $e) {\n  return $e-\u003egetMessage();\n}\n```\n\n## Zdarzenia Payu (events)\n\n```php\n\u003c?php\n\nuse Payu\\Events\\PayuPaymentCreated;\nuse Payu\\Events\\PayuPaymentCanceled;\nuse Payu\\Events\\PayuPaymentConfirmed;\nuse Payu\\Events\\PayuPaymentRefunded;\nuse Payu\\Events\\PayuPaymentNotified;\n```\n\n## Przechwytywanie zdarzeń (listeners)\n\n```sh\nphp artisan make:listener PaymentCreatedNotification --event=PayuPaymentCreated\n```\n\n## Tworzenie klas dla modeli\n\n```sh\nphp artisan make:model Order -a\nphp artisan make:resource OrderResource\nphp artisan make:resource OrderCollection\n```\n\n## Pobierz listę zamówień (admin panel)\n\n```php\n\u003c?php\n\nuse Illuminate\\Support\\Facades\\Route;\nuse App\\Models\\Order;\n\n// Przykład\nRoute::get('/orders', function () {\n  // Zamówienia z płatnościami\n  return Order::with('payment')-\u003eorderBy('created_at', 'desc')-\u003eget();\n\n  // Zamówienia z płatnościami i danymi klienta\n  return Order::with('payment','client')-\u003eorderBy('created_at', 'desc')-\u003eget();\n\n  // Filtruj kolumny\n  return Order::with(['payment' =\u003e function($query) {\n    $query-\u003eselect('id','id','total','status','status_refund','created_at')-\u003eorderBy('created_at', 'desc');\n  }])-\u003eorderBy('created_at', 'desc')-\u003eget();\n});\n```\n\n## LICENSE\n\nThis project is licensed under the terms of the GNU GPLv3 license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomjoy%2Fpayu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatomjoy%2Fpayu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomjoy%2Fpayu/lists"}