Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: v.0.1 #7

Closed
wants to merge 112 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
34b0e47
feat: add image for dark mode
victormendoza96 Jul 19, 2024
025af99
feat: add css for dark mode
victormendoza96 Jul 19, 2024
b5c2f9f
fix: use correct tag for text
victormendoza96 Jul 19, 2024
1b937d6
feat: create dark mode component
victormendoza96 Jul 19, 2024
df4caf6
feat: prepare dark mode ins layouts
victormendoza96 Jul 19, 2024
647d5c2
fix: use correct html tag for images
victormendoza96 Jul 19, 2024
3bc2c08
feat: add dark mode component in header
victormendoza96 Jul 19, 2024
9b05f65
fix: typo
victormendoza96 Jul 19, 2024
1e85ff2
fix: remove commet
victormendoza96 Jul 19, 2024
8f528d0
feat: add dark mode in local storage
victormendoza96 Jul 19, 2024
332b92e
fix: correct method in docs
victormendoza96 Jul 19, 2024
727abec
Merge pull request #2 from TransbankDevelopers/feat/dark-mode
victormendoza96 Jul 19, 2024
4388138
chore: add highlight for snippets
victormendoza96 Jul 24, 2024
9beeca9
refactor: move css to resources file
victormendoza96 Jul 24, 2024
8f05d17
feat: add table css
victormendoza96 Jul 24, 2024
9a93860
feat: add image for copy text in snippet
victormendoza96 Jul 24, 2024
5e2353b
fix: remove empty line
victormendoza96 Jul 24, 2024
da3fe20
feat: create snippet component
victormendoza96 Jul 24, 2024
8ba0ed1
feat: create responsive table component
victormendoza96 Jul 24, 2024
c0622ee
refactor: use vite for compile css and js
victormendoza96 Jul 24, 2024
de41556
feat: use snippet component
victormendoza96 Jul 24, 2024
3a84566
fix: remove coments
victormendoza96 Jul 24, 2024
37bdfc5
feat: use dinamic token for snippet
victormendoza96 Jul 24, 2024
1e23f92
fix: use correct variable
victormendoza96 Jul 24, 2024
a23470c
Merge pull request #3 from TransbankDevelopers/feat/snippet
victormendoza96 Jul 24, 2024
195a76d
Create routes
victormendoza96 Jul 25, 2024
ae67e30
feat: add webpayMall controler
victormendoza96 Jul 25, 2024
bcfb602
docs: update readme description
victormendoza96 Jul 28, 2024
34e44fd
feat: create methods for webpay mall
victormendoza96 Jul 28, 2024
024a7ec
feat: create webpay mall controller
victormendoza96 Jul 28, 2024
3605f3f
feat: add routes for webpay mall
victormendoza96 Jul 28, 2024
a484d05
fix: use correct route for webpay mall
victormendoza96 Jul 28, 2024
5086fdf
feat: add css for links
victormendoza96 Jul 28, 2024
29e2d39
feat: add create page
victormendoza96 Jul 28, 2024
87e08e3
feat: add commit page
victormendoza96 Jul 28, 2024
fe3c632
feat: add refund page
victormendoza96 Jul 28, 2024
c1bd88a
feat: add status page
victormendoza96 Jul 28, 2024
3f87b32
refactor: use pre and code tag
victormendoza96 Jul 29, 2024
becaa06
Merge pull request #4 from TransbankDevelopers/feat/webpay-mall
victormendoza96 Jul 29, 2024
96a40d0
feat: create controller for webpay deferred
victormendoza96 Jul 30, 2024
7ef7136
feat: add routes for webpay deferred
victormendoza96 Jul 30, 2024
0c20242
fix: use cerrect link for webpay deferred
victormendoza96 Jul 30, 2024
46920b4
feat: add create view for webpay deferred
victormendoza96 Jul 30, 2024
bf13b26
feat: add commit view for webpay deferred
victormendoza96 Jul 30, 2024
f6bb57a
feat: add capture view for webpay deferred
victormendoza96 Jul 30, 2024
0937f43
feat: add refund view for webpay deferred
victormendoza96 Jul 30, 2024
e0082ff
feat: add status view for webpay deferred
victormendoza96 Jul 30, 2024
8b798c0
fix: typo
victormendoza96 Jul 30, 2024
4beef3e
chore: add sonar cloud
mastudillot Jul 30, 2024
2968c28
Merge pull request #5 from TransbankDevelopers/feat/webpay-deferred
victormendoza96 Jul 30, 2024
4317c58
Merge pull request #6 from TransbankDevelopers/chore/add-sonar-cloud
mastudillot Jul 30, 2024
4e19cb1
refactor: use only one var
victormendoza96 Aug 1, 2024
cb8ead8
feat: create controller for webpay mall deferred
victormendoza96 Aug 1, 2024
6aae662
feat: create routes for webpay mall deferred
victormendoza96 Aug 1, 2024
e92e736
fix: use correct links for webpay mall deferred
victormendoza96 Aug 1, 2024
8f43dc9
feat: support for array whit arrays
victormendoza96 Aug 1, 2024
5eaf981
fix: use correct titles
victormendoza96 Aug 1, 2024
3f4db3e
feat: add create view for webpay mall deferred
victormendoza96 Aug 1, 2024
71255b5
feat: add commit view for webpay mall deferred
victormendoza96 Aug 1, 2024
36ef7b8
feat: add capture view for webpay mall deferred
victormendoza96 Aug 1, 2024
9877517
feat: add refund view for webpay mall deferred
victormendoza96 Aug 1, 2024
0f507dd
feat: add status view for webpay mall deferred
victormendoza96 Aug 1, 2024
6082d66
fix: typo
victormendoza96 Aug 1, 2024
e355c9a
fix: remove casting
victormendoza96 Aug 1, 2024
8d20993
Merge pull request #8 from TransbankDevelopers/feat/webpay-mall-deferred
mastudillot Aug 5, 2024
784d28b
feat: create error page
victormendoza96 Aug 22, 2024
7d04803
feat: create delete page for oneclick
victormendoza96 Aug 22, 2024
17aa158
feat: create oneclikmallcontroller
victormendoza96 Aug 22, 2024
3d72d41
feat: add css for multile line fields in card
victormendoza96 Aug 22, 2024
f6b550a
refactor: use correct url dor oneclick mall
victormendoza96 Aug 22, 2024
4c56233
refactor: use correct url for oneclick in menu
victormendoza96 Aug 22, 2024
caea63f
feat: create authorize page for oneclick mall
victormendoza96 Aug 22, 2024
49a3c46
feat: create finish page for oneclick mall
victormendoza96 Aug 22, 2024
d1c2c56
feat: create refund page for oneclick mall
victormendoza96 Aug 22, 2024
c107376
feat: create error rejected page for oneclick mall
victormendoza96 Aug 22, 2024
491dc33
feat: create start inscription page for oneclick mall
victormendoza96 Aug 22, 2024
9965507
feat: create status page for oneclick mall
victormendoza96 Aug 22, 2024
9979f99
feat: create timeout page for oneclick mall
victormendoza96 Aug 22, 2024
08910ab
feat: add protection for window.opener
victormendoza96 Aug 22, 2024
22ee5d4
fix: use correct tag
victormendoza96 Aug 22, 2024
15b372b
feat: create routes for oneclick mall
victormendoza96 Aug 22, 2024
8b573ce
fix: typo
victormendoza96 Aug 26, 2024
83cf6d1
feat: add more info about refund
victormendoza96 Aug 26, 2024
76adb12
refactor: resume content
victormendoza96 Aug 26, 2024
89601e8
fix: magic numbers
victormendoza96 Aug 26, 2024
758f076
fix : typo
victormendoza96 Aug 26, 2024
4df6b80
fix: multiple return
victormendoza96 Aug 26, 2024
f63d752
fix: typo
victormendoza96 Aug 26, 2024
c7e91b4
feat: add recorevytransaction page
victormendoza96 Aug 26, 2024
1f01056
feat: create controller for onclick deferred
victormendoza96 Aug 27, 2024
c607241
feat: add onclick deferred routes
victormendoza96 Aug 27, 2024
dbde856
fix: use correct route for onclik deferred
victormendoza96 Aug 27, 2024
c48e6e5
feat: create error pages
victormendoza96 Aug 28, 2024
96ad3f8
feat: create start page for onclick deferred
victormendoza96 Aug 28, 2024
b9f9113
feat: create finish page for onclick deferred
victormendoza96 Aug 28, 2024
0aa19bc
feat: create suthorize page for onclick deferred
victormendoza96 Aug 28, 2024
228246a
feat: create capture page for onclick deferred
victormendoza96 Aug 28, 2024
e3b95f4
feat: create delete page for onclick deferred
victormendoza96 Aug 28, 2024
96d685f
feat: create refund page for onclick deferred
victormendoza96 Aug 28, 2024
83fb54f
feat: create status page for onclick deferred
victormendoza96 Aug 28, 2024
7ddd08b
fix: use correct commerce code
victormendoza96 Aug 28, 2024
86399f8
refactor: use elseif
victormendoza96 Aug 28, 2024
0783d12
feat: add link to github issue
victormendoza96 Aug 28, 2024
f04bf57
feat: add more info for timeout in integration
victormendoza96 Aug 28, 2024
1d78806
feat: add more info for timeout in integration
victormendoza96 Aug 28, 2024
b6813f7
refactor: use elseif
victormendoza96 Aug 28, 2024
978905a
fix: remove route
victormendoza96 Aug 28, 2024
6d8bb89
Merge pull request #9 from TransbankDevelopers/feat/oneclick-mall
victormendoza96 Aug 28, 2024
ad72ef0
Merge branch 'develop' of github.com:TransbankDevelopers/transbank-sd…
victormendoza96 Aug 28, 2024
d59b59f
fix: remove unnecesary route
victormendoza96 Aug 28, 2024
3f4f1ac
fix: typo
victormendoza96 Sep 9, 2024
cae6dbf
Merge pull request #10 from TransbankDevelopers/feat/oneclick-deferred
victormendoza96 Sep 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Sonar Scan
on:
push:
branches:
- main
pull_request:
branches:
- **
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# ChatBot para soporte
# Proyecto de Ejemplo SDK PHP

