无效的资源ID paypal订阅更新计划



我有这个问题。(我尝试从一个计划更新sanbox的订阅到另一个计划)-相同的产品,数量不同。

调用rest api POST:

https://api-m.sandbox.paypal.com/v1/billing/subscriptions/(SubscptionId)/修改

  • 我已经插入正确的ACCESS TOKEN和正确的PLAN ID (Active)。

在visual studio上调试它的工作和paypal响应200.

当我尝试在Azure web api上使用时(在logger上,我在json上有此错误)

issues="INVALID_RESOURCE_ID"
description =" Requested resource ID was not found."

但是在请求字段中不需要资源id。

有人知道我该怎么解决吗?提前感谢。

请求:

订阅激活WEBHOOK响应

响应webhook paypal

{
"id": "WH-05X15924JM439863B-0A754578Y3494494Y",
"create_time": "2022-06-17T09:57:07.299Z",
"resource_type": "subscription",
"event_type": "BILLING.SUBSCRIPTION.ACTIVATED",
"summary": "Subscription activated",
"resource": {
"quantity": "1",
"subscriber": {
"email_address": sb-m4dxd17050716@personal.example.com,
"payer_id": "HNJDGM4CVQWDQ",
"name": {
"given_name": "John",
"surname": "Doe"
},
"shipping_address": {
"address": {
"address_line_1": "Via Unit? d'Italia",
"admin_area_2": "Napoli",
"admin_area_1": "Napoli",
"postal_code": "80127",
"country_code": "IT"
}
}
},
"create_time": "2022-06-17T09:56:58Z",
"plan_overridden": false,
"shipping_amount": {
"currency_code": "EUR",
"value": "0.0"
},
"start_time": "2022-06-17T09:56:40Z",
"update_time": "2022-06-17T09:56:59Z",
"billing_info": {
"outstanding_balance": {
"currency_code": "EUR",
"value": "0.0"
},
"cycle_executions": [
{
"tenure_type": "REGULAR",
"sequence": 1,
"cycles_completed": 1,
"cycles_remaining": 0,
"current_pricing_scheme_version": 1,
"total_cycles": 0
}
],
"last_payment": {
"amount": {
"currency_code": "EUR",
"value": "50.0"
},
"time": "2022-06-17T09:56:58Z"
},
"next_billing_time": "2022-06-19T10:00:00Z",
"failed_payments_count": 0
},
"links": [
{
"href": https://api.sandbox.paypal.com/v1/billing/subscriptions/I-3J5HHBY1JHMC/cancel,
"rel": "cancel",
"method": "POST",
"encType": "application/json"
},
{
"href": https://api.sandbox.paypal.com/v1/billing/subscriptions/I-3J5HHBY1JHMC,
"rel": "edit",
"method": "PATCH",
"encType": "application/json"
},
{
"href": https://api.sandbox.paypal.com/v1/billing/subscriptions/I-3J5HHBY1JHMC,
"rel": "self",
"method": "GET",
"encType": "application/json"
},
{
"href": https://api.sandbox.paypal.com/v1/billing/subscriptions/I-3J5HHBY1JHMC/suspend,
"rel": "suspend",
"method": "POST",
"encType": "application/json"
},
{
"href": https://api.sandbox.paypal.com/v1/billing/subscriptions/I-3J5HHBY1JHMC/capture,
"rel": "capture",
"method": "POST",
"encType": "application/json"
}
],
"id": "I-3J5HHBY1JHMC",
"plan_id": "P-8SG32020HB3302043MKVTYZY",
"status": "ACTIVE",
"status_update_time": "2022-06-17T09:56:59Z"
},
"status": "SUCCESS",
"transmissions": [
{
"webhook_url": https://regolari.azurewebsites.net/RegolariCaller,
"http_status": 200,
"reason_phrase": "HTTP/1.1 200 Connection established",
"response_headers": {
"Transfer-Encoding": "chunked",
"Server": "Microsoft-IIS/10.0",
"Connection": "keep-alive",
"Set-Cookie": "ARRAffinitySameSite=2989c34f7c0cdb7ec5c37c2d6a0cd07c20c702dc389fc83ca79bfb532ef0320f;Path=/;HttpOnly;SameSite=None;Secure;Domain=regolari.azurewebsites.net",
"Date": "Fri, 17 Jun 2022 09:57:44 GMT",
"Content-Type": "application/json; charset=utf-8",
"X-Powered-By": "ASP.NET"
},
"transmission_id": "e87042a0-ee23-11ec-8079-f5b1270d17b4",
"status": "SUCCESS",
"timestamp": "2022-06-17T09:57:33Z"
}
],
"links": [
{
"href": https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-05X15924JM439863B-0A754578Y3494494Y,
"rel": "self",
"method": "GET",
"encType": "application/json"
},
{
"href": https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-05X15924JM439863B-0A754578Y3494494Y/resend,
"rel": "resend",
"method": "POST",
"encType": "application/json"
}
],
"event_version": "1.0",
"resource_version": "2.0"
}

