Get Malformed error while patch request to update payment - python-2.7

I want to reduce some items of my order from payment. That's why I'm using replace method of PayPal python API that allows to update or add data after an object of payment has been created.
Error:
{u'message': u'Incoming JSON request does not map to API request', u'debug_id': u'd57742e9d3b03', u'name': u'MALFORMED_REQUEST', u'information_link': u'https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST'}
Code:
create payment:
I added two products while creating a payment object.
payment = Payment({
"intent": "sale",
"payer": {
"payment_method": "paypal"},
"redirect_urls": {
"return_url": "http://localhost:3000/payment/execute",
"cancel_url": "http://localhost:3000/"},
"transactions": [{
"item_list": {
"items": [{
"name": "Ice-cream",
"sku": "I10001",
"price": "50.00",
"currency": "USD",
"quantity": 12},
{
"name": "Ice-cream12",
"sku": "I100012",
"price": "60.00",
"currency": "USD",
"quantity": 12}
]},
"amount": {
"total": "1320.00",
"currency": "USD"},
"description": "This is the payment transaction description."}]})
payment.create()
Update Payment:
update_payment_json = [
{
"op":"replace",
"path":"/transactions/0/item_list",
"values":{"items":[{
"name": "Ice-cream",
"sku": "I10001",
"price": "50.00",
"currency": "USD",
"quantity": 12,
},]}
},
{
"op":"replace",
"path":"/transactions/0/amount",
"value":
{
"total": "600.00",
"currency": "USD",
"details":{
"subtotal": "600.00",
"shipping":"0.0",
}},
},
]
payment.replace(update_payment_json)

I don't believe the below path is sufficient to determine which item are you updating ? there are 2 items in the item_list correct? if you are updating just 1 of it then you need to qualify it to the right path so that you are clear about which item you are replacing.
"path":"/transactions/0/item_list",

Related

Loopback Relations Query to update parent

