Skip to content

Commit

Permalink
Merge pull request #38 from placetopay-org/feature/gateway-doc
Browse files Browse the repository at this point in the history
Feature/gateway doc
  • Loading branch information
meiyerDev committed May 15, 2024
2 parents 5686ff9 + 665b5eb commit d41cc78
Show file tree
Hide file tree
Showing 48 changed files with 9,940 additions and 9 deletions.
Binary file added public/GatewayFlow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/IdempotenceFirst.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/IdempotenceSecond.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,292 changes: 3,292 additions & 0 deletions src/assets/apis/gateway/en.yaml

Large diffs are not rendered by default.

3,298 changes: 3,298 additions & 0 deletions src/assets/apis/gateway/es.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const MISSING_TRADUCTION_BANNER_TEXTS = {
},
}

export const MissingTraductionBanner = ({ locale = 'en' }) => {
export const MissingTranslationBanner = ({ locale = 'en' }) => {
return (
<article className="not-prose -mt-6 mb-6 w-full rounded border-l-2 border-gray-400 bg-white/[0.2] shadow-lg shadow-gray-700/60 backdrop-blur-sm dark:bg-gray-900/[0.2] dark:text-white/90 dark:backdrop-blur dark:hover:text-white">
<div className="mx-auto max-w-7xl p-3">
Expand Down
4 changes: 2 additions & 2 deletions src/components/Navigation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AnimatePresence, motion, useIsPresent } from 'framer-motion'


import { useLocalizePath } from '@/hooks/useLocalizePath'
import { useNavigation } from '@/hooks/useNavigation'
import { useNamespaceRoute, useNavigation } from '@/hooks/useNavigation'
import { useIsInsideMobileNavigation } from '@/components/MobileNavigation'
import { useSectionStore } from '@/components/SectionProvider'
import { Tag } from '@/components/Tag'
Expand Down Expand Up @@ -194,7 +194,7 @@ function NavigationGroup({ group, className }) {
}

export function Navigation(props) {
let navigation = useNavigation('checkout');
let navigation = useNavigation(useNamespaceRoute());

return (
<nav {...props}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/mdx.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export { Button } from '@/components/Button'
export { CodeGroup, Code as code, Pre as pre } from '@/components/Code'
export { ApiReader } from '@/components/ApiReader'
export { CopyContent } from '@/components/CopyContent'
export { MissingTraductionBanner } from '@/components/MissingTraductionBanner'
export { MissingTranslationBanner } from '@/components/MissingTranslationBanner'
export { GithubRepo } from '@/components/GithubRepo'

export const h2 = function H2(props) {
Expand Down
77 changes: 77 additions & 0 deletions src/constants/navigations.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,84 @@ const CHECKOUT_NAVIGATION_EN = [
},
]

const GATEWAY_NAVIGATION_ES = [
{
title: 'Gateway',
links: [
{ title: 'Introducción', href: '/gateway' },
{ title: 'Flujo de una transacción', href: '/gateway/transaction-flow' },
{ title: 'Obligaciones', href: '/gateway/obligations' },
]
},
{
title: 'Integración',
links: [
{ title: 'Autenticación', href: '/gateway/authentication' },
{ title: 'Números de tarjetas de pruebas', href: '/gateway/testing-card' },
{ title: 'Código de aerolíneas', href: '/gateway/airline-codes' },
{ title: 'Tipos de documentos', href: '/gateway/document-types' },
{ title: 'Tipos de transacciones', href: '/gateway/transaction-types' },
{ title: 'Control de idempotencia', href: '/gateway/idempotency' },
{ title: 'Importación ordenes de pago', href: '/gateway/import-payment-orders' },
{ title: 'Procesamiento con cuentas bancarias', href: '/gateway/processing-with-bank-accounts' },
]
},
{
title: 'API',
links: [
{ title: 'Obtener información', href: '/gateway/api-reference/information' },
{ title: 'Transacciones', href: '/gateway/api-reference/transaction' },
{ title: 'Tokenización de tarjetas', href: '/gateway/api-reference/tokenize' },
{ title: 'Proceso 3DS', href: '/gateway/api-reference/3ds' },
{ title: 'Proceso OTP', href: '/gateway/api-reference/otp' },
{ title: 'Operaciones con PinPad', href: '/gateway/api-reference/pinpad' },
{ title: 'Reporte de operaciones realizadas', href: '/gateway/api-reference/report' },
],
}
]

const GATEWAY_NAVIGATION_EN = [
{
title: 'Gateway',
links: [
{ title: 'Introduction', href: '/gateway' },
{ title: 'Transaction flow', href: '/gateway/transaction-flow' },
{ title: 'Obligations', href: '/gateway/obligations' },
]
},
{
title: 'Integration',
links: [
{ title: 'Authentication', href: '/gateway/authentication' },
{ title: 'Test card numbers', href: '/gateway/testing-card' },
{ title: 'Airline codes', href: '/gateway/airline-codes' },
{ title: 'Document types', href: '/gateway/document-types' },
{ title: 'Transaction types', href: '/gateway/transaction-types' },
{ title: 'Idempotency control', href: '/gateway/idempotency' },
{ title: 'Import payment orders', href: '/gateway/import-payment-orders' },
{ title: 'Processing with bank accounts', href: '/gateway/processing-with-bank-accounts' },
]
},
{
title: 'API',
links: [
{ title: 'Get information', href: '/gateway/api-reference/information' },
{ title: 'Transactions', href: '/gateway/api-reference/transaction' },
{ title: 'Card tokenization', href: '/gateway/api-reference/tokenize' },
{ title: '3DS process', href: '/gateway/api-reference/3ds' },
{ title: 'OTP process', href: '/gateway/api-reference/otp' },
{ title: 'PinPad Operations', href: '/gateway/api-reference/pinpad' },
{ title: 'Report of operations carried out', href: '/gateway/api-reference/report' },
],
}
]

export const CHECKOUT_NAVIGATION = {
[LANGUAGES_CODES.ES]: CHECKOUT_NAVIGATION_ES,
[LANGUAGES_CODES.EN]: CHECKOUT_NAVIGATION_EN,
}

export const GATEWAY_NAVIGATION = {
[LANGUAGES_CODES.ES]: GATEWAY_NAVIGATION_ES,
[LANGUAGES_CODES.EN]: GATEWAY_NAVIGATION_EN,
}
12 changes: 11 additions & 1 deletion src/hooks/useNavigation.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import { useLocale } from "@/components/LocaleProvider";
import { CHECKOUT_NAVIGATION } from "@/constants/navigations";
import { CHECKOUT_NAVIGATION, GATEWAY_NAVIGATION } from "@/constants/navigations";
import { useRouter } from "next/router";

export const useNamespaceRoute = () => {
const router = useRouter();
const paths = router.pathname.split('/', 3);
const namespace = paths[1] && paths[1].length > 2 ? paths[1] : paths[2];
return namespace === 'checkout' ? 'checkout' : 'gateway';
}

export const useNavigation = (namespaces) => {
const {locale} = useLocale();

switch (namespaces) {
case 'checkout':
return CHECKOUT_NAVIGATION[locale];
case 'gateway':
return GATEWAY_NAVIGATION[locale];
default:
throw new Error(`The namespace navigation '${namespaces}' is not defined`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/dereferenceOpenapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fs from 'fs'

const getLocale = (fileUrl) => {
const possibleLocale = new URL(fileUrl).pathname.split('/src/pages/')[1].split('/')[0];
return ['en', 'fr'].includes(possibleLocale) ? possibleLocale : 'es';
return ['en'].includes(possibleLocale) ? possibleLocale : 'es';
}

const getRouteWithLocale = (fileUrl) => {
Expand Down
139 changes: 139 additions & 0 deletions src/pages/en/gateway/airline-codes.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Airlines

## Codes

When dispersion transactions are made to airlines, these are the agreement codes for each of them.

Code | Airline
-------|----------
2 | AIR CANADA Internacional
6 | AEROL. ARGENTINAS Internacional
7 | SERVINCLUIDOS Nacional
8 | SERVINCLUIDOS Internacional
10 | AEROGAL Internacional
11 | COPA DOMESTICO Nacional
18 | AIR FRANCE Internacional
23 | SATENA VISA DISTRIBUCION Nacional
26 | American Airlines
29 | AVIANCA Nacional
30 | AVIANCA Internacional
31 | MAYATUR Nacional
32 | MAYATUR Internacional
33 | COPA INTERNACIONAL
36 | CUBANA DE AVIACION Internacional
38 | IBERIA Internacional
40 | QANTAS Internacional
42 | LACSA Internacional
43 | OCTOPUS TRAVEL Nacional
44 | OCTOPUS TRAVEL Internacional
45 | EASYFLY Nacional
50 | SANTA BARBARA AIRLINES Internacional
53 | SATENA Nacional
56 | DUTCH ANTILLES EXPR Internacional
58 | VARIG Internacional
63 | AVIANCA DESKUBRA Nacional
64 | AVIANCA DESKUBRA Internacional
71 | AVIATUR S.A. DAV NAL Nacional
72 | AVIATUR S.A. DAV INT. Internacional
74 | ASERCA AIRLINES Internacional
78 | DELTA Internacional
84 | TRANS AMERICAN Internacional
86 | LUFTHANSA Internacional
87 | LAN AIRLINES Nacional
88 | LAN AIRLINES Internacional
91 | ADA Nacional
98 | AIR EUROPA Internacional
99 | AGENCIAS DE VIAJES - T.A. Internacional
100 | AEROMEXICO Internacional
101 | CONVIASA Internacional
103 | INSEL AIR Internacional
104 | UNITED AIRLINES Internacional
105 | JETBLUE AIRWAYS Internacional
106 | TACA AIRLINES Internacional
108 | KOREAN AIR LINES Internacional
109 | TAME LINEA AEREA DEL ECUADOR Internacional
110 | AIR PANAMA Suc.Col Internacional
111 | AVIAREPS COLOMBIA Internacional
112 | AVIA MARKETING LTDA NAL Nacional
113 | AVIA MARKETING LTDA INT Internacional
114 | ABC AEROLINEAS SA DE CV Internacional
115 | KLM HOLANDESA DE AVIACION Internacional
116 | OCEANAIR LINHAS AEREAS S.A Internacional
117 | TURKISH AIRLINES
119 | TAP PORTUGAL
120 | ASIANA AIRLINES
121 | ETHIOPIAN AIRLINES
122 | EMIRATES
123 | SINGAPORE AIRLINES
124 | Viva Air Colombia
125 | Viva Air Perú
126 | SKY Airline Nacional
127 | SKY Airline Internacional

## Example of an airline dispersal request

```json
{
...
"payment": {
"reference": "ON1434012-PN1433129",
"description": "Vuelo 50 AV2020",
"amount": {
"taxes": [
{
"kind": "airportTax",
"amount": 63
},
{
"kind": "valueAddedTax",
"amount": 158.47
}
],
"currency": "USD",
"total": 1161.12
},
"dispersion": [
{
"agreement": 29,
"agreementType": "AIRLINE",
"amount": {
"taxes": [
{
"kind": "airportTax",
"amount": 63
},
{
"kind": "valueAddedTax",
"amount": 142.5
}
],
"currency": "USD",
"total": 1055.5
}
},
{
"agreement": null,
"agreementType": "MERCHANT",
"amount": {
"taxes": [
{
"kind": "valueAddedTax",
"amount": 15.97
}
],
"currency": "USD",
"total": 105.62
}
}
]
},
"instrument": {
"card": {
"number": "5180300000000005",
"expiration": "12/24",
"cvv": "123"
}
}
...
}
```
94 changes: 94 additions & 0 deletions src/pages/en/gateway/api-reference/3ds.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
export const apiRefs = ['/gateway/mpi/lookup', '/gateway/mpi/query']

## 3DS Lookup {{ id: 'mpi-lookup-request', tag: 'POST', label: '/gateway/mpi/lookup' }}

<Row>
<Col>
Performs the initial 3DS validation process, returning the data so that the user can continue with the process

<ApiReader
path="/gateway/mpi/lookup"
method="post"
api={props.refs}
/>
</Col>

<Col sticky>
<CodeGroup title="Solicitud" tag="POST" label="/gateway/mpi/lookup">
```bash {{ title: 'cURL' }}
curl -X "POST" https://api-co-dev.placetopay.ws/gateway/mpi/lookup \
-H "Content-Type: application/json" \
-d '{
"locale": "es_CO",
"auth": {
"login":"c51ce410c124a10e0db5e4b97fc2af39",
"tranKey":"VQOcRcVH2DfL6Y4B4SaK6yhoH/VOUveZ3xT16OQnvxE=",
"nonce":"NjE0OWVkODgwYjNhNw==",
"seed":"2021-09-21T09:34:48-05:00"
},
"payment": {
"reference": "1122334455",
"description": "Testing Payment",
"amount": {
"currency": "USD",
"total": 100
}
},
"instrument": {
"card": {
"number": "4110760000000008",
"expiration": "12/20",
"cvv": "123"
}
},
"returnUrl": "https://www.your-site.com/return?reference=1234567890"
}'
```
</CodeGroup>
</Col>
</Row>

---

## 3DS Query {{ id: 'mpi-query-request', tag: 'POST', label: '/gateway/mpi/query' }}

<Row>
<Col>
Once the user has completed the authentication process in 3DS, this endpoint is used to obtain the result of their operation

> ### Important Note
>
> *When consuming this service **NOT** the transaction is being authenticated by default, the value of `data` must be taken from the response and sent in the `instrument.threeDS`*

<ApiReader
path="/gateway/mpi/query"
method="post"
api={props.refs}
/>
</Col>

<Col sticky>
<CodeGroup title="Solicitud" tag="POST" label="/gateway/mpi/query">
```bash {{ title: 'cURL' }}
curl -X "POST" https://api-co-dev.placetopay.ws/gateway/mpi/query \
-H "Content-Type: application/json" \
-d '{
"auth": {
"login":"c51ce410c124a10e0db5e4b97fc2af39",
"tranKey":"VQOcRcVH2DfL6Y4B4SaK6yhoH/VOUveZ3xT16OQnvxE=",
"nonce":"NjE0OWVkODgwYjNhNw==",
"seed":"2021-09-21T09:34:48-05:00"
},
"instrument": {
"card": {
"number": "4110760000000008",
"expiration": "12/20",
"cvv": "123"
}
},
"id": "1"
}'
```
</CodeGroup>
</Col>
</Row>
Loading

0 comments on commit d41cc78

Please sign in to comment.