Square API: Create Checkout API error - square-connect

When using the sample POSTMAN request:
{
"idempotency_key": "74ae1696-b1e3-4328-af6d-f1e04d947a13",
"order": {
"reference_id": "my-order-001",
"line_items": [
{
"name": "line-item-1",
"quantity": "1",
"base_price_money": {
"amount": 1599,
"currency": "USD"
}
},
{
"name": "line-item-2",
"quantity": "2",
"base_price_money": {
"amount": 799,
"currency": "USD"
}
}]
},
"ask_for_shipping_address": true,
"merchant_support_email": "merchant+support#website.com",
"pre_populate_buyer_email": "buyer#email.com",
"pre_populate_shipping_address": {
"address_line_1": "500 Electric Ave",
"address_line_2": "Suite 600",
"locality": "New York",
"administrative_district_level_1": "NY",
"postal_code": "10003",
"first_name": "Jane",
"last_name": "Doe"
},
"redirect_url": "https://merchant.website.com/order-confirm"
}
I'm getting the following response:
{
"errors": [
{
"category": "INVALID_REQUEST_ERROR",
"code": "INVALID_VALUE",
"detail": "The order must have at least one line item.",
"field": "line_items"
}]
}
This is simply executing the sample POSTMAN requests available via https://docs.connect.squareup.com/api/connect/v2/#runningpostman

I was having the same issue and I reached out to Tristan. Tristan replied there was a bug that square development had to fix. I confirmed that the create checkout API is now working properly so this issue should be resolved now.

Are you using your sandbox or production access tokens? I was able to generate a checkout form with the example postman request:
{
"idempotency_key": "73ae1696-b1e3-4328-af6d-f1e04d947a13",
"order": {
"reference_id": "my-order-001",
"line_items": [
{
"name": "line-item-1",
"quantity": "1",
"base_price_money": {
"amount": 1599,
"currency": "USD"
}
},
{
"name": "line-item-2",
"quantity": "2",
"base_price_money": {
"amount": 799,
"currency": "USD"
}
}
]
},
"ask_for_shipping_address": true,
"merchant_support_email": "merchant+support#website.com",
"pre_populate_buyer_email": "buyer#email.com",
"pre_populate_shipping_address": {
"address_line_1": "500 Electric Ave",
"address_line_2": "Suite 600",
"locality": "New York",
"administrative_district_level_1": "NY",
"postal_code": "10003",
"first_name": "Jane",
"last_name": "Doe"
},
"redirect_url": "https://merchant.website.com/order-confirm"
}

Related

How to add additional fields in FHIR using Extensions?