long time lurker in the loopback posts. I'm finally getting around to implementing some CRUD stuff with relations but I'm having some issues.
I have a form model that has a hasMany relation with leverOnes
and levelOnes has a hasMany relation with levelTwos
the individual patches are working fine (for example, if I need to update a single levelOne), but I have a page where the client essentially updates a bunch of levelOnes and levelTwos for a single Form at the same time. I can't update the form with my relation directly.
the patch is taking place at /forms/{id} at the top level, and I am getting a 500 error because when I attempt to patch
"id": "acmeform1",
"name": "ACME Assessment",
"userId": "string",
"org": "Complaints Department",
"clientId": "user#acme.com",
"dueDate": "2022-03-25T18:25:55.734Z",
"readyForReview": true,
"workDriverOnes": [
{
"id": "21740e676035c083fc20004803e88380",
"name": "Governance and Culture",
"description": "Governance and Culture",
"formId": "acmeform1",
"workDriverTwos": [
{
"id": "21740e676035c083fc20004803e8925f",
"name": "Annual Compliance Plan",
"description": "Annual Compliance Plan",
"workDriverOneId": "21740e676035c083fc20004803e88380",
"unitsPerPeriod": 1,
"amount": 20,
"unitType": "Annually",
"ongoing": true,
"roles": [
{
"id": "36c5b6399e951d45a7179f10b1b2df28",
"demandAmount": 5,
"role": "VP - Grade 36 Manager",
"workDriverTwoId": "21740e676035c083fc20004803e8925f"
},
{
"id": "8b054a1cb5002b760d68695b29cf16f6",
"demandAmount": 10,
"role": "SVP - Director",
"workDriverTwoId": "21740e676035c083fc20004803e8925f"
},
{
"id": "b92d2ed082c108d76ee91887234c1b1e",
"demandAmount": 5,
"role": "VP - Grade 37 Manager",
"workDriverTwoId": "21740e676035c083fc20004803e8925f"
}
]
}
]
},
{
"id": "285deab3c703506ac7878327b06eb4bf",
"name": "Policy Governance",
"description": "Policy Governance",
"formId": "acmeform1",
"workDriverTwos": [
{
"id": "8403a66eab00b0de2d2131cfe8d51135",
"name": "Policies",
"description": "Policies",
"workDriverOneId": "285deab3c703506ac7878327b06eb4bf",
"unitsPerPeriod": 1,
"amount": 20,
"unitType": "# Policies",
"ongoing": true,
"roles": [
{
"id": "285deab3c703506ac7878327b06ed443",
"demandAmount": 6,
"role": "VP - Grade 36 Manager",
"workDriverTwoId": "8403a66eab00b0de2d2131cfe8d51135"
},
{
"id": "2e362351b4477cb26f61937a37db27cb",
"demandAmount": 6,
"role": "VP - Grade 37 Manager",
"workDriverTwoId": "8403a66eab00b0de2d2131cfe8d51135"
},
{
"id": "36c5b6399e951d45a7179f10b1b2e932",
"demandAmount": 6,
"role": "SVP - Director",
"workDriverTwoId": "8403a66eab00b0de2d2131cfe8d51135"
},
{
"id": "dd6a475d1ae8f76fc7e7835331a42ad5",
"demandAmount": 2,
"role": "VP - Grade 35 Manager",
"workDriverTwoId": "8403a66eab00b0de2d2131cfe8d51135"
}
]
}
]
},
{
"id": "dd6a475d1ae8f76fc7e7835331a411c6",
"name": "Monitoring",
"description": "Monitoring",
"formId": "acmeform1",
"workDriverTwos": [
{
"id": "dd6a475d1ae8f76fc7e7835331a445a5",
"name": "Monitoring Scripts and Monitoring Plan Development and Drafting",
"description": "Monitoring Scripts",
"workDriverOneId": "dd6a475d1ae8f76fc7e7835331a411c6",
"unitsPerPeriod": 3,
"amount": 1,
"unitType": "# Monitoring Reviews",
"ongoing": true,
"roles": [
{
"id": "36c5b6399e951d45a7179f10b1b2ff49",
"demandAmount": 0.3,
"role": "SVP - Director",
"workDriverTwoId": "dd6a475d1ae8f76fc7e7835331a445a5"
},
{
"id": "9bc41d8a3a9eb3a435d946d8049cc97a",
"demandAmount": 2.7,
"role": "VP - Grade 37 Manager",
"workDriverTwoId": "dd6a475d1ae8f76fc7e7835331a445a5"
}
]
}
]
}
]
}
It says that workDriverOnes is already a relation and I can't update it directly. Do I have to manually loop through my levelOnes and patch each one individually? Or can I batch update at the form level?

Can I get all active ARB subscription in a single API call

Current I'm exporting all ARB data by calling API to get all active ARB ids then go through each ARB id to get info stored in each ID. But this process is too long and it makes lots of requests. Is there any way so that I can get all active ARB ids data in one request like that of any database?
https://developer.authorize.net/api/reference/index.html#recurring-billing-get-a-list-of-subscriptions
This function gives only small amount data while I need complete data stored in a profile like this one: https://developer.authorize.net/api/reference/index.html#recurring-billing-get-subscription
But this function only works for single ID.
New Answer
No. The ARBGetSubscriptionListRequest only returns a limited amount of information. If you want detailed information you would need to call ARBGetSubscriptionListRequest and then loop through the results and make an API call for each subscription to get the more granular data.
Due to the potentially large amount of results, you probably should store the results in a database and then have a bunch of scheduled scripts make the subsequent API calls.
Old Answer
Yes. You can call ARBGetSubscriptionListRequest.
Request:
{
"ARBGetSubscriptionListRequest": {
"merchantAuthentication": {
"name": "5KP3u95bQpv",
"transactionKey": "346HZ32z3fP4hTG2"
},
"refId": "123456",
"searchType": "subscriptionActive",
"sorting": {
"orderBy": "id",
"orderDescending": "false"
},
"paging": {
"limit": "1000",
"offset": "1"
}
}
}
Response:
{
"totalNumInResultSet": 1273,
"totalNumInResultSetSpecified": true,
"subscriptionDetails": [
{
"id": 100188,
"name": "subscription",
"status": "canceled",
"createTimeStampUTC": "2004-04-28T23:59:47.33",
"firstName": "Joe",
"lastName": "Tester",
"totalOccurrences": 12,
"pastOccurrences": 6,
"paymentMethod": "creditCard",
"accountNumber": "XXXX5454",
"invoice": "42820041325496571",
"amount": 10,
"currencyCode": "USD"
},
{
"id": 100222,
"name": "",
"status": "canceled",
"createTimeStampUTC": "2004-10-22T21:00:15.503",
"firstName": "asdf",
"lastName": "asdf",
"totalOccurrences": 12,
"pastOccurrences": 0,
"paymentMethod": "creditCard",
"accountNumber": "XXXX1111",
"invoice": "",
"amount": 1,
"currencyCode": "USD"
},
{
"id": 100223,
"name": "",
"status": "canceled",
"createTimeStampUTC": "2004-10-22T21:01:27.69",
"firstName": "asdf",
"lastName": "asdf",
"totalOccurrences": 12,
"pastOccurrences": 1,
"paymentMethod": "eCheck",
"accountNumber": "XXXX3888",
"invoice": "",
"amount": 10,
"currencyCode": "USD"
}
],
"refId": "123456",
"messages": {
"resultCode": "Ok",
"message": [
{
"code": "I00001",
"text": "Successful."
}
]
}
}

