PayPal Rest API开票:用户不与基于开票人电子邮件的PayPal关联



我正在尝试使用PayPal Rest API进行开票。我遵循了这里的文档https://developer.paypal.com.我可以获得Bearer代币,可以创建草稿发票,但当我试图发送发票时,总是会遇到同样的错误。我确保创建了一个商业PayPal沙盒帐户和一个个人沙盒PayPal帐户,并确保在创建发票时使用与这两个PayPal沙盒帐户的配置文件中相同的电子邮件和名称。我总是根据发票人的电子邮件,用户与贝宝没有关联请问我做错了什么?

这是我的代码:

创建草稿发票:

curl -v -X POST https://api-m.sandbox.paypal.com/v2/invoicing/invoices 
-H "Content-Type: application/json" 
-H "Authorization: Bearer A21AALLJG-bj38vBQqmOd18RvmMFGd8KpynK5iN4QitItZ49.....DWi5v191pygpjX7acNugdw" 
-d '{
"detail":{
"invoice_number":"#001002003004",
"invoice_date":"2022-10-05",
"currency_code":"USD",
"note":"Thank you.",
"payment_term":{
"due_date":"2022-10-06"
}
},
"invoicer":{
"name":{
"given_name":"John Doe"
},
"address":{
"address_line_1":"1 Main St, San Jose",
"admin_area_1":"CA",
"postal_code":"95131",
"country_code":"US"
},
"email_address":"sb-nunyt18072622@business.example.com",
"phones":[
{
"country_code":"001",
"national_number":"4086743426",
"phone_type":"MOBILE"
}
],
"website":"website.com",
"logo_url":"https://website.com/images/website.png"
},
"primary_recipients":[
{
"billing_info":{
"name":{
"given_name":"John Doe"
},
"address":{
"address_line_1":"1 Main St, San Jose",
"admin_area_1":"CA",
"postal_code":"95131",
"country_code":"US"
},
"email_address":"sb-y47azf21389350@personal.example.com",
"phones":[
{
"country_code":"001",
"national_number":"4089403004",
"phone_type":"HOME"
}
],
"additional_info_value":"add-info"
},
"shipping_info":{
"name":{
"given_name":"John Doe"
},
"address":{
"address_line_1":"1 Main St, San Jose",
"admin_area_1":"CA",
"postal_code":"95131",
"country_code":"US"
}
}
}
],
"items":[
{
"name":"Yoga Mat",
"description":"Elastic mat to practice yoga.",
"quantity":"1",
"unit_amount":{
"currency_code":"USD",
"value":"50.00"
}
}
]
}'

响应:

{"rel":"self","href":"https://api.sandbox.paypal.com/v2/invoicing/invoices/INV2-5JLL-25MZ-FF2Y-Y2RG","method":"GET"} 

发送草稿发票:

curl -v -X POST https://api-m.sandbox.paypal.com/v2/invoicing/invoices/INV2-5JLL-25MZ-FF2Y-Y2RG/send 
-H "Content-Type: application/json" 
-H "Authorization: Bearer A21AALLJG-bj38vBQqmOd18RvmMFGd8KpynK5iN..........Wi5v191pygpjX7acNugdw" 
-d '{
"send_to_invoicer": true
}'

响应:

Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 151.101.193.35:443...
* TCP_NODELAY set
* Connected to api-m.sandbox.paypal.com (151.101.193.35) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: businessCategory=Private Organization; jurisdictionC=US; jurisdictionST=Delaware; serialNumber=3014267; C=US; ST=California; L=San Jose; O=PayPal, Inc.; CN=www.sandbox.paypal.com
*  start date: Feb  8 00:00:00 2022 GMT
*  expire date: Mar 11 23:59:59 2023 GMT
*  subjectAltName: host "api-m.sandbox.paypal.com" matched cert's "api-m.sandbox.paypal.com"
*  issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 Extended Validation Server CA
*  SSL certificate verify ok.
> POST /v2/invoicing/invoices/INV2-5JLL-25MZ-FF2Y-Y2RG/send HTTP/1.1
> Host: api-m.sandbox.paypal.com
> User-Agent: curl/7.65.0
> Accept: */*
> Content-Type: application/json
> Authorization: Bearer A21AALLJG-bj38.............191pygpjX7acNugdw
> Content-Length: 30
>
* upload completely sent off: 30 out of 30 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 422 Unprocessable Entity
< Connection: keep-alive
< Content-Length: 377
< Content-Type: application/json
< Server: nginx/1.18.0 (Ubuntu)
< Cache-Control: max-age=0, no-cache, no-store, must-revalidate
< Paypal-Debug-Id: c64c32bd383a9
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< Accept-Ranges: bytes
< Via: 1.1 varnish, 1.1 varnish
< Edge-Control: max-age=0
< Date: Wed, 05 Oct 2022 16:36:41 GMT
< X-Served-By: cache-lhr7321-LHR, cache-mad22050-MAD
< X-Cache: MISS, MISS
< X-Cache-Hits: 0, 0
< X-Timer: S1664987800.334487,VS0,VE666
<
* Connection #0 to host api-m.sandbox.paypal.com left intact
{"name":"UNPROCESSABLE_ENTITY","message":"The requested action could not be performed, semantically incorrect, or failed business validation.","debug_id":"c64c32bd383a9","details":[{"issue":"USER_NOT_FOUND","description":"User is not associated with paypal based on invoicer email."}],"links":[{"href":"https://developer.paypal.com/docs/api/invoicing/#errors","method":"GET"}]}                

我遇到了这个问题。";Preston PHX";解决了我的问题。我创建了新的沙箱业务和个人帐户,以及一个新的REST应用程序,并在创建和发送测试发票时使用了这些帐户。似乎问题出在默认的PayPal沙盒帐户和应用程序上。

最新更新