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.
Related
I am trying to find a tool to automatically generate a set of view elements in the fragment.
The idea is to have a user input template file (xml or json), where the user can define the simple fields that he wants to see displayed in the fragment such as TextView, EditText, Buttons or spinner menus.
Then, the app can read that file and load/generate automatically the fields and show them in the fragment.
For example, a user defines the following json file, here define 2 TextFields and one checkbox with 2 options:
{
"sections": [
{
"rows": [
{
"items": [
{
"componentType": "TextField",
"inputType" "text",
"var": "user name"
}
]
}
],
"itemRank": "1",
"title": "User Login Name",
"shortTitle": "login"
},
{
"rows": [
{
"items": [
{
"componentType": "TextField",
"inputType" "float",
"var": "0.0",
"min": "0.0",
"max": "100.0",
"format":"3.3f"
}
]
}
],
"itemRank": "2",
"title": "Weather Temperature",
"shortTitle": "temp"
},
{
"rows": [
{
"items": [
{
"componentType": "multiSelect",
"inputType" "float",
"options": [
{
"text": "Checkbox option 1",
"var": "option1",
"selected": "false"
},
{
"text": "Checkbox option 2",
"var": "option2",
"selected": "false"
}
]
}
]
}
],
"itemRank": "3",
"title": "Weather Temperature",
"shortTitle": "temp"
},
"name": "My json template view elements",
"title": "My report"
}
Having that json file as an input, generate these fields to attach them on the fragment as views and process them accordingly.
Is there a library that can do that?
Thanks in Advance. This is the response what i am getting. I need to insert this data to local database using room library and need to use auto synchronization in android.
I need to create a local database with this data . I am not clear how to save list and List in android.
{"email": "abc#gmail.com",
"createdOn": "1530344810442",
"childname": "kid1",
"statuscode": "Open",
"programs": ["a","b"],
"labels": [
"5b360152a987ba31b26ced9d",
"5b360152a987ba31b26ced98"
],
"enquiriedPrograms": [
"FIRST",
"Daycare"
],
"details": "Rosy [11:53 a.m. 10 Mar 2018 ] - Interested to join in next year",
"dateofenquiry": "1520682660000",
"followup": "1552132380000",
"channel": "Parent referral",
"academicYear": "2019-20",
"childDOB": "959668410000",
"country": "India",
"countryCode": "91",
"country_name_code": "IN",
"secodaryContact": "99563959718",
"secodaryCountry": "India",
"secodaryCountryCode": "91",
"secodarycountry_name_code": "IN",
"priority": "0",
"_id": "5b37356afa4f6c15a0474d08",
"parentname": "parent",
"mobile": "96542372812",
"schoolid": "59df41728832621654417350",
"__v": 0,
"labelNames": [
{
"_id": "5b360152a987ba31b26ced9d",
"name": "Add",
"colourCode": "#FFFF00"
},
{
"_id": "5b360152a987ba31b26ced98",
"name": "sub",
"colourCode": "#7FB3D5"
}
]
}
I'm trying to set up CI for Gradle based Android project with Bamboo. Tutorial here work just work great for successful build.
For release note following I figure out to get Git log between two revision number.
git log ${bamboo.repository.previous.revision.number}..${bamboo.repository.revision.number}
But how to get last successful build git_revision number & current one.
Any suggestion ?
This involves scripting and utilizing REST API of Bamboo https://docs.atlassian.com/bamboo/REST [Choose the version you are working with]
To get all the build results, you need to make a call to:
[GET] <basepath>/rest/api/latest/result/{projectKey}-{buildKey}
Where, basepath is http://myhost.com:8085 OR http://myhost.com:8085/bamboo
Resulting in below:
{
"results": {
"size": 8,
"expand": "result",
"start-index": 0,
"max-result": 25,
"result": [
{
"link": {
"href": "<basepath>/rest/api/latest/result/{projectKey}-{buildKey}-{buildNumber}",
"rel": "self"
},
"plan": {
"shortName": "xyz",
"shortKey": "{buildKey}",
"type": "chain",
"enabled": true,
"link": {
"href": "<basepath>/rest/api/latest/plan/DS-ASVCCRED",
"rel": "self"
},
"key": "{projectKey}-{buildKey}",
"name": "ABCD",
"planKey": {
"key": "{projectKey}-{buildKey}"
}
},
"buildResultKey": "{projectKey}-{buildKey}-{buildNumber}",
"lifeCycleState": "Finished",
"id": 198039818,
"key": "{projectKey}-{buildKey}-{buildNumber}",
"planResultKey": {
"key": "{projectKey}-{buildKey}-{buildNumber}",
"entityKey": {
"key": "{projectKey}-{buildKey}"
},
"resultNumber": 45
},
"state": "Failed",
"buildState": "Failed",
"number": 45,
"buildNumber": 45
},
If JSON output is desired, just add Accept=application/json header while making a call.
This will return latest 25 build results in a sequence with the latest result being the first. You may go through this results and decide which two build results you are interested in.
Once you decide, you make additional calls to get change set (commit details) captured by bamboo for that particular build.
[GET] <basepath>/rest/api/latest/result/{projectKey}-{buildKey}/{buildNumber : ([0-9]+)|(latest)}?expand=changes
This will give you detailed commit description as below:
"changes": {
"size": 3,
"expand": "change",
"change": [
{
"author": "1234",
"changesetId": "7f76c41a7ff48f679a91d0fa2810ef3398121dc6"
},
{
"author": "abcd",
"changesetId": "104d8b7af9538599a02006005314033c8017e804"
},
{
"author": "cdef",
"changesetId": "d21aef9f3745257aa501425fc31ebd0c6b33f608"
}
],
"start-index": 0,
"max-result": 3
},
And then you can perform
git log <changesetId>...<changesetId>
I am using Firebase Database for my mobile and web application. I wanted to get advise for how to structure the JSON Tree. I have the following use case in mind:
Mobile app user logs in and gets all nearby restaurants in a list. User sets order on one restaurant. The restaurant owner uses web or mobile application to see incoming orders and accepts them. After accepting the order, the mobile app user gets response that his order has been accepted. Now my idea for the structure was the following:
SO we have one node at top level for each restaurant and each restaurant node contains a requests node which saves all the requests for this restaurants.
Is that structure ok or could this be structured better?
Consider a data structure like this, you don't want to retrieve all the request when you get a restaurant and this way, you can get all the requests for a restaurant and all the requests from a particular user.
{
"requests": {
"req1": {
"status": 0,
"time": 1473593287,
"user": { "u2": true }
},
"req2": {
"status": 0,
"time": 1473593227,
"user": { "u1": true }
},
"req3": {
"status": 0,
"time": 1473594287,
"user": { "u1": true }
},
"req4": {
"status": 0,
"time": 1473594227,
"user": { "u2": true }
},
},
"restaurant-requests": {
"resA": {
"req1": true,
"req2": true
},
"resB": {
"req3": true,
"req4": true
}
},
"restaurants": {
"resA": {
"name": "Example Restaurant A",
"address": "1 Example Street"
},
"resB": {
"name": "Example Restaurant B",
"address": "2 Example Street"
}
},
"user-requests": {
"u1": {
"req2": true,
"req3": true
},
"u2": {
"req1": true,
"req4": true
}
},
"users": {
"u1": {
"address": "123 Example Street"
},
"u2": {
"address": "124 Example Street"
},
},
}
That's what I would do..
good luck!
I was wondering how to get the value of "name" for the following json text with facebook sdk. Assuming I have already got the access token. Any thoughts? Many thanks!
enter code here
{
"id": "100005065353669",
"music": {
"data": [
{
"category": "Musician/band",
"name": "Eason Chan",
"id": "105468519487919",
"created_time": "2013-06-05T20:33:26+0000"
}
],
"paging": {
"next": "https://graph.facebook.com/100005065353669/musiclimit=5000&offset=5000&__after_id=105468519487919"
}
}
}