How to fetch API data as this. props?

I am trying to fetch data from API in react component as
{this.props.buyer && this.props.buyer[0].phone_number[0].number} - it's throwing error
Cannot read property 'number' of undefined
{this.props.buyer && this.props.buyer[0].name} - it's working fine
This is the API data
Orders: {
buyer:
},
}
[
{
"id": 2,
"name": "Qi Xiang",
"type": "Consignee",
"address": {
"id": 2,
"type": "shipping",
"street": "China China",
"city": "Beijing",
"postal_code": "34343",
"province": "23232",
"country": "CN"
},
"email": null,
"phone_number": {
"number": "323232",
"type": "Phone"
},
"id_image_url": "/api/files/24e49645-df42-4984-a
}
]
},
}
Your phonenumber is not array. You must use this:
this.props.buyer[0].phone_number.number

can we retrieve the data by sending id field as json object using POST method in django rest framework

GET : http://127.0.0.1:8000/r/
{
"count": 5,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"url": "http://127.0.0.1:8000/r/1/",
"name": "India",
"code": 91
},
{
"id": 2,
"url": "http://127.0.0.1:8000/r/3/",
"name": "us",
"code": 10,
},
{
"id": 3,
"url": "http://127.0.0.1:8000/r/4/",
"name": "pak",
"code": 9
},
{
"id": 4,
"url": "http://127.0.0.1:8000/r/5/",
"name": "kansas",
"code": 44
},
{
"id": 5,
"url": "http://127.0.0.1:8000/r/6/",
"name": "kanada",
"code": 123
}
}
I know that , suppose I can get "name": "us", "code": 10 based on it's "id": 2 by specifying the id in the URL like http://127.0.0.1:8000/r/2,
By using GET method,
but I want to retrive "name": "us", "code": 10 based on it's "id": 2 by sending it(means 'id') as json object using 'POST' method.

Is the referral (fb_action_ids) value, stored within the activity made by a user on a timeline app?

I'm testing a timeline app I just made.
I'm using Graph API Explorer for testing.
I tested the next URL:
https://graph.facebook.com/10150691128476714
where 10150691128476714 is the id of the activity I made through my app.
It returns the next values:
{
"id": "10150691128476714",
"from": {
"name": "Moisés Briseño Estrello",
"id": "719621713"
},
"start_time": "2012-04-26T07:22:00+0000",
"end_time": "2012-04-26T07:22:00+0000",
"publish_time": "2012-04-26T07:22:00+0000",
"application": {
"name": "appname",
"namespace": "appname",
"id": "367747679937600"
},
"data": {
"objectname": {
"id": "10150825002710211",
"url": "https://young-planet-1642.herokuapp.com/AMLO.html",
"type": "appname:objectname",
"title": "TItle"
}
},
"type": "appname:actionname",
"likes": {
"count": 0,
"can_like": true,
"user_likes": false
},
"comments": {
"count": 0,
"can_comment": true
}
}
I wonder if the referral (fb_action_ids) value is also stored in here or where I can find it?
Thanks in advance :)
ID of the action is the fb_action_ids value, i.e. fb_action_ids = 10150691128476714.