PayPal: создание и получение заказа - PullRequest
0 голосов
/ 14 октября 2019

Я следую этому примеру (https://developer.paypal.com/docs/checkout/reference/server-integration/set-up-transaction/#on-the-server), чтобы заставить PayPal работать на сервере.

Я завершил создание заказа, но он не захватывает заказ одновременно. Возможно ли создать и захватить заказ одновременно?

var request = new OrdersCreateRequest();
request.Prefer("return=representation");
request.RequestBody(BuildRequestBody());

var response = await PayPalClient.client().Execute(request);  //this will only create the order. How to capture it at the same time?

Когда я попытался захватить заказ:

//continue from above
var result = response.Result<Order>();

var requestCapture = new OrdersCaptureRequest(result.Id);
requestCapture.Prefer("return=representation");
requestCapture.RequestBody(new OrderActionRequest());

response = await PayPalClient.Client().Execute(requestCapture);

Я получаю сообщение об ошибке:

"name":"UNPROCESSABLE_ENTITY",
"details":  [{
                "issue":"ORDER_NOT_APPROVED",
                "description":"Payer has not yet approved the Order for payment. Please redirect the payer to the 'rel':'approve' url returned as part of the HATEOAS links within the Create Order call or provide a valid payment_source in the request."
            }],
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"links":    [{
                "href": "https://developer.paypal.com/docs/api/orders/v2/#error-ORDER_NOT_APPROVED",
                "rel": "information_link",
                "method": "GET"
            }]

У меня вопрос: возможно ли создать заказ, авторизоваться и захватить в то же время ? 1018 *

Спасибо

...