mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-23 14:40:36 +01:00
Merge pull request #891 from Kukks/pay-button-language
Allow language parameter in pay button endpoint
This commit is contained in:
commit
9e354d7703
4 changed files with 36 additions and 3 deletions
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Web;
|
||||||
using BTCPayServer.Filters;
|
using BTCPayServer.Filters;
|
||||||
using BTCPayServer.Models;
|
using BTCPayServer.Models;
|
||||||
using BTCPayServer.Models.StoreViewModels;
|
using BTCPayServer.Models.StoreViewModels;
|
||||||
|
@ -58,7 +59,17 @@ namespace BTCPayServer.Controllers
|
||||||
RedirectURL = model.BrowserRedirect,
|
RedirectURL = model.BrowserRedirect,
|
||||||
FullNotifications = true
|
FullNotifications = true
|
||||||
}, store, HttpContext.Request.GetAbsoluteRoot(), cancellationToken: cancellationToken);
|
}, store, HttpContext.Request.GetAbsoluteRoot(), cancellationToken: cancellationToken);
|
||||||
|
if (string.IsNullOrEmpty(model.CheckoutQueryString))
|
||||||
|
{
|
||||||
return Redirect(invoice.Data.Url);
|
return Redirect(invoice.Data.Url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var additionalParamValues = HttpUtility.ParseQueryString(model.CheckoutQueryString);
|
||||||
|
var uriBuilder = new UriBuilder(invoice.Data.Url);
|
||||||
|
var paramValues = HttpUtility.ParseQueryString(uriBuilder.Query);
|
||||||
|
paramValues.Add(additionalParamValues);
|
||||||
|
uriBuilder.Query = paramValues.ToString();
|
||||||
|
return Redirect(uriBuilder.Uri.AbsoluteUri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ namespace BTCPayServer.Models.StoreViewModels
|
||||||
public string NotifyEmail { get; set; }
|
public string NotifyEmail { get; set; }
|
||||||
|
|
||||||
public string StoreId { get; set; }
|
public string StoreId { get; set; }
|
||||||
|
public string CheckoutQueryString { get; set; }
|
||||||
|
|
||||||
// Data that influences Pay Button UI, but not invoice creation
|
// Data that influences Pay Button UI, but not invoice creation
|
||||||
public string UrlRoot { get; set; }
|
public string UrlRoot { get; set; }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@model PayButtonViewModel
|
@model PayButtonViewModel
|
||||||
@{
|
@{
|
||||||
Layout = "../Shared/_NavLayout.cshtml";
|
Layout = "../Shared/_NavLayout.cshtml";
|
||||||
ViewData.SetActivePageAndTitle(StoreNavPages.PayButton);
|
ViewData.SetActivePageAndTitle(StoreNavPages.PayButton);
|
||||||
|
@ -140,6 +140,24 @@
|
||||||
Finally <i>Browser Redirect</i> defines where BtcPayServer will redirect customer after puchase is completed.
|
Finally <i>Browser Redirect</i> defines where BtcPayServer will redirect customer after puchase is completed.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<h3>Advanced</h3>
|
||||||
|
<br />
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-7">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Checkout Additional Query String</label>
|
||||||
|
<input name="checkoutQueryString" type="text" class="form-control" placeholder="(optional)"
|
||||||
|
v-model="srvModel.checkoutQueryString" v-on:change="inputChanges"
|
||||||
|
:class="{'is-invalid': errors.has('checkoutQueryString') }">
|
||||||
|
<small class="text-danger">{{ errors.first('checkoutQueryString') }}</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-5">
|
||||||
|
<br />
|
||||||
|
This parameter allows you to specify additional query string paramters that should be appended to the checkout page once the invoice is created. For example, <kbd>lang=da-DK</kbd> would load the checkout page in Danishby default.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
<h3>Generated code</h3>
|
<h3>Generated code</h3>
|
||||||
<div class="row" v-show="!errors.any()">
|
<div class="row" v-show="!errors.any()">
|
||||||
|
|
|
@ -26,7 +26,7 @@ function esc(input) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Vue.use(VeeValidate);
|
Vue.use(VeeValidate);
|
||||||
const dictionary = {
|
var dictionary = {
|
||||||
en: {
|
en: {
|
||||||
attributes: {
|
attributes: {
|
||||||
price: 'Price', checkoutDesc: 'Checkout Description', orderId: 'Order Id',
|
price: 'Price', checkoutDesc: 'Checkout Description', orderId: 'Order Id',
|
||||||
|
@ -97,6 +97,9 @@ function inputChanges(event, buttonSize) {
|
||||||
if (srvModel.notifyEmail) {
|
if (srvModel.notifyEmail) {
|
||||||
html += addinput("notifyEmail", srvModel.notifyEmail);
|
html += addinput("notifyEmail", srvModel.notifyEmail);
|
||||||
}
|
}
|
||||||
|
if (srvModel.checkoutQueryString) {
|
||||||
|
html += addinput("checkoutQueryString", srvModel.checkoutQueryString);
|
||||||
|
}
|
||||||
|
|
||||||
html += '\n <input type="image" src="' + esc(srvModel.payButtonImageUrl) + '" name="submit" style="width:' + width +
|
html += '\n <input type="image" src="' + esc(srvModel.payButtonImageUrl) + '" name="submit" style="width:' + width +
|
||||||
'" alt="Pay with BtcPay, Self-Hosted Bitcoin Payment Processor">';
|
'" alt="Pay with BtcPay, Self-Hosted Bitcoin Payment Processor">';
|
||||||
|
|
Loading…
Add table
Reference in a new issue