commit 7bceac1ec3b812e5618db4bc8cf63e460a4d037c
parent 3f6b3d63faf4c3b96c33a1bedae4ff6c984575d2
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date: Wed, 4 Sep 2024 17:14:20 +0200
handle claimed order
Diffstat:
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/pkg/rest/gnsregistrar.go b/pkg/rest/gnsregistrar.go
@@ -616,20 +616,24 @@ func (t *Registrar) paymentPage(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/name/" + sanitizedLabel + "?error=Payment already paid.", http.StatusSeeOther)
return
}
- _, _, payto, paytoErr := t.Merchant.IsOrderPaid(regMetadata.OrderID)
+ _, orderStatus, payto, paytoErr := t.Merchant.IsOrderPaid(regMetadata.OrderID)
if paytoErr != nil {
http.Redirect(w, r, "/name/" + sanitizedLabel + "?error=Payment failed: Error getting payment data", http.StatusSeeOther)
return
}
- qrPng, qrErr := qrcode.Encode(payto, qrcode.Medium, 256)
- if qrErr != nil {
- http.Redirect(w, r, "/name/" + sanitizedLabel + "?error=Registration failed: Error generating QR code", http.StatusSeeOther)
- return
+ encodedPng := ""
+ if (payto != "") {
+ qrPng, qrErr := qrcode.Encode(payto, qrcode.Medium, 256)
+ if qrErr != nil {
+ http.Redirect(w, r, "/name/" + sanitizedLabel + "?error=Registration failed: Error generating QR code", http.StatusSeeOther)
+ return
+ }
+ encodedPng = base64.StdEncoding.EncodeToString(qrPng)
}
- encodedPng := base64.StdEncoding.EncodeToString(qrPng)
cost, _ := t.RegistrationCost.FormatWithCurrencySpecification(t.CurrencySpec)
w.Header().Set("Refresh", "20;url=" + t.BaseUrl + "/name/" + sanitizedLabel + "/edit?token=" + regMetadata.RegistrationID)
fullData := map[string]interface{}{
+ "orderUnpaid": merchant.OrderUnpaid == orderStatus,
"qrCode": template.URL("data:image/png;base64," + encodedPng),
"payto": template.URL(payto),
"fulfillmentUrl": template.URL(t.BaseUrl + "/name/" + sanitizedLabel + "/edit?token=" + regMetadata.RegistrationID),
diff --git a/web/templates/buy.html b/web/templates/buy.html
@@ -13,8 +13,10 @@
<h1 class="mb-3">To complete the registration of <i class="text-primary">{{.label}}</i>:</h1>
<a class="link-dark" href="{{.payto}}" class="btn btn-success mb-3">Pay {{.cost}} with your Taler wallet</a><br/>
+ {{if .orderUnpaid}}
Alternatively, you can pay using your mobile wallet by scanning the QR code below:<br/>
- <img class="qr" src="{{.qrCode}}"/>
+ <img class="qr" src="{{.qrCode}}"/>
+ {{end}}
<br/>
</div>
<div class="alert alert-warning">