## Descripción

ChatBot de Slack que se conecta con un LLM para apoyar el soporte a las comunidades.
Proyecto de ejemplo mostrando el paso a paso de como usar el SDK PHP de transbank

## Requisitos

- Node 18+
- Slack Bolt
- Dotenv
- PHP 8.3+
- laravel 11

## Iniciar aplicación

Expand Down
153 changes: 153 additions & 0 deletions app/Http/Controllers/OneclickMallController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Transbank\Webpay\Options;
use Transbank\Webpay\Oneclick\MallInscription;
use Transbank\Webpay\Oneclick\MallTransaction;

class OneclickMallController extends Controller
{

const TIMEOUT = -96;
const REJECTED = -1;
const COMMERCE_CODE = "597055555541";
const API_KEY = "579B532A7440BB0C9079DED94D31EA1615BACEB56610332264630D42D0A36B1C";
private MallInscription $mallInscription;
private MallTransaction $mallTransaction;

public function __construct()
{
$option = new Options(self::API_KEY, self::COMMERCE_CODE, Options::ENVIRONMENT_INTEGRATION);
$this->mallInscription = new MallInscription($option);
$this->mallTransaction = new MallTransaction($option);
}

public function startInscription()
{
try {

$startTx = [
"username" => "User-" . random_int(1, 10000),
"email" => "user." . random_int(1, 10000) . "@example.cl",
"response_url" => url("/") . "/oneclick-mall/finish"
];

session(['username' => $startTx["username"]]);
$resp = $this->mallInscription->start($startTx["username"], $startTx["email"], $startTx["response_url"]);
return view('oneclick-mall.start', ["request" => $startTx, "resp" => $resp]);
} catch (\Exception $e) {
$error = ["msg" => $e->getMessage(), "code" => $e->getCode()];
return view('error-page', ["error" => $error]);
}
}

public function finishInscription(Request $request)
{
try {
$view = 'error-page';
$data = ["error" => $request];
$params = $request->only(['TBK_ORDEN_COMPRA', 'TBK_TOKEN', 'TBK_ID_SESION']);
$token = $request["TBK_TOKEN"];
$userName = session('username', '');

if ($request->exists("TBK_ORDEN_COMPRA")) {
return view('oneclick-mall.recoverTransaction', ["req" => $params]);
}

$resp = $this->mallInscription->finish($token);

if ($resp->responseCode == self::REJECTED) {
$view = 'oneclick-mall.rejected';
$data = ["resp" => $resp, "token" => $token];
} elseif ($resp->responseCode == self::TIMEOUT) {
$view = 'oneclick-mall.timeout';
$data = ["resp" => $resp];
} else {
$table = [
"username" => $userName,
"tbk_user" => $resp->tbkUser,
];
$data = ["resp" => $resp, "token" => $token, "table" => $table];
$view = 'oneclick-mall.finish';
}

return view($view, $data);
} catch (\Exception $e) {
$error = ["msg" => $e->getMessage(), "code" => $e->getCode()];
return view('error-page', ["error" => $error]);
}
}
public function deleteInscription(Request $request)
{
try {
$tbkUser = $request["tbkUser"];
$userName = $request["userName"];
$resp = $this->mallInscription->delete($tbkUser, $userName);
return view('oneclick-mall.delete', ["resp" => $resp]);
} catch (\Exception $e) {
$error = ["msg" => $e->getMessage(), "code" => $e->getCode()];
return view('error-page', ["error" => $error]);
}
}

public function authorizeMall(Request $request)
{
try {
$tbkUser = $request["tbkUser"];
$userName = $request["userName"];
$buyOrder = "O-" . random_int(1000, 9999);
$details = [
[
"commerce_code" => "597055555542",
"buy_order" => "O1-" . random_int(1000, 9999),
"amount" => 1693,
"installments_number" => 1
],
[
"commerce_code" => "597055555543",
"buy_order" => "O2-" . random_int(1000, 9999),
"amount" => 1960,
"installments_number" => 1
]
];

$resp = $this->mallTransaction->authorize($userName, $tbkUser, $buyOrder, $details);
return view('oneclick-mall.authorize', ["resp" => $resp]);
} catch (\Exception $e) {
$error = ["msg" => $e->getMessage(), "code" => $e->getCode()];
return view('error-page', ["error" => $error]);
}
}

public function status(Request $request)
{
try {
$buyOrder = $request["buyOrder"];
$resp = $this->mallTransaction->status($buyOrder);
return view('oneclick-mall.status', ["resp" => $resp]);
} catch (\Exception $e) {
$error = ["msg" => $e->getMessage(), "code" => $e->getCode()];
return view('error-page', ["error" => $error]);
}
}

public function refund(Request $request)
{
try {
$req = $request->except('_token');
$buyOrder = $req["buyOrder"];
$childCommerceCode = $req["childCommerceCode"];
$childBuyOrder = $req["childBuyOrder"];
$amount = $req["amount"];

$resp = $this->mallTransaction->refund($buyOrder, $childCommerceCode, $childBuyOrder, $amount);

return view('oneclick-mall.refund', ["resp" => $resp]);
} catch (\Exception $e) {
$error = ["msg" => $e->getMessage(), "code" => $e->getCode()];
return view('error-page', ["error" => $error]);
}
}
}
171 changes: 171 additions & 0 deletions app/Http/Controllers/OneclickMallDeferredController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Transbank\Webpay\Options;
use Transbank\Webpay\Oneclick\MallInscription;
use Transbank\Webpay\Oneclick\MallTransaction;

