- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everybody.
I would like some some help with the following issue.
As a part of my testing i need to create some authorized "test" orders with payments in order to use them to make capture, void and refund calls.
I can already create on order but i cannot proceed to execute it so that i would get the order id to authorize it (with https://api.sandbox.paypal.com/v1/payments/orders/{order_id}/authorize) because i don't have a payer id on it.
The order creation data is
{
"intent": "authorize",
"state":"approved",
"payer": {
"payment_method": "paypal"
},
"transactions": [{
"amount": {
"total": "123.45",
"currency": "EUR"
}
}],
"redirect_urls": {
"return_url": "https://example.com/your_redirect_url.html",
"cancel_url": "https://example.com/your_cancel_url.html"
}
}
can you please help with that.
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @kokobill
You need to first create a payment and pass the "intent" as "order", then execute that payment request and you'll be returned an order id.
https://developer.paypal.com/docs/api/payments/#payment_create
## Request
{
"intent":"order",
"redirect_urls":{
"return_url":"http://www.paypal.com",
"cancel_url":"http://www.paypal.com"
},
"payer":{
"payment_method":"paypal"
},
"transactions":[
{
"amount":{
"total":"5.00",
"currency":"USD"
}
}
]
}
## Response
"id": "PAY-25810121L21995004LILJ37Q",
"intent": "order",
"state": "created",
"payer": {
"payment_method": "paypal"
},
"transactions": [
{
"amount": {
"total": "5.00",
"currency": "USD"
{
"href": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-9CM4610894219853C",
"rel": "approval_url",
"method": "REDIRECT"
},
Buyer is redirected to the "redirect" URL above, they login to their account and approve the transaction. You then execute that payment and the order id is returned in the response.
## Response
"id": "PAY-25810121L21995004LILJ37Q",
"intent": "order",
"state": "approved",
"cart": "9CM4610894219853C",
"payer": {
"payment_method": "paypal",
"status": "VERIFIED",
"related_resources": [
{
"order": {
"id": "O-8HK725664L9406804",
"create_time": "2017-11-23T10:11:39Z",
"update_time": "2017-11-23T10:11:39Z",
"amount": {
"total": "5.00",
"currency": "USD",
You can then use that order id when submitting an authorization request on the order
https://developer.paypal.com/docs/api/payments/#order_authorize
## Response
"id": "7S9107002T8538358",
"create_time": "2017-11-23T10:13:14Z",
"update_time": "2017-11-23T10:13:19Z",
"amount": {
"total": "5.00",
"currency": "USD"
},
"state": "authorized",
Was my post helpful? If so, please give me a kudos!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @kokobill
You need to first create a payment and pass the "intent" as "order", then execute that payment request and you'll be returned an order id.
https://developer.paypal.com/docs/api/payments/#payment_create
## Request
{
"intent":"order",
"redirect_urls":{
"return_url":"http://www.paypal.com",
"cancel_url":"http://www.paypal.com"
},
"payer":{
"payment_method":"paypal"
},
"transactions":[
{
"amount":{
"total":"5.00",
"currency":"USD"
}
}
]
}
## Response
"id": "PAY-25810121L21995004LILJ37Q",
"intent": "order",
"state": "created",
"payer": {
"payment_method": "paypal"
},
"transactions": [
{
"amount": {
"total": "5.00",
"currency": "USD"
{
"href": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-9CM4610894219853C",
"rel": "approval_url",
"method": "REDIRECT"
},
Buyer is redirected to the "redirect" URL above, they login to their account and approve the transaction. You then execute that payment and the order id is returned in the response.
## Response
"id": "PAY-25810121L21995004LILJ37Q",
"intent": "order",
"state": "approved",
"cart": "9CM4610894219853C",
"payer": {
"payment_method": "paypal",
"status": "VERIFIED",
"related_resources": [
{
"order": {
"id": "O-8HK725664L9406804",
"create_time": "2017-11-23T10:11:39Z",
"update_time": "2017-11-23T10:11:39Z",
"amount": {
"total": "5.00",
"currency": "USD",
You can then use that order id when submitting an authorization request on the order
https://developer.paypal.com/docs/api/payments/#order_authorize
## Response
"id": "7S9107002T8538358",
"create_time": "2017-11-23T10:13:14Z",
"update_time": "2017-11-23T10:13:19Z",
"amount": {
"total": "5.00",
"currency": "USD"
},
"state": "authorized",
Was my post helpful? If so, please give me a kudos!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi again
I have already been able to (after creating a token) to create an order with data
{ "intent": "order", "state":"approved", "payer": { "payment_method": "paypal" }, "transactions": [{ "amount": { "total": "123.45", "currency": "EUR" } }], "redirect_urls": { "return_url": "https://example.com/your_redirect_url.html", "cancel_url": "https://example.com/your_cancel_url.html" } }
and i get the response
{ "id": "PAY-0VG52272L64696250LILJ5OY", "intent": "order", "state": "created", "payer": { "payment_method": "paypal" }, "transactions": [ { "amount": { "total": "123.45", "currency": "EUR" }, "related_resources": [] } ], "create_time": "2017-11-23T10:11:07Z", }
but when i try to make a call to
https://api.sandbox.paypal.com/v1/payments/orders/PAY-0VG52272L64696250LILJ5OY/authorize (the returned id) and this simple data
{ "amount": { "total": "123.45", "currency": "EUR" } }
i get the following error
{ "name": "INVALID_RESOURCE_ID", "message": "Requested resource ID was not found.", "information_link": "https://developer.paypal.com/docs/api/payments/#errors", "debug_id": "a65bfe5fc23b0" }
any ideas???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You missed part of my instructions where I advised you need to "execute" the payment request after it has been "created". You appear to have only completed the transaction "created" portion.
https://developer.paypal.com/docs/api/payments/#payment_execute
Was my post helpful? If so, please give me a kudos!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What i am missing here is the EXECUTION step. If you check my other response
For example i create an order and i get the returned it PAY-0VG52272L64696250LILJ5OY
When i try to execute it with https://api.sandbox.paypal.com/v1/payments/payment/PAY-0VG52272L64696250LILJ5OY/execute i cannot proceed since i dont have a payer_id to use in my request data.
Do you mean i will always have to go to the redirect url and make a payment with another paypal account?
I tried to do so but which card should i use? i cannot use 4xxx xxxx xxxx xxxx etc...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is why the "redirect URL" is returned in the response, you need to direct the buyer to that URL, they login with their PayPal account or pay via card.
You can use any card number, search for random card generator on the internet or use one of the card numbers below. Any expiry from 01/2018 any CVV2/CSC can be used.
Mastercard
5496146035001297
5556019452615237
5552063293947825
5447974126566054
5168232526473398
5431105322898953
5164396813396788
5359369902182075
5232439352648330
5594894113410226
VISA 16 digit
4024007135674009
4395637750297032
4929351047533416
4916344119139837
4929856961714065
4929712914213640
4532216287992052
4929783607910669
4556203475245270
4622424480492521
Was my post helpful? If so, please give me a kudos!
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.