How to make a payment with square from Dart code in flutter? - api

I need make payments with square, I used square_in_app_payments plugin but it only give me a nonce string that seems I have to send it to checkout api with items information inside JSON in http request, but I don't understand how to make it.
I only tried from postman make some samples fo square.
POST /v2/locations/{{location_id}}/checkouts HTTP/1.1
Host: connect.squareup.com
Authorization: Bearer {{access_token}}
Content-Type: application/json
cache-control: no-cache
Postman-Token: 5d2c05ae-11d6-42bd-bd1e-47fa44621a98
{
"idempotency_key": "60f919ba-2042-4402-bc66-e6455ec32349",
"order": {
"reference_id": "reference_id",
"line_items": [
{
"name": "Printed T Shirt",
"quantity": "2",
"base_price_money": {
"amount": 1500,
"currency": "USD"
},
"discounts": [
{
"name": "7% off previous season item",
"percentage": "7"
},
{
"name": "$3 off Customer Discount",
"amount_money": {
"amount": 300,
"currency": "USD"
}
}
]
},
{
"name": "Slim Jeans",
"quantity": "1",
"base_price_money": {
"amount": 2500,
"currency": "USD"
}
},
{
"name": "Woven Sweater",
"quantity": "3",
"base_price_money": {
"amount": 3500,
"currency": "USD"
},
"discounts": [
{
"name": "$11 off Customer Discount",
"amount_money": {
"amount": 1100,
"currency": "USD"
}
}
],
"taxes": [
{
"name": "Fair Trade Tax",
"percentage": "5"
}
]
}
],
"discounts": [
{
"name": "Father's day 12% OFF",
"percentage": "12"
},
{
"name": "Global Sales $55 OFF",
"amount_money": {
"amount": 5500,
"currency": "USD"
}
}
],
"taxes": [
{
"name": "Sales Tax",
"percentage": "8.5"
}
]
},
"ask_for_shipping_address": true,
"merchant_support_email": "merchant+support#website.com",
"pre_populate_buyer_email": "example#email.com",
"pre_populate_shipping_address": {
"address_line_1": "1455 Market St.",
"address_line_2": "Suite 600",
"locality": "San Francisco",
"administrative_district_level_1": "CA",
"postal_code": "94103",
"country": "US",
"first_name": "Jane",
"last_name": "Doe"
}
}
I need to know how to take the nonce string from card form of square_in_app_payments plugin and send it in http request for complete the payment.

Related

QuickBooks Online API - Sales tax: trying to override automatic sales tax, but it's not respecting my inputs

