Skip to content

Commit 236ee5a

Browse files
committed
Merge branch 'OP-159-API-Payment-widget' into 'sprint'
Resolve OP-159 "Api payment widget" See merge request open-platform/api!197
2 parents c899532 + 496b8c9 commit 236ee5a

17 files changed

+9400
-2513
lines changed

build.gradle

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ plugins {
1111
apply plugin: "io.spring.dependency-management"
1212

1313
group = "io.openfuture.api"
14-
version = "2.5.0"
14+
version = "2.6.0"
1515
sourceCompatibility = JavaVersion.VERSION_1_8
1616

1717
repositories {
@@ -62,6 +62,7 @@ dependencies {
6262
sourceSets {
6363
main.kotlin.srcDirs += 'src/main/kotlin'
6464
main.resources.srcDirs += 'frontend/build/resources'
65+
main.resources.srcDirs += 'widget/build/resources'
6566
}
6667

6768
// Kotlin
@@ -100,4 +101,5 @@ jacocoTestReport {
100101
check.dependsOn jacocoTestReport
101102

102103
// Front
103-
processResources.dependsOn(':frontend:assemble')
104+
processResources.dependsOn(':frontend:assemble')
105+
processResources.dependsOn(':widget:assemble')

frontend/package-lock.json

+2,547-2,511
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

settings.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
rootProject.name = 'open-api'
22

33
include 'frontend'
4+
include 'widget'
5+

src/main/kotlin/io/openfuture/api/config/SecurityConfig.kt

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class SecurityConfig(
2727
override fun configure(http: HttpSecurity) {
2828
http.cors()
2929
http.csrf().disable()
30+
http.headers().frameOptions().disable()
3031

3132
// @formatter:off
3233
http

src/main/kotlin/io/openfuture/api/controller/base/MainController.kt

+9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ package io.openfuture.api.controller.base
22

33
import io.openfuture.api.config.propety.AuthorizationProperties
44
import org.springframework.stereotype.Controller
5+
import org.springframework.web.bind.annotation.CrossOrigin
56
import org.springframework.web.bind.annotation.GetMapping
7+
import org.springframework.web.bind.annotation.PathVariable
8+
import org.springframework.web.servlet.ModelAndView
69
import javax.servlet.http.Cookie
710
import javax.servlet.http.HttpServletResponse
811

@@ -21,4 +24,10 @@ class MainController(
2124
@GetMapping("/", "/scaffold", "/scaffolds", "/scaffolds/**", "/keys", "/keys/**")
2225
fun frontend() = "frontend"
2326

27+
@GetMapping("/widget/{address}")
28+
fun widget(@PathVariable address: String, modelAndView: ModelAndView): String {
29+
modelAndView.modelMap.addAttribute("address", address)
30+
return "widget"
31+
}
32+
2433
}

widget/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Open-widget
2+
This is a payment widget that you can embed to your site for processing payments from customers in the Cryptocurrency via [OPEN platform](https://api.openfuture.io/) API.
3+
4+
This widget requires [Metamask wallet](https://metamask.io/).
5+
6+
[![](http://joxi.net/VrwNex4COodeMA.png)]()
7+
8+
### How to use a widget
9+
10+
Paste the code below to a location at your site where you'd like to use this widget and set the width and height parameters.
11+
You also have to put your scaffold address in the src element: 'https://www.openfuture.io/widget/your_scaffold_address'
12+
The best solution is to do it dynamically, especially if you have created a lot of scaffolds.
13+
14+
15+
```html
16+
<iframe id="open-widget-iframe" src="https://www.openfuture.io/widget/your_scaffold_address_here" width="400" height="600" scrolling="no" frameborder="0" allowfullscreen></iframe>
17+
18+
```
19+
20+
21+
The widget can contain a maximum of 9 fields of 3 types (string, number, boolean).
22+
Field names and types are set in a [personal OPEN-platform account](https://api.open-platform.zensoft.io/scaffolds/new) during a smart contract creation.
23+

widget/build.gradle

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
plugins {
2+
id "com.moowork.node" version "1.2.0"
3+
}
4+
5+
apply plugin: 'com.moowork.node'
6+
7+
node {
8+
version = '8.11.2'
9+
distBaseUrl = 'https://nodejs.org/dist'
10+
download = true
11+
}
12+
13+
task assemble(type: NpmTask) {
14+
args = ['run', 'build']
15+
}
16+
17+
assemble.doLast {
18+
println "Merging widget"
19+
20+
def destinationDir = mkdir "$project.buildDir/resources"
21+
22+
// copying index.html
23+
copy {
24+
from project.buildDir
25+
include 'index.html'
26+
rename 'index.html', "widget.ftl"
27+
into "$destinationDir/templates"
28+
}
29+
// copying resources
30+
copy {
31+
from project.buildDir
32+
exclude 'index.html', 'resources'
33+
into "$destinationDir/static"
34+
}
35+
}
36+
37+
assemble.dependsOn npmInstall
38+
npmInstall.dependsOn npmSetup
39+
npmSetup.dependsOn nodeSetup

widget/build/index.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport"
6+
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8+
<title></title>
9+
</head>
10+
<body data-address="${address}">
11+
<script src="/js/open-widget.js"></script>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)