How to make a payment on quickbooks using QB online - node.js

I am able to create invoice on the quickbooks. But I need to set the payment as paid and set the payment option as credit card for a particular invoice. Here is the payment object.
{
"TotalAmt": 25.0,
"CustomerRef": {
"value": "20"
}
}
But there is no option to set the invoice Id here or the card option. Here is the reference

Example copy/pasted from the reference you linked to in your post:
{
"TxnDate": "2015-01-16",
"TotalAmt": 65.0,
"Line": [
{
"Amount": 55.0,
"LinkedTxn": [
{
"TxnId": "70",
"TxnType": "Invoice"
}
]
}
],
"CustomerRef": {
"name": "Red Rock Diner",
"value": "20"
}
}

Related

Admin-graphql - Create private metafield on shopify

How do I create a private metafield on Shopify using Admin-graphql? In their docs, they have given example for retrieving a private metafield by its ID(ref: https://shopify.dev/api/admin-graphql/2022-01/queries/privateMetafield#section-examples), do you have any example for creating private metafield using Node.js?
I use https://www.npmjs.com/package/shopify-api-node, it has support for GraphQL calls. https://insomnia.rest/ has great GraphQL support, with field hinting, query eval etc.
An example of creating a product with a private metafield:
mutation productCreate($input: ProductInput!, $namespace: String!) {
productCreate(input: $input) {
product {
id
bufferProductId: privateMetafield(
key: "your_field_key"
namespace: $namespace
) {
value
}
tags
variants(first: 10) {
edges {
node {
id
sku
}
}
}
}
userErrors {
field
message
}
}
}
You need to pass these variables to the GraphQL query:
{
"input": {
"title": "Your product name",
"options": [
"Size",
"Colour"
],
"handle": "your-product-name",
"tags": [
"Product tag"
],
"vendor": "Lauri's sportin' goods",
"variants": [
{
"sku": "ABC123XL",
"options": [
"Large",
"Blue"
]
},
{
"sku": "ABC123L",
"options": [
"Large",
"Yellow"
]
}
],
"privateMetafields": [
{
"key": "your_field_key",
"namespace": "your_namespace",
"valueInput": {
"value": "Your field value",
"valueType": "STRING"
}
}
]
},
"namespace": "your_namespace"
}
This will return the private metafield value in the product creation response.
A few things that make private metafields different from public ones:
you can add / update the private metafield over and over using ProductUpdate, whereas
you can only access the private metafields through GraphQL. AFAIK, they're not visible anywhere in the Shopify Admin, or using the REST API.
even with GraphQL, those fields will be visible only to the API key that created them. So, you won't see them with another Shopify App.
You can use these field types to set the private metafield values.

Shopware 6 API: Update an existing product without stock or price

It is very common that the stock entries of a product are updated in the shop by a different ERP system than the system that updates the product information (number, properties, etc.). Shopware 6 does not seem to support this method and throws the error seen below.
I do understand that for the initial creation of a product there are some required fields like productNumber or stock but when updating an already existing product, it should be totally fine to leave those values out, so that they can be updated by an external system.
This worked in Shopware 5 but not in Shopware 6. Does anyone know a workaround?
(I am thinking about sending the existing value from Shopware because then it is technically not updated but that is my last resort.)
Array
(
[code] => c1051bb4-d103-4f74-8988-acbcafc7fdc3
[status] => 400
[detail] => This value should not be blank.
[template] => This value should not be blank.
[meta] => Array
(
[parameters] => Array
(
[{{ value }}] => null
)
)
[source] => Array
(
[pointer] => /0/stock
)
)
Full example for a request payload
{
"newData": {
"action": "upsert",
"entity": "product",
"payload": [
{
"id": "206c59a3339383101655aae7598e328c",
"language": "default",
"taxId": "6460303d84264f36858d1fe9e8c2f60f",
"name": "SLT 95 Nano Crystal",
"active": true,
"visibilities": [
{
"id": "d43840cff1b2bcc741a9a83ebb5b3c16",
"salesChannelId": "e8d8fd2337dd42e0a86b47ea68739824",
"visibility": 30
}
],
"categories": [
{
"id": "66ca2d80dc532d4d6659b4430e6954a8"
}
],
"description": "A not so much very short text. Another short text.",
"price": [
{
"net": 9999.99,
"gross": 9999.99,
"linked": true,
"currencyId": "b7d2554b0ce847cd82f3ac9bd1c0dfca"
}
],
"productNumber": "P_10254",
"crossSellings": [
{
"id": "b3e3171397d30794171877fed2329d96",
"name": "Similar Products",
"assignedProducts": [],
"type": "productList",
"active": true,
"sortBy": "name",
"sortDirection": "ASC",
"limit": 24,
"position": 1
}
]
}
]
}
}
Short example for a request payload
"payload": [
{
"id": "206c59a3339383101655aae7598e328c",
"language": "default",
"taxId": "6460303d84264f36858d1fe9e8c2f60f",
"name": "SLT 95 Nano Crystal",
"active": true,
...
}
]
I simply do not send the stock for a normal product upsert in hopes that Shopware uses the already existing stock.
With the version "v6.4.4.1 Stable Version" Shopware introduced a concept change which allows you to update existing products without having to send all required fields.
This solves this issue and is very useful if for example the stocks shall be maintained by hand and not be controlled by the API calls.

Paypal not charging the customer after the trail ends

I am making paypal subscription plans. I am facing two problems. First, Is there a way to make a plan without trial period? Second, Paypal is not charging customer after trial period ends.
let body = {
"product_id": "PROD-81J67779NH423045A",
"name": obj.pname,
"description": obj.description,
"billing_cycles": [
{
"frequency": {
"interval_unit": "DAY",
"interval_count": 1
},
"tenure_type": "TRIAL",
"sequence": 1,
"total_cycles": 1
},
{
"frequency": {
"interval_unit": obj.duration,
"interval_count": 1
},
"tenure_type": "REGULAR",
"sequence": 2,
"total_cycles": 12,
"pricing_scheme": {
"fixed_price": {
"value": obj.price,
"currency_code": "USD"
}
}
}
],
"payment_preferences": {
"service_type": "PREPAID",
"auto_bill_outstanding": true,
"setup_fee": {
"value": obj.price,
"currency_code": "USD"
},
"setup_fee_failure_action": "CONTINUE",
"payment_failure_threshold": 3
},
"quantity_supported": true,
"taxes": {
"percentage": obj.tax,
"inclusive": false
}
}
You can have a plan without a TRIAL period.
Remove that whole block, and have the REGULAR one be sequence: 1.
As for it 'not charging', you probably haven't waited enough 24 hour cycles for it to kick in. Subscriptions bill in a batch, and so it can take some portion of the day for the initial non-billing trial period to even start, and then a day for that to run.

ElasticSearch: Suggestion Completion Multi Search

I am using the suggestion api within ES with completion. My implementation works (code below) but I would like to search for multiple words within a query. In the example below if I query search "word" it finds "wordpress" and outputs "Found". What I am am trying to accomplish is querying with something like "word blog magazine" which are all tags and have an output of "Found". Any help would be appreciated!
Mapping:
curl -XPUT "http://localhost:9200/test_index/" -d'
{
"mappings": {
"product": {
"properties": {
"description": {
"type": "string"
},
"tags": {
"type": "string"
},
"title": {
"type": "string"
},
"tag_suggest": {
"type": "completion",
"index_analyzer": "simple",
"search_analyzer": "simple",
"payloads": false
}
}
}
}
}'
Add document:
curl -XPUT "http://localhost:9200/test_index/product/1" -d'
{
"title": "Product1",
"description": "Product1 Description",
"tags": [
"blog",
"magazine",
"responsive",
"two columns",
"wordpress"
],
"tag_suggest": {
"input": [
"blog",
"magazine",
"responsive",
"two columns",
"wordpress"
],
"output": "Found"
}
}'
_suggest query:
curl -XPOST "http://localhost:9200/test_index/_suggest" -d'
{
"product_suggest":{
"text":"word",
"completion": {
"field" : "tag_suggest"
}
}
}'
The results are as we would expect:
{
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"product_suggest": [
{
"text": "word",
"offset": 0,
"length": 4,
"options": [
{
"text": "Found",
"score": 1
},
]
}
]
}
If you're willing to switch to using edge ngrams (or full ngrams if you need them), I think it will solve your problem.
I wrote up a pretty detailed explanation of how to do this in this blog post:
https://qbox.io/blog/an-introduction-to-ngrams-in-elasticsearch
But I'll give you a quick and dirty version here. The trick is to use ngrams together with the _all field and the match AND operator.
So with this mapping:
PUT /test_index
{
"settings": {
"analysis": {
"filter": {
"ngram_filter": {
"type": "edge_ngram",
"min_gram": 2,
"max_gram": 20
}
},
"analyzer": {
"ngram_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"ngram_filter"
]
}
}
}
},
"mappings": {
"doc": {
"_all": {
"type": "string",
"analyzer": "ngram_analyzer",
"search_analyzer": "standard"
},
"properties": {
"word": {
"type": "string",
"include_in_all": true
},
"definition": {
"type": "string",
"include_in_all": true
}
}
}
}
}
and some documents:
PUT /test_index/_bulk
{"index":{"_index":"test_index","_type":"doc","_id":1}}
{"word":"democracy", "definition":"government by the people; a form of government in which the supreme power is vested in the people and exercised directly by them or by their elected agents under a free electoral system."}
{"index":{"_index":"test_index","_type":"doc","_id":2}}
{"word":"republic", "definition":"a state in which the supreme power rests in the body of citizens entitled to vote and is exercised by representatives chosen directly or indirectly by them."}
{"index":{"_index":"test_index","_type":"doc","_id":3}}
{"word":"oligarchy", "definition":"a form of government in which all power is vested in a few persons or in a dominant class or clique; government by the few."}
{"index":{"_index":"test_index","_type":"doc","_id":4}}
{"word":"plutocracy", "definition":"the rule or power of wealth or of the wealthy."}
{"index":{"_index":"test_index","_type":"doc","_id":5}}
{"word":"theocracy", "definition":"a form of government in which God or a deity is recognized as the supreme civil ruler, the God's or deity's laws being interpreted by the ecclesiastical authorities."}
{"index":{"_index":"test_index","_type":"doc","_id":6}}
{"word":"monarchy", "definition":"a state or nation in which the supreme power is actually or nominally lodged in a monarch."}
{"index":{"_index":"test_index","_type":"doc","_id":7}}
{"word":"capitalism", "definition":"an economic system in which investment in and ownership of the means of production, distribution, and exchange of wealth is made and maintained chiefly by private individuals or corporations, especially as contrasted to cooperatively or state-owned means of wealth."}
{"index":{"_index":"test_index","_type":"doc","_id":8}}
{"word":"socialism", "definition":"a theory or system of social organization that advocates the vesting of the ownership and control of the means of production and distribution, of capital, land, etc., in the community as a whole."}
{"index":{"_index":"test_index","_type":"doc","_id":9}}
{"word":"communism", "definition":"a theory or system of social organization based on the holding of all property in common, actual ownership being ascribed to the community as a whole or to the state."}
{"index":{"_index":"test_index","_type":"doc","_id":10}}
{"word":"feudalism", "definition":"the feudal system, or its principles and practices."}
{"index":{"_index":"test_index","_type":"doc","_id":11}}
{"word":"monopoly", "definition":"exclusive control of a commodity or service in a particular market, or a control that makes possible the manipulation of prices."}
{"index":{"_index":"test_index","_type":"doc","_id":12}}
{"word":"oligopoly", "definition":"the market condition that exists when there are few sellers, as a result of which they can greatly influence price and other market factors."}
I can apply partial matching across both fields (would work with as many fields as you want) like this:
POST /test_index/_search
{
"query": {
"match": {
"_all": {
"query": "theo go",
"operator": "and"
}
}
}
}
which in this case, returns:
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.7601639,
"hits": [
{
"_index": "test_index",
"_type": "doc",
"_id": "5",
"_score": 0.7601639,
"_source": {
"word": "theocracy",
"definition": "a form of government in which God or a deity is recognized as the supreme civil ruler, the God's or deity's laws being interpreted by the ecclesiastical authorities."
}
}
]
}
}
Here is the code I used here (there's more in the blog post):
http://sense.qbox.io/gist/e4093c25a8257499f54ced5a09f35b1eb48e4e3c
Hope that helps.

How do I specify VAT in an order?

We're based in the EU. When we sell our digital products to private persons or companies without a VAT number, we have to charge them VAT (Value Added Tax). This is what I'm trying:
import stripe
stripe.api_key = 'sk_test_xxx'
stripe.api_version = '2015-10-16'
product = stripe.Product.create(
id='product',
name='Product',
shippable=False
)
sku = stripe.SKU.create(
product='product',
price=100,
currency='eur',
inventory={'type': 'infinite'}
)
customer = stripe.Customer.create(
email='customer#example.org',
description="Customer"
)
order = stripe.Order.create(
customer=customer.id,
currency='eur',
items=[
{
'type': 'sku',
'quantity': 5,
'parent': sku.id,
'amount': 500
},
{
'type': 'tax',
'description': "20% VAT",
'amount': 100
}
]
)
The Order creation call gives me:
stripe.error.InvalidRequestError: Request req_xxx: Items of type tax are not supported at order creation.
When I replace the last order creation call without the tax:
order = stripe.Order.create(
customer=customer.id,
currency='eur',
items=[
{
'type': 'sku',
'quantity': 5,
'parent': sku.id,
'amount': 500
}
]
)
I'm getting back these order['items']:
[
{
"amount": 500,
"currency": "eur",
"description": "Product",
"object": "order_item",
"parent": "sku_xxx",
"quantity": 5,
"type": "sku"
},
{
"amount": 0,
"currency": "eur",
"description": "Taxes (included)",
"object": "order_item",
"parent": null,
"quantity": null,
"type": "tax"
},
{
"amount": 0,
"currency": "eur",
"description": "Free shipping",
"object": "order_item",
"parent": "ship_free-shipping",
"quantity": null,
"type": "shipping"
}
]
However, an order does not allow updating the items field after the order has been created.
What's the correct and semantic way to add VAT to the order items?
I contacted Stripe support and this should now be possible in a private beta. You can ask Stripe to join the taxes beta.
After joining, you can access documentation here: https://stripe.com/docs/relay#shipping-and-taxes and here: https://stripe.com/docs/relay/dynamic-shipping-taxes#order-creation-event.
There will be an option in your Stripe dashboard (Relay settings) to specify a "dynamic" taxes webhook where Stripe sends an Order to, and your server should then respond with a Order Item containing a tax entry. The webhook is hit immediately after creating an Order.

Resources