Мы находим некоторые ошибки в вызове res. json () после ответа на выборку, после создания заказа на Back End, что успешно .
Я прилагаю некоторый код обратите внимание, что это быстрая попытка просто заставить работать l oop.
paypalClient - скрипт на literalControl
Ошибки на консоли после ответа по серверу с разрешением json ()
Это код, который отображает кнопку PayPal и выдает ошибки.
paypal.Buttons({
enableStandardCardFields: 'true',
style: {
layout: 'vertical'
},
createOrder: function(data, actions) {
return fetch('/PayPal/Notify', {
method: 'post',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify({amount:'39.65',
item_name:'17349-051350-11032020',
currency_code:'EUR',
clientID:'d4569977-9f4a-498e-9bc8-8032b6c8374d',
full_name:'Giorgio',
surname:'Rossi',
email:'giorgiorossi100@gmail.com',
city:'Adria',
state:'RO',
postal_code:'45011',
phone:'3411113108',
address_line_1:'Via Corona 10',
address_line_2:'Scala 2',
admin_area_1:'Adria',
admin_area_2:'Adria',
country_code:'IT'
})
}).then(function(res) {
return res.json();
console.log(res);
}).then(function(data) {
return data.orderID;
});
}
}).render('#btnPaypal_17349-051350-11032020');
paypalServer - Создать заказ как задачу (из PayPaylHttp.HttpResponse)
Public Shared Async Function CreateOrder(dicNameValue As Dictionary(Of String, String), ByVal Optional debug As Boolean = False) As Task(Of PayPalHttp.HttpResponse)
Dim result As New Order
Dim request = New OrdersCreateRequest()
request.Prefer("return=representation")
Dim newRequest As New OrderActionRequest
request.RequestBody(BuildRequestBody(dicNameValue))
Dim response = Await PayPalClient.client().Execute(request)
If debug Then
result = response.Result(Of Order)()
Console.WriteLine("Status: {0}", result.Status)
Console.WriteLine("Order Id: {0}", result.Id)
Console.WriteLine("Links:")
For Each link As LinkDescription In result.Links
Console.WriteLine(vbTab & "{0}: {1}" & vbTab & "Call Type: {2}", link.Rel, link.Href, link.Method)
Next
Dim amount As AmountWithBreakdown = result.PurchaseUnits(0).AmountWithBreakdown
Console.WriteLine("Total Amount: {0} {1}", amount.CurrencyCode, amount.Value)
End If
Return response
End Function
клиент-серверная связь
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Context.Response.ContentType = "application/json"
Context.Request.ContentType = "application/json"
Dim requestStream As IO.Stream = Context.Request.InputStream
Dim requestarray(requestStream.Length) As Byte
requestStream.Read(requestarray, 0, requestStream.Length)
Dim strRequest As String = System.Text.Encoding.Default.GetString(requestarray)
CreaDicKeyName(keyValue, strRequest)
Page.ExecuteRegisteredAsyncTasks()
End Sub
Private Async Function CreaOrdine() As Task(Of PayPalHttp.HttpResponse)
Dim order = Await _server.CreateOrder(Me.keyValue, True)
_order = order
Return order
End Function