QBOnline API: Problems with overriding Sales Tax - passed in values not respected on Invoice (AST seems to override my override)
Hi all,
Yes, I'm new to the API. Diving in head first! :)
I'm trying to troubleshoot a problem with my app. It's submitting new Invoices to the QBOnline API, and passing in all the line item information. We aren't trying to use the AST system - so I was trying to set the override values. (Documentation: https://developer.intuit.com/app/developer/qbo/docs/workflows/manage-sales-tax-for-us-locales#specifying-sales-tax)
I think that I am providing the values correctly, but the system is still calculating it's own sales tax amount.
Target API URL:
https://sandbox-quickbooks.api.intuit.com/v3/company/4620816365232674520/Invoice?minorversion=4
Here's an example of the object we are passing in (edited for privacy, expanded for human readability):
{
"BillAddr": {
"City": "AnywhereVille",
"Country": "USA",
"CountrySubDivisionCode": "CA",
"Line1": "",
"Line2": "Customer Name LLP",
"Line3": "45 E. Pacific Coast Highway",
"Line4": "",
"PostalCode": "90804"
},
"CustomField": [{
"DefinitionId": "1",
"Name": "P.O. Number",
"StringValue": "",
"Type": "StringType"
}, {
"DefinitionId": "2",
"Name": "Sales Rep",
"StringValue": "TY",
"Type": "StringType"
}],
"CustomerMemo": {
"value": "Pay your invoice online at: ..."
},
"CustomerRef": {
"value": "60"
},
"DocNumber": "11111",
"DueDate": "2022-08-01",
"Line": [{
"Amount": 576,
"Description": "",
"DetailType": "SalesItemLineDetail",
"LineNum": 1,
"SalesItemLineDetail": {
"ClassRef": {
"name": "3 Studios",
"value": "1111111111111"
},
"ItemRef": {
"name": "16GBUSBFLASH",
"value": "21"
},
"Qty": 48,
"TaxCodeRef": {
"value": "TAX"
},
"UnitPrice": 12
}
}, {
"Amount": 168,
"Description": "",
"DetailType": "SalesItemLineDetail",
"LineNum": 4,
"SalesItemLineDetail": {
"ClassRef": {
"name": "3 Studios",
"value": "1111111111111"
},
"ItemRef": {
"name": "DVDMEDIA",
"value": "23"
},
"Qty": 12,
"TaxCodeRef": {
"value": "TAX"
},
"UnitPrice": 14
}
}, {
"Amount": 600,
"Description": "",
"DetailType": "SalesItemLineDetail",
"LineNum": 6,
"SalesItemLineDetail": {
"ClassRef": {
"name": "3 Studios",
"value": "1111111111111"
},
"ItemRef": {
"name": "DIGITALDEL30",
"value": "25"
},
"Qty": 12,
"TaxCodeRef": {
"value": "TAX"
},
"UnitPrice": 50
}
}],
"SalesTermRef": {
"value": "8"
},
"TxnDate": "2022-08-01",
"TxnTaxDetail": {
"TaxLine": [{
"Amount": 130.98,
"DetailType": "TaxLineDetail",
"TaxLineDetail": {
"NetAmountTaxable": 576,
"PercentBased": true,
"TaxPercent": 0.0925,
"TaxRateRef": {
"value": "4"
}
}
}],
"TotalTax": 130.98,
"TxnTaxCodeRef": {
"value": "4"
}
}
}

Amadeus Flight Offers Different Prices

We're using flight offers search api and ready to move to prod. But when we search flights with ECONOMY class the prices are not even close to "amadeus.net" search engine results or TK (Turkish Airlines) web site prices. If we use BUSINESS class as a parameter the api results are closer to real prices. How can we solve this issue?
The sample query is: (IST - CGN 25th May ECONOMY and TK Opearated flight departures 16:05 )
/v2/shopping/flight-offers?originLocationCode=IST&destinationLocationCode=CGN&departureDate=2021-05-25&adults=1&travelClass=ECONOMY&includedAirlineCodes=TK&nonStop=true&max=250
The api result is: €206.55
TK Web Site: €121
Amadeus.net €103
Detailed API result:
{
"meta": {
"count": 2,
"links": {
"self": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=IST&destinationLocationCode=CGN&departureDate=2021-05-25&adults=1&travelClass=ECONOMY&includedAirlineCodes=TK&nonStop=true&max=250"
}
},
"data": [
{
"type": "flight-offer",
"id": "2",
"source": "GDS",
"instantTicketingRequired": false,
"nonHomogeneous": false,
"oneWay": false,
"lastTicketingDate": "2021-05-25",
"numberOfBookableSeats": 9,
"itineraries": [
{
"duration": "PT3H20M",
"segments": [
{
"departure": {
"iataCode": "IST",
"at": "2021-05-25T16:05:00"
},
"arrival": {
"iataCode": "CGN",
"terminal": "2",
"at": "2021-05-25T18:25:00"
},
"carrierCode": "TK",
"number": "1675",
"aircraft": {
"code": "321"
},
"operating": {
"carrierCode": "TK"
},
"duration": "PT3H20M",
"id": "2",
"numberOfStops": 0,
"blacklistedInEU": false
}
]
}
],
"price": {
"currency": "EUR",
"total": "206.55",
"base": "134.00",
"fees": [
{
"amount": "0.00",
"type": "SUPPLIER"
},
{
"amount": "0.00",
"type": "TICKETING"
}
],
"grandTotal": "206.55"
},
"pricingOptions": {
"fareType": [
"PUBLISHED"
],
"includedCheckedBagsOnly": true
},
"validatingAirlineCodes": [
"TK"
],
"travelerPricings": [
{
"travelerId": "1",
"fareOption": "STANDARD",
"travelerType": "ADULT",
"price": {
"currency": "EUR",
"total": "206.55",
"base": "134.00"
},
"fareDetailsBySegment": [
{
"segmentId": "2",
"cabin": "ECONOMY",
"fareBasis": "QT2PXOW",
"class": "Q",
"includedCheckedBags": {
"weight": 30,
"weightUnit": "KG"
}
}
]
}
]
}
],
"dictionaries": {
"locations": {
"SAW": {
"cityCode": "IST",
"countryCode": "TR"
},
"CGN": {
"cityCode": "CGN",
"countryCode": "DE"
},
"IST": {
"cityCode": "IST",
"countryCode": "TR"
}
},
"aircraft": {
"321": "AIRBUS A321",
"738": "BOEING 737-800"
},
"currencies": {
"EUR": "EURO"
},
"carriers": {
"TK": "TURKISH AIRLINES"
}
}
}
Thanks in advance
There are two reasons why you see different prices:
The Self-Service APIs return published airfares coming from the GDS and not any negotiated ones. That means the flights returned by the APIs can be more expensive than the ones you find in OTAs or airline websites.
In the test environment that you are using, you get access to cached flight data which might be different from the live prices.

