2018-08-10 20:26:51 +02:00
|
|
|
@model PayButtonViewModel
|
|
|
|
@{
|
|
|
|
ViewData["Title"] = "Pay Button";
|
|
|
|
}
|
|
|
|
|
|
|
|
<section>
|
2018-08-14 14:57:46 +02:00
|
|
|
<div class="container" id="payButtonCtrl">
|
2018-08-10 20:26:51 +02:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-lg-12 text-center">
|
|
|
|
<h2 class="section-heading">@ViewData["Title"]</h2>
|
|
|
|
<hr class="primary">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<br />
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-lg-6">
|
|
|
|
<div class="form-row">
|
|
|
|
<div class="form-group col-md-8">
|
|
|
|
<label>Price</label>
|
2018-08-16 21:55:24 +02:00
|
|
|
<input name="price" type="text" class="form-control"
|
|
|
|
v-model="srvModel.price" v-on:change="inputChanges"
|
|
|
|
v-validate="'required|decimal|min_value:0'" :class="{'is-invalid': errors.has('price') }">
|
|
|
|
<small class="text-danger">{{ errors.first('price') }}</small>
|
2018-08-10 20:26:51 +02:00
|
|
|
</div>
|
|
|
|
<div class="form-group col-md-4">
|
|
|
|
<label> </label>
|
2018-08-14 23:47:41 +02:00
|
|
|
<select class="form-control" v-model="srvModel.currency" v-on:change="inputChanges">
|
2018-08-15 23:58:39 +02:00
|
|
|
@foreach (var item in Model.CurrencyDropdown)
|
2018-08-14 23:47:41 +02:00
|
|
|
{
|
|
|
|
<option>@item</option>
|
|
|
|
}
|
|
|
|
</select>
|
2018-08-10 20:26:51 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
|
|
<label>Checkout Description</label>
|
2018-08-17 10:30:49 +02:00
|
|
|
<input name="checkoutDesc" type="text" class="form-control" placeholder="(optional)"
|
2018-08-14 14:57:46 +02:00
|
|
|
v-model="srvModel.checkoutDesc" v-on:change="inputChanges">
|
2018-08-10 20:26:51 +02:00
|
|
|
</div>
|
2018-08-11 13:34:52 +02:00
|
|
|
<div class="form-group">
|
|
|
|
<label>Order Id</label>
|
2018-08-17 10:30:49 +02:00
|
|
|
<input name="orderId" type="text" class="form-control" id="inputAddress" placeholder="(optional)"
|
2018-08-14 14:57:46 +02:00
|
|
|
v-model="srvModel.orderId" v-on:change="inputChanges">
|
2018-08-11 13:34:52 +02:00
|
|
|
</div>
|
2018-08-22 10:52:17 +02:00
|
|
|
<div class="form-group">
|
|
|
|
<label>Pay Button Image Url</label>
|
|
|
|
<input name="payButtonImageUrl" type="text" class="form-control" id="inputAddress"
|
|
|
|
v-model="srvModel.payButtonImageUrl" v-on:change="inputChanges"
|
|
|
|
v-validate="'required|url'" :class="{'is-invalid': errors.has('payButtonImageUrl') }">
|
|
|
|
<small class="text-danger">{{ errors.first('payButtonImageUrl') }}</small>
|
|
|
|
</div>
|
2018-08-10 20:26:51 +02:00
|
|
|
<div class="form-group">
|
|
|
|
<label>Button Size</label>
|
|
|
|
<div style="vertical-align:top; font-size:12px; display:flex;">
|
2018-08-14 19:40:57 +02:00
|
|
|
<button class="btn" style="width:95px;height:40px;margin-right:40px;"
|
|
|
|
v-on:click="inputChanges($event, 0)" v-bind:class="{'btn-primary': (srvModel.buttonSize == 0) }">
|
2018-08-14 18:59:59 +02:00
|
|
|
146 x 40 px
|
|
|
|
</button>
|
|
|
|
<button class="btn btn-default" style="width:126px;height:46px;margin-right:40px;"
|
2018-08-14 19:40:57 +02:00
|
|
|
v-on:click="inputChanges($event, 1)" v-bind:class="{'btn-primary': (srvModel.buttonSize == 1) }">
|
2018-08-14 18:59:59 +02:00
|
|
|
168 x 46 px
|
|
|
|
</button>
|
|
|
|
<button class="btn btn-default" style="width:146px;height:57px;"
|
2018-08-14 19:40:57 +02:00
|
|
|
v-on:click="inputChanges($event, 2)" v-bind:class="{'btn-primary': (srvModel.buttonSize == 2) }">
|
2018-08-14 18:59:59 +02:00
|
|
|
209 x 57 px
|
|
|
|
</button>
|
2018-08-10 20:26:51 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-lg-6">
|
|
|
|
<br />
|
|
|
|
Define parameters that define the purchase: price, currency and then optional description of purchase.
|
|
|
|
<br /><br />
|
|
|
|
Generated HTML will be displayed at the bottom of this page and all you need is to paste that HTML into your final page.
|
|
|
|
Clicking on the button will redirect customer to checkout.
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-08-11 13:34:52 +02:00
|
|
|
<hr />
|
|
|
|
<h3>Payment Notifications</h3>
|
|
|
|
<br />
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-lg-6">
|
|
|
|
<div class="form-group">
|
|
|
|
<label>Server IPN</label>
|
2018-08-16 21:55:24 +02:00
|
|
|
<input name="serverIpn" type="text" class="form-control" placeholder="(optional)"
|
|
|
|
v-model="srvModel.serverIpn" v-on:change="inputChanges"
|
|
|
|
v-validate="'email'" :class="{'is-invalid': errors.has('serverIpn') }">
|
|
|
|
<small class="text-danger">{{ errors.first('serverIpn') }}</small>
|
2018-08-11 13:34:52 +02:00
|
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
|
|
<label>Send Email Notifications to</label>
|
2018-08-17 12:38:03 +02:00
|
|
|
<input name="notifyEmail" type="text" class="form-control" placeholder="(optional)"
|
|
|
|
v-model="srvModel.notifyEmail" v-on:change="inputChanges"
|
|
|
|
v-validate="'email'" :class="{'is-invalid': errors.has('notifyEmail') }">
|
|
|
|
<small class="text-danger">{{ errors.first('notifyEmail') }}</small>
|
2018-08-16 21:55:24 +02:00
|
|
|
|
2018-08-11 13:34:52 +02:00
|
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
|
|
<label>Browser Redirect</label>
|
2018-08-16 21:55:24 +02:00
|
|
|
<input name="browserRedirect" type="text" class="form-control" placeholder="(optional)"
|
|
|
|
v-model="srvModel.browserRedirect" v-on:change="inputChanges"
|
|
|
|
v-validate="'url'" :class="{'is-invalid': errors.has('browserRedirect') }">
|
|
|
|
<small class="text-danger">{{ errors.first('browserRedirect') }}</small>
|
2018-08-11 13:34:52 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-lg-6">
|
|
|
|
<br />
|
|
|
|
These parameters allow you to influence process after purchase. <i>Server IPN</i> is location we'll query with details.
|
|
|
|
We can also deliver email notification to specified addres.
|
|
|
|
<br /><br />
|
|
|
|
Finally <i>Browser Redirect</i> defines where BtcPayServer will redirect customer after puchase is completed.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<hr />
|
|
|
|
<h3>Generated code</h3>
|
2018-08-16 21:55:24 +02:00
|
|
|
<div class="row" v-show="!errors.any()">
|
2018-08-11 13:34:52 +02:00
|
|
|
<div class="col-lg-8">
|
2018-08-14 23:47:28 +02:00
|
|
|
<pre><code id="mainCode" class="html"></code></pre>
|
2018-08-16 22:22:15 +02:00
|
|
|
<button class="btn btn-primary" id="copyCode">
|
|
|
|
<i class="fa fa-copy"></i> Copy Code
|
|
|
|
</button>
|
|
|
|
<span class="copyLabelPopup" style="display:none;">Copied</span>
|
2018-08-11 13:34:52 +02:00
|
|
|
</div>
|
|
|
|
<div class="col-lg-4">
|
2018-08-14 18:59:59 +02:00
|
|
|
<img id="previewButton" src="~/img/paywithbtcpay.png" />
|
2018-08-11 13:34:52 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-08-16 21:55:24 +02:00
|
|
|
<div class="row" v-show="errors.any()">
|
2018-08-17 10:30:49 +02:00
|
|
|
<div class="col-lg-12 text-danger">
|
2018-08-16 21:55:24 +02:00
|
|
|
Please fix errors shown in order for code generation to successfully execute.
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-08-11 13:34:52 +02:00
|
|
|
<br />
|
2018-08-10 20:26:51 +02:00
|
|
|
</div>
|
|
|
|
</section>
|
2018-08-11 13:34:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
@section Scripts {
|
|
|
|
<link rel="stylesheet" href="~/vendor/highlightjs/default.min.css">
|
|
|
|
<script src="~/vendor/highlightjs/highlight.min.js"></script>
|
2018-08-14 14:57:46 +02:00
|
|
|
|
|
|
|
<script src="~/vendor/vuejs/vue.js"></script>
|
2018-08-15 23:58:39 +02:00
|
|
|
<!-- jsdelivr cdn -->
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/vee-validate@latest/dist/vee-validate.js"></script>
|
|
|
|
|
2018-08-16 22:22:15 +02:00
|
|
|
<script src="~/vendor/clipboard.js/clipboard.js"></script>
|
|
|
|
|
2018-08-14 14:57:46 +02:00
|
|
|
<script type="text/javascript">
|
|
|
|
var srvModel = @Html.Raw(Json.Serialize(Model));
|
2018-08-15 23:58:39 +02:00
|
|
|
Vue.use(VeeValidate);
|
2018-08-17 10:30:49 +02:00
|
|
|
const dictionary = {
|
|
|
|
en: {
|
|
|
|
attributes: {
|
|
|
|
price: 'Price', checkoutDesc: 'Checkout Description', orderId: 'Order Id',
|
2018-08-22 10:52:17 +02:00
|
|
|
serverIpn: 'Server IPN', notifyEmail: 'Send Email Notifications', browserRedirect: 'Browser Redirect',
|
|
|
|
payButtonImageUrl: "Pay Button Image Url"
|
2018-08-17 10:30:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
VeeValidate.Validator.localize(dictionary);
|
2018-08-14 14:57:46 +02:00
|
|
|
var payButtonCtrl = new Vue({
|
|
|
|
el: '#payButtonCtrl',
|
|
|
|
data: {
|
|
|
|
srvModel: srvModel
|
|
|
|
},
|
|
|
|
methods: {
|
2018-08-14 18:59:59 +02:00
|
|
|
inputChanges: function (event, buttonSize) {
|
2018-08-14 23:47:28 +02:00
|
|
|
inputChanges(event, buttonSize);
|
|
|
|
}
|
2018-08-14 19:40:57 +02:00
|
|
|
}
|
2018-08-15 23:58:39 +02:00
|
|
|
});
|
2018-08-14 19:40:57 +02:00
|
|
|
|
|
|
|
function inputChanges(event, buttonSize) {
|
|
|
|
if (buttonSize != null) {
|
|
|
|
srvModel.buttonSize = buttonSize;
|
|
|
|
}
|
|
|
|
|
2018-08-17 12:38:03 +02:00
|
|
|
var html = '<form method="POST" action="' + srvModel.urlRoot + '/apps/3jVExUHqRkGi4eaJEFCTxw5zjk14VAFzoVZXZJ3fbwED/pay">';
|
|
|
|
html += addinput("price", srvModel.price);
|
2018-08-14 19:40:57 +02:00
|
|
|
if (srvModel.currency) {
|
|
|
|
html += addinput("currency", srvModel.currency);
|
|
|
|
}
|
|
|
|
if (srvModel.checkoutDesc) {
|
|
|
|
html += addinput("checkoutDesc", srvModel.checkoutDesc);
|
|
|
|
}
|
|
|
|
if (srvModel.orderId) {
|
|
|
|
html += addinput("orderId", srvModel.orderId);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (srvModel.serverIpn) {
|
|
|
|
html += addinput("serverIpn", srvModel.serverIpn);
|
|
|
|
}
|
|
|
|
if (srvModel.browserRedirect) {
|
|
|
|
html += addinput("browserRedirect", srvModel.browserRedirect);
|
|
|
|
}
|
2018-08-17 12:38:03 +02:00
|
|
|
if (srvModel.notifyEmail) {
|
|
|
|
html += addinput("notifyEmail", srvModel.notifyEmail);
|
2018-08-14 19:40:57 +02:00
|
|
|
}
|
2018-08-14 18:59:59 +02:00
|
|
|
|
2018-08-14 19:40:57 +02:00
|
|
|
var width = "209px";
|
|
|
|
if (srvModel.buttonSize == 0) {
|
|
|
|
width = "146px";
|
|
|
|
} else if (srvModel.buttonSize == 1) {
|
|
|
|
width = "168px";
|
|
|
|
} else if (srvModel.buttonSize == 2) {
|
|
|
|
width = "209px";
|
|
|
|
}
|
2018-08-22 10:52:17 +02:00
|
|
|
html += '\n <input type="image" src="' + srvModel.payButtonImageUrl + '" name="submit" style="width:' + width +
|
2018-08-16 22:22:15 +02:00
|
|
|
'" alt="Pay with BtcPay, Self-Hosted Bitcoin Payment Processor">';
|
2018-08-14 14:57:46 +02:00
|
|
|
|
2018-08-14 19:40:57 +02:00
|
|
|
html += '\n</form>';
|
2018-08-14 18:59:59 +02:00
|
|
|
|
2018-08-14 19:40:57 +02:00
|
|
|
$("#mainCode").html(html);
|
2018-08-14 18:59:59 +02:00
|
|
|
|
2018-08-14 19:40:57 +02:00
|
|
|
$('pre code').each(function (i, block) {
|
|
|
|
hljs.highlightBlock(block);
|
|
|
|
});
|
2018-08-16 22:22:15 +02:00
|
|
|
|
2018-08-22 10:52:17 +02:00
|
|
|
$("#previewButton").css("width", width);
|
|
|
|
$("#previewButton").attr("src", srvModel.payButtonImageUrl);
|
|
|
|
|
2018-08-16 22:22:15 +02:00
|
|
|
return html;
|
2018-08-14 19:40:57 +02:00
|
|
|
}
|
2018-08-14 14:57:46 +02:00
|
|
|
|
2018-08-14 23:47:28 +02:00
|
|
|
function addinput(name, value) {
|
|
|
|
var html = '\n <input type="hidden" name="' + name + '" value="' + value + '" />';
|
2018-08-14 19:40:57 +02:00
|
|
|
return html;
|
|
|
|
}
|
2018-08-14 23:47:28 +02:00
|
|
|
|
|
|
|
$(function () {
|
|
|
|
inputChanges();
|
|
|
|
});
|
2018-08-16 22:22:15 +02:00
|
|
|
|
|
|
|
String.prototype.replaceAll = function (search, replacement) {
|
|
|
|
var target = this;
|
|
|
|
return target.replace(new RegExp(search, 'g'), replacement);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Clipboard Copy
|
|
|
|
new Clipboard('#copyCode', {
|
|
|
|
text: function (trigger) {
|
|
|
|
$(".copyLabelPopup").show().delay(1000).fadeOut(500);
|
|
|
|
return inputChanges().replaceAll("<", "<").replaceAll(">", ">");
|
|
|
|
}
|
|
|
|
});
|
2018-08-14 14:57:46 +02:00
|
|
|
</script>
|
2018-08-11 13:34:52 +02:00
|
|
|
}
|