I have a payload for Claim.
I want to add an additional field LOB (Line of business) using extension, and POST it to FHIR Server, and then search the resource using that field like:
GET: http://fhir_server/Claim?lob=value
In the payload I have added the extension block:
{
"resourceType": "Claim",
"status": "active",
"extension" : [{
"url" : "<i entered some random url>",
"valueString" : "MAPD"
}],
"identifier": [{
"value": "TEST"
}],
"type": {
"coding": [{
"system": "http://terminology.hl7.org/CodeSystem/claim-type",
"code": "institutional"
}]
},
"use": "claim",
"patient": {
"reference": "f8d8477c-1ef4-4878-abed-51e514bfd91f",
"display": "John_Smith"
},
"billablePeriod": {
"start": "1957-04-12T21:08:35+05:30",
"end": "1957-04-12T21:23:35+05:30"
},
"created": "1957-04-12T21:23:35+05:30",
"provider": {
"reference": "urn:uuid:Organization",
"display": "PCP79032"
},
"priority": {
"coding": [{
"system": "http://terminology.hl7.org/CodeSystem/processpriority",
"code": "normal"
}]
},
"facility": {
"reference": "Location",
"display": "PCP79032"
},
"diagnosis": [{
"sequence": 1,
"diagnosisReference": {
"reference": "0316a0c4-0e46-e3fa-a7bf-9e4f3b9c9e92"
}
}, {
"sequence": 2,
"diagnosisReference": {
"reference": "932432b0-ac67-0f7a-1382-26c48050c62f"
}
}],
"insurance": [{
"sequence": 1,
"focal": true,
"coverage": {
"display": "Blue Cross Blue Shield"
}
}],
"item": [{
"sequence": 1,
"productOrService": {
"coding": [{
"system": "http://snomed.info/sct",
"code": "162673000",
"display": "General examination of patient (procedure)"
}],
"text": "General examination of patient (procedure)"
},
"encounter": [{
"reference": "67062d00-2531-3ebd-8558-1de2fd3e5aab"
}]
}, {
"sequence": 2,
"diagnosisSequence": [1],
"productOrService": {
"coding": [{
"system": "http://snomed.info/sct",
"code": "713458007",
"display": "Lack of access to transportation (finding)"
}],
"text": "Lack of access to transportation (finding)"
}
}, {
"sequence": 3,
"diagnosisSequence": [2],
"productOrService": {
"coding": [{
"system": "http://snomed.info/sct",
"code": "73595000",
"display": "Stress (finding)"
}],
"text": "Stress (finding)"
}
}],
"total": {
"value": 786.3299999999999,
"currency": "USD"
}
}
and created a SearchParameter using POST:
{
"resourceType" : "SearchParameter",
"id": "21761828-b929-416a-8813-d3646cf288f4",
"name": "lob",
"status": "active",
"url" : "https://fhir_server/StructureDefinition/f971fc4998167948838f8a8831ea914c",
"description": "Returns a Claim with extension.valueString matching the specified one in request.",
"code" : "lob",
"base" : [ "Claim" ],
"type" : "string",
"expression": "Claim.extension.where(url ='https://fhir_server/StructureDefinition/f971fc4998167948838f8a8831ea914c').value.string"
}
but while fetching the result (GET: https://fhirserver/Claim?lob=MAPD), I am getting the full dataset instead of the filtered result.
I also did a $reindex on the /Claim/<resource_id>/$reindex, but its not listing the field lob.
Am I missing something ?
Servers need to be configured to support new search parameters - you can't search by arbitrary elements, only by specific SearchParameters the server supports. That's true for both searching on extensions as well as core elements. You'll have to work with the owner of the server to support your desired search capability. Did you try posting on http://chat.fhir.org to find out if there was a non-extension mechanism to represent "line of business" on a Claim?

Graphql query to get an object nested in multiple layers

I am a graphql noob and the first query I have to write turned to be a complex one. Imagine this is the object I'm looking for
{
name : "ferrari"
year : "1995"
}
Now, there is a nested object in which this could be present, The object could look like this
{
"name": "car",
"year": "1990",
"morecars": [
{
"name": "ferrari",
"year": "1995"
},
{
"name": "bmw",
"year": "200"
}
]
}
or this
{
"name": "car",
"year": "1990",
"morecars": [
{
"name": "red",
"year": "1990",
"morecares": [
{
"name": "ferrari",
"year": "1995"
}
]
},
{
"name": "bmw",
"year": "200"
}
]
}
How do fetch the ferrari i need

Rest Query on the Patient Resource for Finding BOTH/ALL Given Name(s)

How do I search for a person with BOTH given names I provide?
I have the following 2 patients who are "close". Everything (in the Human Name area) is the same except one of the GivenNames are the same.
Note "Apple" vs "Banana".
{
"resourceType": "Bundle",
"id": "269caf66-0ccc-43e7-b9a5-f16f84db0149",
"meta": {
"lastUpdated": "2019-11-20T19:30:26.858917+00:00"
},
"type": "searchset",
"link": [
{
"relation": "self",
"url": "https://localhost:44348/Patient?given=Jingerheimer"
}
],
"entry": [
{
"fullUrl": "https://localhost:44348/Patient/504f6bd3-e9b4-4846-8948-97bf09c70722",
"resource": {
"resourceType": "Patient",
"id": "504f6bd3-e9b4-4846-8948-97bf09c70722",
"meta": {
"versionId": "1",
"lastUpdated": "2019-11-20T19:26:11.005+00:00"
},
"identifier": [
{
"system": "ssn",
"value": "111-11-1111"
},
{
"system": "uuid",
"value": "da55d068e0784b359fa97498a11543c5"
}
],
"name": [
{
"family": "Smith",
"given": [
"John",
"Apple",
"Jingerheimer"
]
}
]
},
"search": {
"mode": "match"
}
},
{
"fullUrl": "https://localhost:44348/Patient/10054ce9-6141-4eca-bc5b-0978f8c8afcb",
"resource": {
"resourceType": "Patient",
"id": "10054ce9-6141-4eca-bc5b-0978f8c8afcb",
"meta": {
"versionId": "1",
"lastUpdated": "2019-11-20T19:26:48.962+00:00"
},
"identifier": [
{
"system": "ssn",
"value": "222-22-2222"
},
{
"system": "uuid",
"value": "52d09f9436d44591816fd229dd139523"
}
],
"name": [
{
"family": "Smith",
"given": [
"John",
"Banana",
"Jingerheimer"
]
}
]
},
"search": {
"mode": "match"
}
}
]
}
One has GivenNames that include "Apple". The other includes GivenNames that include "Banana".
This search works fine:
https://localhost:44348/Patient/?given=Jingerheimer
What I have tried is:
https://localhost:44348/Patient/?given=Jingerheimer&given=Apple
but that gives me no results.
Note, omitting "given=Jingerheimer" is not an option....that filters a bunch of others.
I'm trying to get
"Has BOTH of the given names I provide"
Your syntax is correct, so I think the server does not handle the search correctly. Can you check the self link for your second search to see if it reflects the search you performed? Does the result Bundle have an OperationOutcome detailing something went wrong? If all that seems okay, you'll need to check your server's code.

ElasticSearch : how to rank on skill rating in full text search?

I have quite a simple case but can't find the good way to solve it:
I have People, their Skills are rated. They also have other information attached (eg: city). All of this is in my ElasticSearch index.
Example:
John
Paris
Python: 7/10
Boris
Paris
Python: 3/10
Mike
Frankfurt
Python: 7/10
I would like to perform a text search only to find people.
If I type "Python", the better rated someone is, the higher it should be
If I type "Python Paris", it should get all people in Paris sorted by Python rating
Here is an example of people document in ES index:
{
"_index": "senso",
"_type": "talent",
"_id": "12469",
"_version": 1,
"found": true,
"_source": {
"id": 12469,
"nickname": "Roger",
"first_name": "Moore",
"last_name": "Bond",
"companyName": null,
"email": "example#example.org",
"city": "Marseille",
"region": "Provence-Alpes-Côte d'Azur",
"internalGlobalRating": 5,
"declaredDailyPrice": 650,
"declaredAnnualSalaryTarget": null,
"boughtDailyPrice": null,
"soldDailyPrice": null,
"skillsRatings": [
{
"skillName": "Direction Artistique Web",
"skillId": 1298,
"rating": 9
},
{
"skillName": "UX Design",
"skillId": 1295,
"rating": 9
},
{
"skillName": "Identité Visuelle",
"skillId": 1319,
"rating": 8
},
{
"skillName": "Illustrator",
"skillId": 1425,
"rating": 9
},
{
"skillName": "Photoshop",
"skillId": 1427,
"rating": 9
},
{
"skillName": "InDesign",
"skillId": 1426,
"rating": 9
}
],
"expertises": [
{
"name": "Direction Artistique Web",
"id": 1298
},
{
"name": "UX Design",
"id": 1295
},
{
"name": "Identité Visuelle",
"id": 1319
}
],
"missionTypes": [
{
"name": "Freelance sur place",
"id": 2
},
{
"name": "Freelance en télétravail",
"id": 3
},
{
"name": "Forfait",
"id": 4
}
],
"tools": [
{
"name": "Illustrator",
"id": 1425
},
{
"name": "Photoshop",
"id": 1427
},
{
"name": "InDesign",
"id": 1426
}
],
"themes": [],
"medias": [],
"organizationType": {
"id": 2,
"name": "Studio"
},
"source": {
"id": 2
},
"spokenLanguages": [
{
"id": 2
},
{
"id": 3
}
],
"mainLanguage": {
"id": 1,
"name": "Français"
}
"created": "2011-10-05T20:17:52+02:00",
"updated": "2017-07-03T15:59:11+02:00",
"applicationDate": "2011-10-05T20:17:52+02:00",
"portfolio": {
"id": 95,
"visible": true,
"submissionTime": "2017-01-13T18:20:31+01:00",
"isDisplayed": 1,
"isPublic": 1
}
}
}
I wonder which approach I should choose : tweak at index time or custom queries, or both ?
Any clue on how to tackle this problem would be appreciated.
Thank you.

How to get Order and OrderLineItem for a transaction using Connect V2?

I am writing a wrapper to retrive transaction data for the Square Connect API V2. I am able to retrive the trasactions with Order data missing.
I am getting following response using All Transaction and Retrieve Transaction API:
{
"transactions": [
{
"id": "mYziFkYv2QK7e2kb2vyIhegeV",
"location_id": "75S3K9Z9KSVYK",
"created_at": "2017-04-17T11:00:51Z",
"tenders": [
{
"id": "2qeDw6CmCs299m9w0RY7KQB",
"location_id": "75S3K9Z9KSVYK",
"transaction_id": "mYziFkYv2QK7e2kb2vyIhegeV",
"created_at": "2017-04-17T11:00:51Z",
"amount_money": {
"amount": 10000,
"currency": "INR"
},
"processing_fee_money": {
"amount": 0,
"currency": "INR"
},
"type": "OTHER"
}
],
"product": "REGISTER",
"client_id": "75S3K9Z9KSVYK-a776-4377-84f5-75S3K9Z9KSVYK"
},
{
"id": "UJsg9IdIv9WWvqT1h2VkbxgeV",
"location_id": "75S3K9Z9KSVYK",
"created_at": "2017-04-17T11:00:37Z",
"tenders": [
{
"id": "UVuQghb8RTF8OUcmAsaXKQB",
"location_id": "75S3K9Z9KSVYK",
"transaction_id": "UJsg9IdIv9WWvqT1h2VkbxgeV",
"created_at": "2017-04-17T11:00:37Z",
"amount_money": {
"amount": 0,
"currency": "INR"
},
"processing_fee_money": {
"amount": 0,
"currency": "INR"
},
"type": "NO_SALE"
}
],
"product": "REGISTER",
"client_id": "75S3K9Z9KSVYK-a751-4434-a041-75S3K9Z9KSVYK"
}
]}
Is there any way to get order (line item) details?
If you are looking for itemizations, you can use the v1 transactions endpoints.
See here: https://docs.connect.squareup.com/api/connect/v1/#get-paymentid

Resources