Square API: Object version does not match latest database version

I'm trying to use the following Square API endpoint to update an item, but I'm getting some errors. Here is the item that I'm trying to update.
{
"type": "ITEM",
"id": "7HXK6NVBDKSOK64CCAYZJ2KW",
"updated_at": "2020-08-08T21:43:41.849Z",
"version": 1596923021849,
"is_deleted": false,
"present_at_all_locations": false,
"present_at_location_ids": [
"1JZ5JTPBW0EXY"
],
"item_data": {
"name": "Hummus Plate",
"description": "Olives, feta, tomatoes, tzatziki and warm pita.",
"visibility": "PRIVATE",
"category_id": "ARB5LTTDUSER6T66ZWYO65FL",
"variations": [
{
"type": "ITEM_VARIATION",
"id": "HBIHPLROOJUUNUSW3BZUDQ5J",
"updated_at": "2020-08-08T21:40:14.581Z",
"version": 1596922814581,
"is_deleted": false,
"present_at_all_locations": false,
"present_at_location_ids": [
"1JZ5JTPBW0EXY"
],
"item_variation_data": {
"item_id": "7HXK6NVBDKSOK64CCAYZJ2KW",
"name": "Regular",
"ordinal": 0,
"pricing_type": "FIXED_PRICING",
"price_money": {
"amount": 1000,
"currency": "USD"
}
}
}
],
"product_type": "REGULAR",
"skip_modifier_screen": true,
"ecom_available": false,
"ecom_visibility": "UNINDEXED"
}
}
Here the body content.
{
"batches": [{
"objects": [{
"type": "ITEM_VARIATION",
"id": "T6KKCATDIU2VV4BDBMVGML4W",
"item_variation_data": {
"item_id": "FNWWGFTBQWFAYK6JGBD3LDLD",
"pricing_type": "FIXED_PRICING",
"price_money": {
"amount": 150,
"currency": "USD"
}
}
}]
}],
"idempotency_key": "61994762-3a6s-4b75-sf81-fdfaf"
}
Here is the error I'm getting:
**{
"errors": [
{
"category": "INVALID_REQUEST_ERROR",
"code": "VERSION_MISMATCH",
"detail": "Object version does not match latest database version.",
"field": "version"
}
]
}**
I'm not sure what I'm doing wrong, but I appreciate any help I can get. Thank you in advance!
When updating a catalog object in Square, you need to provide the latest version number in the request.
{
"batches": [{
"objects": [{
"type": "ITEM_VARIATION",
"id": "T6KKCATDIU2VV4BDBMVGML4W",
"version": "12345",
"item_variation_data": {
"item_id": "FNWWGFTBQWFAYK6JGBD3LDLD",
"pricing_type": "FIXED_PRICING",
"price_money": {
"amount": 150,
"currency": "USD"
}
}
}]
}],
"idempotency_key": "61994762-3a6s-4b75-sf81-fdfaf"
}

