Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/waiap/vue_example
Browse files Browse the repository at this point in the history
  • Loading branch information
XayOn committed Apr 27, 2020
2 parents fbc019b + 7550237 commit d977e4a
Show file tree
Hide file tree
Showing 14 changed files with 323 additions and 257 deletions.
32 changes: 15 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
# vue_integration
# Vuejs example integration for WAIAP Payment Wall

## Project setup

You need to pre-install the project's dependencies.

```
npm install
```

### Compiles and hot-reloads for development

This serves the front-end app.

```
npm run serve
```

### hot-reload node backend

This serves an API backend

```
node src/server.js
npm run serve_api
```

### follow instrucctions to run ngrok - required for local environment

Needs to run the application with a valid url.

For testing ngrok can be used.
For testing ngrok can be used.

```
https://dashboard.ngrok.com/get-started
```

Update the generated ngrok url in ./src/server.js const _notify_url='<generated-ngrok-url>'


<!-- ### Compiles and minifies for production
```
npm run build
```
### Lints and fixes files
```
npm run lint
```
## Configuration

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/). -->
Setup notify_url to your NGROK's public URL each time before launching the api
service or the front-end
11 changes: 11 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const CONFIG = {
endpoint: "https://sandbox.sipay.es/pwall/api/v1/actions",
key: "your-key",
identity: "your-identity",
secret: "your-secret",
resource: "your-resource",
mode: "sha256",
notify_url: "https://url.ngrok.com/checkout"
};

module.exports = CONFIG;
11 changes: 3 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"serve_api": "node src/server.js",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
Expand Down Expand Up @@ -33,10 +34,7 @@
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"extends": ["plugin:vue/essential", "eslint:recommended"],
"rules": {},
"parserOptions": {
"parser": "babel-eslint"
Expand All @@ -47,8 +45,5 @@
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions"
]
"browserslist": ["> 1%", "last 2 versions"]
}
31 changes: 22 additions & 9 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<title>vue_integration</title>
<!-- Payment Wall hoja de estilos -->
<link href="https://sandbox.sipay.es/pwall_app/css/app.css" rel=stylesheet>
<link
href="https://sandbox.sipay.es/pwall_app/css/app.css"
rel="stylesheet"
/>
<!-- Payment Wall JavaScript para gestión de eventos -->
<script src="https://sandbox.sipay.es/pwall_sdk/pwall_sdk.bundle.js"></script>
</head>
<body>
<noscript>
<strong>We're sorry but vue_integration doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
<strong
>We're sorry but vue_integration doesn't work properly without
JavaScript enabled. Please enable it to continue.</strong
>
</noscript>
<div id="app2"></div>
<!--
data-timeout: can be set to any expected value based on the customer backend
<!--
data-timeout: can be set to any expected value based on the customer backend
-->
<script data-url="http://localhost:3000/test" data-amount="1" data-currency="EUR" data-timeout="30000" data-placeholder="#app" src="https://sandbox.sipay.es/pwall_app/js/app.js"></script>
<script
data-url="http://localhost:3000/actions/30000"
data-amount="1"
data-currency="EUR"
data-timeout="30000"
data-placeholder="#app"
src="https://sandbox.sipay.es/pwall_app/js/app.js"
></script>
<!-- built files will be auto injected -->

<!-- Payment Wall evento personalizado para gestionar los métodos de pago basados en REDIRECT.
Expand Down
4 changes: 2 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</div> -->
<router-view/>
<router-view />
</div>
</template>

<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
font-family: "Avenir", Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
Expand Down
75 changes: 45 additions & 30 deletions src/components/Pwall.vue
Original file line number Diff line number Diff line change
@@ -1,43 +1,58 @@
<template>
<div>
<div id="app">
</div>
<table id=result class="table table-dark" style="display: none">
<tr><td>Tarjeta</td><td id=masked_card></td></tr>
<tr><td>Ticket</td><td id=order></td></tr>
<tr><td>Banco</td><td id=authorizator></td></tr>
<tr><td>Moneda</td><td id=currency></td></tr>
<tr><td>ID Interno</td><td id=transaction_id></td></tr>
<div id="app"></div>
<table id="result" class="table table-dark" style="display: none">
<tr>
<td>Tarjeta</td>
<td id="masked_card"></td>
</tr>
<tr>
<td>Ticket</td>
<td id="order"></td>
</tr>
<tr>
<td>Banco</td>
<td id="authorizator"></td>
</tr>
<tr>
<td>Moneda</td>
<td id="currency"></td>
</tr>
<tr>
<td>ID Interno</td>
<td id="transaction_id"></td>
</tr>
</table>
</div>
</template>