class OneclickMallDeferredController extends Controller
{
const TIMEOUT = -96;
const REJECTED = -1;
const COMMERCE_CODE = "597055555547";
const API_KEY = "579B532A7440BB0C9079DED94D31EA1615BACEB56610332264630D42D0A36B1C";
private MallInscription $mallInscription;
private MallTransaction $mallTransaction;

public function __construct()
{
$option = new Options(self::API_KEY, self::COMMERCE_CODE, Options::ENVIRONMENT_INTEGRATION);
$this->mallInscription = new MallInscription($option);
$this->mallTransaction = new MallTransaction($option);
}

public function startInscription()
{
try {

$startTx = [
"username" => "User-" . random_int(1, 10000),
"email" => "user." . random_int(1, 10000) . "@example.cl",
"response_url" => url("/") . "/oneclick-mall-diferido/finish"
];

session(['username' => $startTx["username"]]);
$resp = $this->mallInscription->start($startTx["username"], $startTx["email"], $startTx["response_url"]);
return view('oneclick-mall-deferred.start', ["request" => $startTx, "resp" => $resp]);
} catch (\Exception $e) {
$error = ["msg" => $e->getMessage(), "code" => $e->getCode()];
return view('error-page', ["error" => $error]);
}
}

public function finishInscription(Request $request)
{
try {
$view = 'error-page';
$data = ["error" => $request];
$params = $request->only(['TBK_ORDEN_COMPRA', 'TBK_TOKEN', 'TBK_ID_SESION']);
$token = $request["TBK_TOKEN"];
$userName = session('username', '');

if ($request->exists("TBK_ORDEN_COMPRA")) {
return view('oneclick-mall-deferred.recoverTransaction', ["req" => $params]);
}

$resp = $this->mallInscription->finish($token);

if ($resp->responseCode == self::REJECTED) {
$view = 'oneclick-mall-deferred.rejected';
$data = ["resp" => $resp, "token" => $token];
} elseif ($resp->responseCode == self::TIMEOUT) {
$view = 'oneclick-mall-deferred.timeout';
$data = ["resp" => $resp];
} else {
$table = [
"username" => $userName,
"tbk_user" => $resp->tbkUser,
];
$data = ["resp" => $resp, "token" => $token, "table" => $table];
$view = 'oneclick-mall-deferred.finish';
}

return view($view, $data);
} catch (\Exception $e) {
$error = ["msg" => $e->getMessage(), "code" => $e->getCode()];
return view('error-page', ["error" => $error]);
}
}
public function deleteInscription(Request $request)
{
try {
$tbkUser = $request["tbkUser"];
$userName = $request["userName"];
$resp = $this->mallInscription->delete($tbkUser, $userName);
return view('oneclick-mall-deferred.delete', ["resp" => $resp]);
} catch (\Exception $e) {
$error = ["msg" => $e->getMessage(), "code" => $e->getCode()];
return view('error-page', ["error" => $error]);
}
}

public function authorizeMall(Request $request)
{
try {
$tbkUser = $request["tbkUser"];
$userName = $request["userName"];
$buyOrder = "O-" . random_int(1000, 9999);
session(['buyOrder' => $buyOrder]);
$details = [
[
"commerce_code" => 597055555548,
"buy_order" => "O1-" . random_int(1000, 9999),
"amount" => 1693,
"installments_number" => 1
],
[
"commerce_code" => 597055555549,
"buy_order" => "O2-" . random_int(1000, 9999),
"amount" => 1960,
"installments_number" => 1
]
];

$resp = $this->mallTransaction->authorize($userName, $tbkUser, $buyOrder, $details);
return view('oneclick-mall-deferred.authorize', ["resp" => $resp]);
} catch (\Exception $e) {
$error = ["msg" => $e->getMessage(), "code" => $e->getCode()];
return view('error-page', ["error" => $error]);
}
}

public function capture(Request $request)
{
try {
$req = $request->except('_token');
$childBuyOrder = $req["childBuyOrder"];
$childCommerceCode = $req["childCommerceCode"];
$authorizationCode = $req["authorizationCode"];
$amount = $req["amount"];
$buyOrder = session('buyOrder', '');

$resp = $this->mallTransaction->capture($childCommerceCode, $childBuyOrder, $authorizationCode, $amount);
return view('oneclick-mall-deferred.capture', ["resp" => $resp, "req" => $req, "buyOrder" => $buyOrder]);
} catch (\Exception $e) {
$error = ["msg" => $e->getMessage(), "code" => $e->getCode()];
return view('error-page', ["error" => $error]);
}
}

public function status(Request $request)
{
try {
$buyOrder = $request["buyOrder"];
$resp = $this->mallTransaction->status($buyOrder);
return view('oneclick-mall-deferred.status', ["resp" => $resp]);
} catch (\Exception $e) {
$error = ["msg" => $e->getMessage(), "code" => $e->getCode()];
return view('error-page', ["error" => $error]);
}
}

public function refund(Request $request)
{
try {
$req = $request->except('_token');
$buyOrder = $req["buyOrder"];
$childCommerceCode = $req["childCommerceCode"];
$childBuyOrder = $req["childBuyOrder"];
$amount = $req["amount"];

$resp = $this->mallTransaction->refund($buyOrder, $childCommerceCode, $childBuyOrder, $amount);

return view('oneclick-mall-deferred.refund', ["resp" => $resp]);
} catch (\Exception $e) {
$error = ["msg" => $e->getMessage(), "code" => $e->getCode()];
return view('error-page', ["error" => $error]);
}
}
}
Loading