extra bag information is missing in the flight offer price response

I'm testing self-service APIs. I wonder if this is a bug:
I make a search request, and the response contains the extra bag information in the flight-offer/price/additionalServices
Then I make the offer price request by adding include=bags parameter in the path of Flight Offers Price API.
However there is no any bags information in the response, neither in the offer/price/additionalServices, nor in the included/.
I still try to create order by adding the extra bag. So I use the extra bag information that I got at step 1 (search response). And the order is created successfully.
It seems that the extra bag information is missing in step 2 (response of flight offer price), is it a bug?
Here is an example of my test to reproduce the issue:
search request
{
"currencyCode": "EUR",
"originDestinations": [
{
"id": "1",
"originLocationCode": "PAR",
"destinationLocationCode": "NYC",
"departureDateTimeRange": {
"date": "2020-08-20",
"time": "10:00:00"
}
}
],
"travelers": [
{
"id": "1",
"travelerType": "ADULT"
}
],
"sources": [
"GDS"
],
"searchCriteria": {
"maxFlightOffers": 3
}
}
Then I select the second offer in the response to make a offer price request using include=bags parameter
{
"type": "flight-offer",
"id": "2",
"source": "GDS",
"instantTicketingRequired": false,
"nonHomogeneous": false,
"oneWay": false,
"lastTicketingDate": "2020-08-13",
"numberOfBookableSeats": 8,
"itineraries": [
{
"duration": "PT8H15M",
"segments": [
{
"departure": {
"iataCode": "ORY",
"terminal": "4",
"at": "2020-08-20T19:45:00"
},
"arrival": {
"iataCode": "EWR",
"terminal": "B",
"at": "2020-08-20T22:00:00"
},
"carrierCode": "TX",
"number": "6720",
"aircraft": {
"code": "359"
},
"operating": {
"carrierCode": "BF"
},
"duration": "PT8H15M",
"id": "3",
"numberOfStops": 0,
"blacklistedInEU": false
}
]
}
],
"price": {
"currency": "EUR",
"total": "149.44",
"base": "41.00",
"fees": [
{
"amount": "0.00",
"type": "SUPPLIER"
},
{
"amount": "0.00",
"type": "TICKETING"
}
],
"grandTotal": "149.44",
"additionalServices": [
{
"amount": "70.00",
"type": "CHECKED_BAGS"
}
]
},
"pricingOptions": {
"fareType": [
"PUBLISHED"
],
"includedCheckedBagsOnly": false
},
"validatingAirlineCodes": [
"TX"
],
"travelerPricings": [
{
"travelerId": "1",
"fareOption": "STANDARD",
"travelerType": "ADULT",
"price": {
"currency": "EUR",
"total": "149.44",
"base": "41.00"
},
"fareDetailsBySegment": [
{
"segmentId": "3",
"cabin": "ECONOMY",
"fareBasis": "ULBCOWFR",
"brandedFare": "EBASIC",
"class": "U",
"includedCheckedBags": {
"quantity": 0
}
}
]
}
]
}
There is no extra bag in the response.
Thanks

Square API - The payment total does not match the order total. It does