<script>
export default {
name: 'Pwall',
name: "Pwall",
mounted() {
let vm = this;
document.dispatchEvent(new Event('payment_wall_load_app'));
// THIS IS REQUIRED for all integrations.
// This makes all redirect-based methods to finish its operation
document.getElementById('app').addEventListener(
'payment_wall_drawn',
function() {
if (vm.$route.query.request_id || vm.$route.query.reference_id) {
document.getElementById('app').dispatchEvent(
new CustomEvent('payment_wall_process_redirect', {
detail: {
request_id: vm.$route.query.request_id || vm.$route.query.reference_id,
method: vm.$route.query.method
}
})
);
}
});
let vm = this;
document.dispatchEvent(new Event("payment_wall_load_app"));
// THIS IS REQUIRED for all integrations.
// This makes all redirect-based methods to finish its operation
document
.getElementById("app")
.addEventListener("payment_wall_drawn", function() {
if (vm.$route.query.request_id || vm.$route.query.reference_id) {
document.getElementById("app").dispatchEvent(
new CustomEvent("payment_wall_process_redirect", {
detail: {
request_id:
vm.$route.query.request_id || vm.$route.query.reference_id,
method: vm.$route.query.method,
error: vm.$route.query.error || null
}
})
);
}
});
}
}
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>
<style scoped></style>
87 changes: 52 additions & 35 deletions src/components/Shop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,71 @@
@currency="e => currency = e"
/>
<Pwall v-else/> -->
<div class=container>
<form>
<h1>Bienvenido a la tienda de prueba del Payment Wall </h1>
<br>
<div class="container">
<form>
<h1>Bienvenido a la tienda de prueba del Payment Wall</h1>
<br />
<div>
<label for="currency">
Seleccione la moneda en la que desea operar. Esta elección está
habilitada para el usuario en el entorno de pruebas
</label>
<br /><br />
<select id="currency" v-model="model.currency">
<option disabled value="">Please select one</option>
<option value="EUR">EUR</option>
</select>
<br />
<span>Moneda seleccionada: {{ model.currency }}</span>
</div>
<br />
<h3>Listado de productos</h3>
<div>
<div>
<div>
<label for="currency">
Seleccione la moneda en la que desea operar. Esta elección está habilitada para el usuario en el entorno de pruebas
</label>
<br><br>
<select id="currency" v-model="model.currency">
<option disabled value=''>Please select one</option>
<option value='EUR'>EUR</option>
</select>
<br>
<span>Moneda seleccionada: {{ model.currency }}</span>
<img
class="item"
onclick="return check(this, 1)"
height="90"
src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/4e/Llavero_bal%C3%B3n_de_plata.jpg/256px-Llavero_bal%C3%B3n_de_plata.jpg"
/>
<p>Llavero balón de plata</p>
<h4>Precio: 0,01&euro;</h4>
</div>
<br>
<h3> Listado de productos </h3>
<div>
<div>
<div>
<img class=item onclick="return check(this, 1)" height="90" src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/4e/Llavero_bal%C3%B3n_de_plata.jpg/256px-Llavero_bal%C3%B3n_de_plata.jpg">
<p>Llavero balón de plata</p>
<h4>Precio: 0,01&euro;</h4>
</div>
</div>
<small id="amountHelp" class="form-text text-muted">Introduzca la cantidad de llaveros que desea comprar</small>
<br>
<label for="amount">Cantidad</label>
<input name=amount type="number" v-model="model.amount" id="amount" aria-describedby="amountHelp" placeholder="1" >
</div>
<router-link to="/checkout" :model="model" tag="button">Comprar</router-link>
</form>
</div>
<small id="amountHelp" class="form-text text-muted"
>Introduzca la cantidad de llaveros que desea comprar</small
>
<br />
<label for="amount">Cantidad</label>
<input
name="amount"
type="number"
v-model="model.amount"
id="amount"
aria-describedby="amountHelp"
placeholder="1"
/>
</div>
<router-link to="/checkout" :model="model" tag="button"
>Comprar</router-link
>
</form>
</div>
</div>
</template>

<script>
export default {
name: 'Shop',
data:() => ({
name: "Shop",
data: () => ({
model: {
currency: '',
currency: "",
amount: 1,
checkout: false
}
})
}
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
Expand Down
12 changes: 6 additions & 6 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";

Vue.config.productionTip = false
Vue.config.productionTip = false;

new Vue({
router,
store,
render: h => h(App)
}).$mount('#app2')
}).$mount("#app2");
Loading

0 comments on commit d977e4a

Please sign in to comment.