付款已完成


{
"id": "WH-3YN53862H3003372E-77V7032476059723Y",
"create_time": "2022-06-17T09:57:17.044Z",
"resource_type": "sale",
"event_type": "PAYMENT.SALE.COMPLETED",
"summary": "Payment completed for EUR 50.0 EUR",
"resource": {
"billing_agreement_id": "I-3J5HHBY1JHMC",
"amount": {
"total": "50.00",
"currency": "EUR",
"details": {
"subtotal": "50.00"
}
},
"payment_mode": "INSTANT_TRANSFER",
"update_time": "2022-06-17T09:56:58Z",
"create_time": "2022-06-17T09:56:58Z",
"protection_eligibility_type": "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE",
"transaction_fee": {
"currency": "EUR",
"value": "2.05"
},
"protection_eligibility": "ELIGIBLE",
"links": [
{
"method": "GET",
"rel": "self",
"href": https://api.sandbox.paypal.com/v1/payments/sale/5C135321A6617514V
},
{
"method": "POST",
"rel": "refund",
"href": https://api.sandbox.paypal.com/v1/payments/sale/5C135321A6617514V/refund
}
],
"id": "5C135321A6617514V",
"state": "completed",
"invoice_number": ""
},
"status": "SUCCESS",
"transmissions": [
{
"webhook_url": https://regolari.azurewebsites.net/RegolariCaller,
"http_status": 200,
"reason_phrase": "HTTP/1.1 200 Connection established",
"response_headers": {
"Transfer-Encoding": "chunked",
"Server": "Microsoft-IIS/10.0",
"Connection": "keep-alive",
"Set-Cookie": "ARRAffinitySameSite=2989c34f7c0cdb7ec5c37c2d6a0cd07c20c702dc389fc83ca79bfb532ef0320f;Path=/;HttpOnly;SameSite=None;Secure;Domain=regolari.azurewebsites.net",
"Date": "Fri, 17 Jun 2022 09:57:41 GMT",
"Content-Type": "application/json; charset=utf-8",
"X-Powered-By": "ASP.NET"
},
"transmission_id": "e11441f0-ee23-11ec-bf74-079e67007b5e",
"status": "SUCCESS",
"timestamp": "2022-06-17T09:57:20Z"
}
],
"links": [
{
"href": https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-3YN53862H3003372E-77V7032476059723Y,
"rel": "self",
"method": "GET",
"encType": "application/json"
},
{
"href": https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-3YN53862H3003372E-77V7032476059723Y/resend,
"rel": "resend",
"method": "POST",
"encType": "application/json"
}
],
"event_version": "1.0"
}

更改订阅到新计划的API调用

POST https://api-m.sandbox.paypal.com/v1/billing/subscriptions/I-3J5HHBY1JHMC/revise
-H "Content-Type: application/json" 
-H "Authorization: Bearer <Access-Token>" 
-d '
{ "plan_id": " P-39787693WX5555114MKWE6KI"
}'

AZURE日志APPINSIGHT的响应日志

{
"name": "RESOURCE_NOT_FOUND",
"message": "The specified resource does not exist.",
"debug_id": "cff93589c06cd",
"details": [
{
"issue": "INVALID_RESOURCE_ID",
"description": "Requested resource ID was not found."
}
],
"links": [
{
"href": https://developer.paypal.com/docs/api/v1/billing/subscriptions#RESOURCE_NOT_FOUND,
"rel": "information_link",
"method": "GET"
}
]
}

看起来您创建的订阅ID与您试图修改订阅的APP/client-id不同。

管理您的应用程序和相应的客户端id在https://www.paypal.com/signin?intent=developer&returnUri=https%3A%2F%2Fdeveloper.paypal.com%2Fdeveloper%2Fapplications

最新更新