[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taldir] branch master updated: add access token and baseurl confi
From: |
gnunet |
Subject: |
[taler-taldir] branch master updated: add access token and baseurl configuration for merchant API |
Date: |
Tue, 12 Jul 2022 14:06:47 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository taldir.
The following commit(s) were added to refs/heads/master by this push:
new 877761d add access token and baseurl configuration for merchant API
877761d is described below
commit 877761d2ef55888e062e08036a3b4ffd9460de92
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Tue Jul 12 14:06:44 2022 +0200
add access token and baseurl configuration for merchant API
---
cmd/taldir-server/testdata/taldir-test.conf | 12 +++++++++++-
config/taldir-example.conf | 3 +++
pkg/rest/taldir.go | 4 +++-
pkg/taler/merchant.go | 17 +++++++++--------
4 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/cmd/taldir-server/testdata/taldir-test.conf
b/cmd/taldir-server/testdata/taldir-test.conf
index 4cbfe6e..4a87cba 100644
--- a/cmd/taldir-server/testdata/taldir-test.conf
+++ b/cmd/taldir-server/testdata/taldir-test.conf
@@ -5,8 +5,18 @@ host = "https://taldir.net";
bind_to = "localhost:11000"
salt = "ChangeMe"
monthly_fee = KUDOS:0
-request_frequency_microseconds = 10
validation_landing = testdata/templates/validation_landing.html
+default_doc_filetype = text/markdown
+default_doc_lang = en-US
+default_tos_path = terms/
+default_pp_path = privacy/
+challenge_bytes = 16
+validation_initiation_max = 3
+solution_attempt_max = 3
+validation_timeframe = 10m
+solution_attempt_timeframe = 1h
+merchant_baseurl_private = http://merchant.taldir/instances/myInstance
+merchant_token = superSecretToken
[taldir-test]
challenge_fee = KUDOS:0
diff --git a/config/taldir-example.conf b/config/taldir-example.conf
index bb8c874..ed7c0db 100644
--- a/config/taldir-example.conf
+++ b/config/taldir-example.conf
@@ -14,6 +14,9 @@ validation_initiation_max = 3
solution_attempt_max = 3
validation_timeframe = 10m
solution_attempt_timeframe = 1h
+merchant_baseurl_private = http://merchant.taldir/instances/myInstance
+merchant_token = superSecretToken
+validation_landing = testdata/templates/validation_landing.html
[taldir-email]
sender = "taldir@taler.net"
diff --git a/pkg/rest/taldir.go b/pkg/rest/taldir.go
index 99dec0a..74187fa 100644
--- a/pkg/rest/taldir.go
+++ b/pkg/rest/taldir.go
@@ -838,7 +838,9 @@ func (t *Taldir) Initialize(cfgfile string) {
if "" == t.Salt {
t.Salt = t.Cfg.Section("taldir").Key("salt").MustString("ChangeMe")
}
- t.Merchant = taler.NewMerchant("http://merchant.taldir";, "myInstance")
+ merchUrl :=
t.Cfg.Section("taldir").Key("merchant_baseurl_private").MustString("http://merchant.taldir/instances/myInstance";)
+ merchToken :=
t.Cfg.Section("taldir").Key("merchant_token").MustString("secretAccessToken")
+ t.Merchant = taler.NewMerchant(merchUrl, merchToken)
t.setupHandlers()
}
diff --git a/pkg/taler/merchant.go b/pkg/taler/merchant.go
index 44d28a5..989306d 100644
--- a/pkg/taler/merchant.go
+++ b/pkg/taler/merchant.go
@@ -95,23 +95,24 @@ type CheckPaymentPaytoResponse struct {
type Merchant struct {
// The host of this merchant
- Host string;
+ BaseUrlPrivate string
+
+ // The access token to use for the private API
+ AccessToken string
- // The instance of this merchant
- Instance string;
}
-func NewMerchant(merchHost string, merchInstance string) Merchant {
+func NewMerchant(merchBaseUrlPrivate string, merchAccessToken string) Merchant
{
return Merchant{
- Host: merchHost,
- Instance: merchInstance,
+ BaseUrlPrivate: merchBaseUrlPrivate,
+ AccessToken: merchAccessToken,
}
}
func (m *Merchant) IsOrderPaid(orderId string) (string, error) {
var orderPaidResponse CheckPaymentStatusResponse
var paytoResponse CheckPaymentPaytoResponse
- resp, err := http.Get(m.Host + "/instances/"+ m.Instance +
"/private/orders/" + orderId)
+ resp, err := http.Get(m.BaseUrlPrivate + "/private/orders/" + orderId)
if nil != err {
return "", err
}
@@ -144,7 +145,7 @@ func (m *Merchant) AddNewOrder(cost float64, currency
string) (string, error) {
orderDetail.Summary = "This is an order to a TalDir registration"
newOrder.order = orderDetail
reqString, _ := json.Marshal(newOrder)
- resp, err := http.Post(m.Host + "/instances/"+ m.Instance +
"/private/orders", "application/json", bytes.NewBuffer(reqString))
+ resp, err := http.Post(m.BaseUrlPrivate + "/private/orders",
"application/json", bytes.NewBuffer(reqString))
if nil != err {
return "", err
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-taldir] branch master updated: add access token and baseurl configuration for merchant API,
gnunet <=