Updates a Store Credit
const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
store_credit: {
user_id: '2',
category_id: '4',
created_by_id: '5',
amount: 25,
currency: 'USD',
type_id: '1',
store_id: '2',
amount_used: 10,
memo: 'This credit was given as a refund',
amount_authorized: 15.5,
originator_id: '3',
originator_type: 'Refund',
public_metadata: {},
private_metadata: {}
}
})
};
fetch('http://{defaultHost}/api/v2/platform/store_credits/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"data": {
"id": "9",
"type": "store_credit",
"attributes": {
"amount": "500.0",
"amount_used": "0.0",
"memo": "The user is awarded",
"deleted_at": null,
"currency": "CAD",
"amount_authorized": "0.0",
"originator_type": null,
"created_at": "2022-11-08T19:35:40.170Z",
"updated_at": "2022-11-08T19:35:40.405Z",
"public_metadata": {
"loyalty_reward": true
},
"private_metadata": {},
"display_amount": "$500.00",
"display_amount_used": "$0.00"
},
"relationships": {
"user": {
"data": {
"id": "119",
"type": "user"
}
},
"created_by": {
"data": {
"id": "120",
"type": "user"
}
},
"store_credit_category": {
"data": {
"id": "21",
"type": "store_credit_category"
}
},
"store_credit_type": {
"data": {
"id": "22",
"type": "store_credit_type"
}
},
"store_credit_events": {
"data": [
{
"id": "10",
"type": "store_credit_event"
}
]
}
}
}
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Select which associated resources you would like to fetch, see: https://jsonapi.org/format/#fetching-includes
Show child attributes
Record updated
Show child attributes
Was this page helpful?
const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
store_credit: {
user_id: '2',
category_id: '4',
created_by_id: '5',
amount: 25,
currency: 'USD',
type_id: '1',
store_id: '2',
amount_used: 10,
memo: 'This credit was given as a refund',
amount_authorized: 15.5,
originator_id: '3',
originator_type: 'Refund',
public_metadata: {},
private_metadata: {}
}
})
};
fetch('http://{defaultHost}/api/v2/platform/store_credits/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"data": {
"id": "9",
"type": "store_credit",
"attributes": {
"amount": "500.0",
"amount_used": "0.0",
"memo": "The user is awarded",
"deleted_at": null,
"currency": "CAD",
"amount_authorized": "0.0",
"originator_type": null,
"created_at": "2022-11-08T19:35:40.170Z",
"updated_at": "2022-11-08T19:35:40.405Z",
"public_metadata": {
"loyalty_reward": true
},
"private_metadata": {},
"display_amount": "$500.00",
"display_amount_used": "$0.00"
},
"relationships": {
"user": {
"data": {
"id": "119",
"type": "user"
}
},
"created_by": {
"data": {
"id": "120",
"type": "user"
}
},
"store_credit_category": {
"data": {
"id": "21",
"type": "store_credit_category"
}
},
"store_credit_type": {
"data": {
"id": "22",
"type": "store_credit_type"
}
},
"store_credit_events": {
"data": [
{
"id": "10",
"type": "store_credit_event"
}
]
}
}
}
}