I am integrating Paypal checkout in an Android App using REST APIs provided by Paypal and my country is India so I am following this guide from PayPal.
How I did as per docs:
Get access-token (/v1/oauth2/token) for further api calls.
Use the Create Order API to create a payment (v2/checkout/orders)and in the response we will get approval url at where you need to redirect user to make the payment.
Now my question is how do I know if payment transaction was successful or not in mobile app because I am using WebView in my app to load approval url.
Order is created like this and I load href inside webview:
{
"id": "1KK44573EX7352015",
"status": "CREATED",
"links": [
{
"href": "https://www.sandbox.paypal.com/checkoutnowtoken=1KK44573EX7352015",
"rel": "approve",
"method": "GET"
}
]
}
I did this way:
As soon as Payment is successfully completed by customer the return_url gets called with query parameters : PayerID & token(orderID). At that time we can update user's payment status in our database (Amount is not deducted yet still because order is yet not approved or captured).
After that we can capture our order (Make sure invoice-id is not duplicate) otherwise status will be not completed.
If order is not approved on the time of capture we get this kind of error:
{
"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.",
"debug_id": "47af43e..",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-ORDER_NOT_APPROVED",
"rel": "information_link",
"method": "GET"
}
]
}
If there is duplicate invoice-id you will see error at the time of capture:
{
"name": "UNPROCESSABLE_ENTITY",
"details": [
{
"issue": "DUPLICATE_INVOICE_ID",
"description": "Duplicate Invoice ID detected. To avoid a potential duplicate transaction your account setting requires that Invoice Id be unique for each transaction."
}
],
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "86e0cc7f....",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-DUPLICATE_INVOICE_ID",
"rel": "information_link",
"method": "GET"
}
]
}
If there is currency based issue:
{
"name": "UNPROCESSABLE_ENTITY",
"details": [
{
"location": "body",
"issue": "CURRENCY_NOT_SUPPORTED",
"description": "Currency code is not currently supported. Please refer https://developer.paypal.com/docs/integration/direct/rest/currency-codes/ for list of supported currency codes."
}
],
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "d666b5e5eb0c0",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-CURRENCY_NOT_SUPPORTED",
"rel": "information_link",
"method": "GET"
}
]
}
If your order is successfully captured with status as COMPLETED:
{
"id": "8G0042477K865063U",
"status": "COMPLETED",
"purchase_units": [
{
"reference_id": "default",
"shipping": {
"name": {
"full_name": "John Doe"
},
"address": {
"address_line_1": "10, east street",
"address_line_2": "first building",
"admin_area_2": "Mumbai",
"admin_area_1": "Maharashtra",
"postal_code": "400029",
"country_code": "NZ"
}
},
"payments": {
"captures": [
{
"id": "4K670967VH2547504",
"status": "PENDING",
"status_details": {
"reason": "RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION"
},
"amount": {
"currency_code": "NZD",
"value": "170.00"
},
"final_capture": true,
"seller_protection": {
"status": "ELIGIBLE",
"dispute_categories": [
"ITEM_NOT_RECEIVED",
"UNAUTHORIZED_TRANSACTION"
]
},
"invoice_id": "INV-1234567888",
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/payments/captures/4K670967VH2547504",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v2/payments/captures/4K670967VH2547504/refund",
"rel": "refund",
"method": "POST"
},
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/8G0042477K865063U",
"rel": "up",
"method": "GET"
}
],
"create_time": "2020-10-31T13:35:58Z",
"update_time": "2020-10-31T13:35:58Z"
}
]
}
}
],
"payer": {
"name": {
"given_name": "Sumit",
"surname": "Shukla"
},
"email_address": "testg32#gmail.com",
"payer_id": "VW87TYSM2GMZ4",
"address": {
"address_line_1": "10, east street",
"admin_area_2": "Mumbai",
"admin_area_1": "Maharashtra",
"postal_code": "400029",
"country_code": "NZ"
}
},
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/8G0042477K865063U",
"rel": "self",
"method": "GET"
}
]
}
After that you can redirect user to thank you page and update mobile app screen based on database values.
**[11:12] Umer Saleem
Working on it, sir in this example link what is the components name and how to find it
POST https://{subdomain}.{centralDnsSuffixInPath}/api/preview/devices/{device_id}/components/{component_name}/commands/{command_name}
**
To find out what components you have for this device, you can do a GET request to
https://{subdomain}.{centralDnsSuffixInPath}/api/preview/devices/{device_id}/components/
This will show you the components, a sample response can be:
{
"value": [
{
"#id": "urn:machine:MyMachine:lxhc64xu:1",
"#type": [
"InterfaceInstance"
],
"name": "cb_7d7",
"displayName": "Interface"
},
{
"#id": "urn:machine:MyMachine:_lyh_e2x:1",
"#type": [
"InterfaceInstance"
],
"name": "cb_282",
"displayName": "Properties"
}
]
}
The name of the {component} is the name of the value that you get in the response. In my example, you can use "cb_7d7" or "cb_282". They are the names of your interfaces.
I am working on an ionic app which will be used on android and iOS platforms.and I need to post an object to the server which contain some attribute that reference others for example:
{
"room": [
{
"#id": 2,
"date": "2019-10-10",
"number": "750"
}
],
"bed": [
[
{
"class": "A",
"room": 2
}
]
]
}
but when posting it the order of the JSON object changes to :
{
"bed": [
[
{
"class": "A",
"room": 2
}
]
],
"room": [
{
"#id": 2,
"date": "2019-10-10",
"number": "750"
}
]
}
what should I do to keep the order of the object, considering that it works fine in android?
Referring to JSON's standards, an object is simply unordered which means there is no problem with your case. However, if in your case the order is important, you may use arrays. Arrays make sure the order is preserved.
I am trying to make an app showing info from an API. I have searched everywhere but I didn't find an answer that solve my problem!
Here is an example from the JSON file:
{
"status": 200,
"data": {
"date": "2018-10-12T00:00:00.000Z",
"featured": [
{
"id": "5bbdc3abdf819b65ea6b733b",
"name": "Name",
"price": "1",
"priceIcon": "priceicon",
"priceIconLink": "price.png",
"images": {
"icon": "icon.png",
"png": false,
"gallery": false,
"featured": false
},
"rarity": "rarity",
"type": "type",
"readableType": "Type"
}
]
}
}
How can I fetch the name, price, icon, rarity and readableType?
Please don't mark it as duplicate because I haven't found the answer that I am searching for.
Check this tutorial, no one is going to code it for you, also your question has been made 10000 times
Tutorial
My json file that have data
[
{
"id": 19,
"name": "Science",
"quiz": "quiz6"
},
{
"id": 21,
"name": "general knowledge",
"quiz": "For banking"
},
{
"id": 26,
"name": "Technologies",
"quiz": "arithmatic"
},
{
"id": 27,
"name": "english",
"quiz": "abcde"
},
{
"id": 28,
"name": "computer",
"quiz": "basic Question"
}
]
save on a server.Now i want to parse it in phonegap(android).How to do that.
When I save that file on my project and use it then it work, but when i use that file directly on server site then its not working.Is there any permission or plugin needed to access json on server side.
If in url i pass the "http://some folders/places.php" then it not work.
Thanks to all. Its working now.I try it on phone and its working.Actually my AVG software block my emulator to access the internet. Thats why it was not working.