First off, I created an order and doing an order search, the string below shows the order details from the response.
Next, I used the API Explorers for Payments->CreatePayment:
https://developer.squareup.com/reference/square/payments-api/create-payment/explorer
I put in my sandbox Access Token at the top.
As for the other info I entered, please refer to the Request String:
curl https://connect.squareup.com/v2/payments \
-X POST \
-H 'Content-Type: application/json' \
-H 'Square-Version: 2020-01-22' \
-H 'Authorization: Bearer {{access_token}}' \
-d '{
"source_id": "cnon:CBASEBbXLsTfPIy04J18kMjfbRo",
"idempotency_key": "5e42534d06257",
"location_id": "DWK1VQ391ZARF",
"order_id": "fQZM8ekWkcAo7fRRBvUj2G2pY5EZY",
"amount_money": {
"amount": 3649,
"currency": "USD"
}
}'
Here is the Order Details:
{
"id": "fQZM8ekWkcAo7fRRBvUj2G2pY5EZY",
"location_id": "DWK1VQ391ZARF",
"line_items": [
{
"uid": "iLVwmNInonSV2Twc9G84fD",
"catalog_object_id": "B57CGCIAGUTLBQMAMEEI5WBC",
"quantity": "1",
"name": "Athletic Heather Pullover Hooded Sweatshirt",
"variation_name": "X-Large",
"base_price_money": {
"amount": 2699,
"currency": "USD"
},
"taxes": [
{
"uid": "f9euLpXOOEWKd2bV7AgOdD",
"name": "Sales Tax",
"percentage": "9.0",
"type": "ADDITIVE",
"applied_money": {
"amount": 243,
"currency": "USD"
},
"scope": "LINE_ITEM"
}
],
"gross_sales_money": {
"amount": 2699,
"currency": "USD"
},
"total_tax_money": {
"amount": 243,
"currency": "USD"
},
"total_discount_money": {
"amount": 0,
"currency": "USD"
},
"total_money": {
"amount": 2942,
"currency": "USD"
},
"variation_total_price_money": {
"amount": 2699,
"currency": "USD"
},
"applied_taxes": [
{
"uid": "f9euLpXOOEWKd2bV7AgOdD",
"tax_uid": "f9euLpXOOEWKd2bV7AgOdD",
"applied_money": {
"amount": 243,
"currency": "USD"
}
}
]
},
{
"uid": "dQS0tXEW46ERhQlLdPAxgC",
"catalog_object_id": "PY7V64HVFKSE6O7SW6RBQZ7U",
"quantity": "1",
"name": "2nd Amendment",
"variation_name": "Small Print",
"base_price_money": {
"amount": 300,
"currency": "USD"
},
"taxes": [
{
"uid": "RAD93NhnUa9E6XBy7NYWG",
"name": "Sales Tax",
"percentage": "9.0",
"type": "ADDITIVE",
"applied_money": {
"amount": 27,
"currency": "USD"
},
"scope": "LINE_ITEM"
}
],
"gross_sales_money": {
"amount": 300,
"currency": "USD"
},
"total_tax_money": {
"amount": 27,
"currency": "USD"
},
"total_discount_money": {
"amount": 0,
"currency": "USD"
},
"total_money": {
"amount": 327,
"currency": "USD"
},
"variation_total_price_money": {
"amount": 300,
"currency": "USD"
},
"applied_taxes": [
{
"uid": "RAD93NhnUa9E6XBy7NYWG",
"tax_uid": "RAD93NhnUa9E6XBy7NYWG",
"applied_money": {
"amount": 27,
"currency": "USD"
}
}
]
},
{
"uid": "mIae9M46tMvTCpzgNvyNW",
"catalog_object_id": "Q4OPKIJ2BMG5LY35SUMHFG7S",
"quantity": "1",
"name": "2nd Amendment",
"variation_name": "Large",
"base_price_money": {
"amount": 0,
"currency": "USD"
},
"taxes": [
{
"uid": "IFLJKtYmIiEvXTLZ5FLaJD",
"name": "Sales Tax",
"percentage": "9.0",
"type": "ADDITIVE",
"applied_money": {
"amount": 0,
"currency": "USD"
},
"scope": "LINE_ITEM"
}
],
"gross_sales_money": {
"amount": 0,
"currency": "USD"
},
"total_tax_money": {
"amount": 0,
"currency": "USD"
},
"total_discount_money": {
"amount": 0,
"currency": "USD"
},
"total_money": {
"amount": 0,
"currency": "USD"
},
"variation_total_price_money": {
"amount": 0,
"currency": "USD"
},
"applied_taxes": [
{
"uid": "IFLJKtYmIiEvXTLZ5FLaJD",
"tax_uid": "IFLJKtYmIiEvXTLZ5FLaJD",
"applied_money": {
"amount": 0,
"currency": "USD"
}
}
]
},
{
"uid": "w3HK68X6MEpXHIxQDyTZ5",
"quantity": "1",
"name": "Shipping",
"base_price_money": {
"amount": 380,
"currency": "USD"
},
"gross_sales_money": {
"amount": 380,
"currency": "USD"
},
"total_tax_money": {
"amount": 0,
"currency": "USD"
},
"total_discount_money": {
"amount": 0,
"currency": "USD"
},
"total_money": {
"amount": 380,
"currency": "USD"
},
"variation_total_price_money": {
"amount": 380,
"currency": "USD"
}
}
],
"taxes": [
{
"uid": "IFLJKtYmIiEvXTLZ5FLaJD",
"name": "Sales Tax",
"percentage": "9.0",
"type": "ADDITIVE",
"applied_money": {
"amount": 0,
"currency": "USD"
},
"scope": "LINE_ITEM"
},
{
"uid": "RAD93NhnUa9E6XBy7NYWG",
"name": "Sales Tax",
"percentage": "9.0",
"type": "ADDITIVE",
"applied_money": {
"amount": 27,
"currency": "USD"
},
"scope": "LINE_ITEM"
},
{
"uid": "f9euLpXOOEWKd2bV7AgOdD",
"name": "Sales Tax",
"percentage": "9.0",
"type": "ADDITIVE",
"applied_money": {
"amount": 243,
"currency": "USD"
},
"scope": "LINE_ITEM"
}
],
"created_at": "2020-02-11T07:46:54.962Z",
"updated_at": "2020-02-11T07:46:54.962Z",
"state": "OPEN",
"version": 1,
"total_tax_money": {
"amount": 270,
"currency": "USD"
},
"total_discount_money": {
"amount": 0,
"currency": "USD"
},
"total_tip_money": {
"amount": 0,
"currency": "USD"
},
"total_money": {
"amount": 3649,
"currency": "USD"
},
"total_service_charge_money": {
"amount": 0,
"currency": "USD"
},
"net_amounts": {
"total_money": {
"amount": 3649,
"currency": "USD"
},
"tax_money": {
"amount": 270,
"currency": "USD"
},
"discount_money": {
"amount": 0,
"currency": "USD"
},
"tip_money": {
"amount": 0,
"currency": "USD"
},
"service_charge_money": {
"amount": 0,
"currency": "USD"
}
},
"source": {
"name": "Sandbox for sq0idp-0WcmbRcdTbsMGg5UjGvifQ"
}
}
Please note the order_id and location_id both match what's in the order details. What also matches is the amount entered in the create payment request and the total_money in the order details: 3649.
So then why do I get the following response for the Create Payment request?
cache-control: no-cache
content-length: 136
content-type: application/json
date: Tue, 11 Feb 2020 07:48:48 GMT
square-version: 2020-01-22
{
"errors": [
{
"code": "BAD_REQUEST",
"detail": "The payment total does not match the order total.",
"category": "INVALID_REQUEST_ERROR"
}
]
}
Using Square API v2.