Fix connection to checkout backend (bad links)

This commit is contained in:
nicolas.dorier
2019-01-28 16:24:11 +09:00
parent 47f8938b89
commit 02d227ee02
4 changed files with 20 additions and 13 deletions

View File

@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
<Version>1.0.3.47</Version> <Version>1.0.3.48</Version>
<NoWarn>NU1701,CA1816,CA1308,CA1810,CA2208</NoWarn> <NoWarn>NU1701,CA1816,CA1308,CA1810,CA2208</NoWarn>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>

View File

@@ -279,7 +279,6 @@ namespace BTCPayServer.Controllers
PaymentMethodName = GetDisplayName(paymentMethodId, network), PaymentMethodName = GetDisplayName(paymentMethodId, network),
CryptoImage = GetImage(paymentMethodId, network), CryptoImage = GetImage(paymentMethodId, network),
IsLightning = paymentMethodId.PaymentType == PaymentTypes.LightningLike, IsLightning = paymentMethodId.PaymentType == PaymentTypes.LightningLike,
ServerUrl = HttpContext.Request.GetAbsoluteRoot(),
OrderId = invoice.OrderId, OrderId = invoice.OrderId,
InvoiceId = invoice.Id, InvoiceId = invoice.Id,
DefaultLang = storeBlob.DefaultLang ?? "en", DefaultLang = storeBlob.DefaultLang ?? "en",
@@ -370,6 +369,9 @@ namespace BTCPayServer.Controllers
[HttpGet] [HttpGet]
[Route("i/{invoiceId}/status")] [Route("i/{invoiceId}/status")]
[Route("i/{invoiceId}/{paymentMethodId}/status")] [Route("i/{invoiceId}/{paymentMethodId}/status")]
[Route("invoice/{invoiceId}/status")]
[Route("invoice/{invoiceId}/{paymentMethodId}/status")]
[Route("invoice/status")]
public async Task<IActionResult> GetStatus(string invoiceId, string paymentMethodId = null) public async Task<IActionResult> GetStatus(string invoiceId, string paymentMethodId = null)
{ {
var model = await GetInvoiceModel(invoiceId, paymentMethodId); var model = await GetInvoiceModel(invoiceId, paymentMethodId);
@@ -380,6 +382,10 @@ namespace BTCPayServer.Controllers
[HttpGet] [HttpGet]
[Route("i/{invoiceId}/status/ws")] [Route("i/{invoiceId}/status/ws")]
[Route("i/{invoiceId}/{paymentMethodId}/status/ws")]
[Route("invoice/{invoiceId}/status/ws")]
[Route("invoice/{invoiceId}/{paymentMethodId}/status")]
[Route("invoice/status/ws")]
public async Task<IActionResult> GetStatusWebSocket(string invoiceId) public async Task<IActionResult> GetStatusWebSocket(string invoiceId)
{ {
if (!HttpContext.WebSockets.IsWebSocketRequest) if (!HttpContext.WebSockets.IsWebSocketRequest)
@@ -425,6 +431,7 @@ namespace BTCPayServer.Controllers
[HttpPost] [HttpPost]
[Route("i/{invoiceId}/UpdateCustomer")] [Route("i/{invoiceId}/UpdateCustomer")]
[Route("invoice/UpdateCustomer")]
public async Task<IActionResult> UpdateCustomer(string invoiceId, [FromBody]UpdateCustomerModel data) public async Task<IActionResult> UpdateCustomer(string invoiceId, [FromBody]UpdateCustomerModel data)
{ {
if (!ModelState.IsValid) if (!ModelState.IsValid)

View File

@@ -24,7 +24,6 @@ namespace BTCPayServer.Models.InvoicingModels
public bool IsModal { get; set; } public bool IsModal { get; set; }
public bool IsLightning { get; set; } public bool IsLightning { get; set; }
public string CryptoCode { get; set; } public string CryptoCode { get; set; }
public string ServerUrl { get; set; }
public string InvoiceId { get; set; } public string InvoiceId { get; set; }
public string BtcAddress { get; set; } public string BtcAddress { get; set; }
public string BtcDue { get; set; } public string BtcDue { get; set; }

View File

@@ -95,9 +95,8 @@ function onDataCallback(jsonData) {
} }
function fetchStatus() { function fetchStatus() {
var path = srvModel.serverUrl + "/i/" + srvModel.invoiceId + "/" + srvModel.paymentMethodId + "/status";
$.ajax({ $.ajax({
url: path, url: window.location.pathname + "/status?invoiceId=" + srvModel.invoiceId,
type: "GET", type: "GET",
cache: false cache: false
}).done(function (data) { }).done(function (data) {
@@ -164,11 +163,8 @@ $(document).ready(function () {
$("#emailAddressForm .input-wrapper bp-loading-button .action-button").addClass("loading"); $("#emailAddressForm .input-wrapper bp-loading-button .action-button").addClass("loading");
// Push the email to a server, once the reception is confirmed move on // Push the email to a server, once the reception is confirmed move on
srvModel.customerEmail = emailAddress; srvModel.customerEmail = emailAddress;
var path = srvModel.serverUrl + "/i/" + srvModel.invoiceId + "/UpdateCustomer";
$.ajax({ $.ajax({
url: path, url: window.location.pathname + "/UpdateCustomer?invoiceId=" + srvModel.invoiceId,
type: "POST", type: "POST",
data: JSON.stringify({ Email: srvModel.customerEmail }), data: JSON.stringify({ Email: srvModel.customerEmail }),
contentType: "application/json; charset=utf-8" contentType: "application/json; charset=utf-8"
@@ -240,11 +236,16 @@ $(document).ready(function () {
var supportsWebSockets = 'WebSocket' in window && window.WebSocket.CLOSING === 2; var supportsWebSockets = 'WebSocket' in window && window.WebSocket.CLOSING === 2;
if (supportsWebSockets) { if (supportsWebSockets) {
var path = srvModel.serverUrl + "/i/" + srvModel.invoiceId + "/status/ws"; var loc = window.location, ws_uri;
path = path.replace("https://", "wss://"); if (loc.protocol === "https:") {
path = path.replace("http://", "ws://"); ws_uri = "wss:";
} else {
ws_uri = "ws:";
}
ws_uri += "//" + loc.host;
ws_uri += loc.pathname + "/status/ws?invoiceId=" + srvModel.invoiceId;
try { try {
var socket = new WebSocket(path); var socket = new WebSocket(ws_uri);
socket.onmessage = function (e) { socket.onmessage = function (e) {
fetchStatus(); fetchStatus();
}; };