How to create a refund on ShopifyAPI - shopify

I'm trying to create a refund using Shopify API with the details in the documentation here:
and this is the payload I'm sending:
{ currency: 'GBP',
notify: false,
refund_line_items:
[ { line_item_id: '<line-item-id>',
quantity: 1,
restock_type: 'no_restock' } ] }
But I get this error:
StatusCodeError: 422 - {"errors":{"refund_line_items.line_item":["can't be blank"]}}
But refund_line_items.line_item is not mentioned in the documentation. I have checked the and the line_item_id is correct (is the ID of the variation ID, not the product ID, but I have tried using SKU and product ID, same result)
Other response in SO infers that this is because the line_item_id is incorrect but that's not the case. Any suggestions would be much appreciated. Thanks!

Related

Query MongoDB Aggregation framework with Golang

I have in a collection stores , products and many prices (for store-products there are many prices) of the products in MongoDB
I have to find out min price from a product in a store in the last 30 days with the help of go
I have built the following aggregation pipeline
pipeline := []bson.M{
bson.D{
"$group", bson.D{
{
"_id", bson.D{
{
Key: "storeId",
Value: "$storeUd",
},
{
Key: "productId",
Value: "$productId",
},
},
},
minPrice : {
Key: "min",
Value: "$price",
},
},
} <---
}
But go compiler tell me in the line that I marked with an arrow (<---) there is a mistake
syntax error: unexpected newline in composite literal; possibly missing comma or }
I would like to calculate something like
select min(price)
from prices
group by storeId , productId
Please can you tell me what is wrong?
Thanks,
Aurel
I added }, but what I get you can see in the attached picture - the next declaration (var ... ) is in red ....

Query Loopring NFTs using the GraphQL "Playground"

Hello and thanks in advance for any help.
I would like to write a simple query to find out Loopring NFT (non-fungible token) data using the Loopring subgraph, given a user account number. (Note the account number is the Loopring address, similar to an Ethereum address, a hexadecimal as string type)
The subgraph playground for Loopring is here: https://thegraph.com/explorer/subgraph?id=7QP7oCLbEAjejkp7wSLTD1zbRMSiDydAmALksBB5E6i1&view=Playground
Here is my code:
query accountNFTSlotsQuery(
$skip:Int
$first:Int
$orderBy: AccountNFTSlot_orderBy
$orderDirection:OrderDirection
$where:AccountNFTSlot_filter
) {
accountNFTSlots(
skip : 0
first: 100
orderBy: createdAt
orderDirection: asc
where: {
account: "0x08F06d44D6D3e35a3790392571194d86090C863539277"
}
) {
id
account {
id
}
balance
nft {
id
nftType
nftID
mintedAt
}
}
}
The playground is returning...
{
"data": {
"accountNFTSlots": []
}
}
Which I interpret as returning NULL, or "no data found". For the address above, one can verify NFTs exist using lexplorer:
https://lexplorer.io/account/39277
Variations:
I have tried several accounts which I know have NFTs.
I have tried replacing the "account" string with an "id" in the 'where' filter thus:
where: {
id: 39277
}
Model:
I used this github repo as a model for my queries: https://github.com/fudgebucket27/Lexplorer/blob/master/Shared/Services/LoopringGraphQLService.cs

Razorpay response not sending Razorpay order_id

I am working on React Native Razorpay payment gateway integration.
I am using react-native-razorpay.
Code is below:-
Send Params are:-
var options = {
description: "Credits towards consultation",
image: "https://i.imgur.com/3g7nmJC.png",
currency: "INR",
key: "a-----b----ccc-dd",
amount: Math.round(Number(order_total).toFixed(2) * 100),
name: "Product",
prefill: {
email: email ? email : "v#razorpay.com",
contact: mobile ? mobile : "1111111111",
name:
firstname && lastname
? `${firstname} ${lastname}`
: "Razorpay Software"
},
theme: { color: theme.colors.primaryColor },
payment_capture: 1
};
Checkout Method:-
RazorpayCheckout.open(options)
.then(data => {
// handle success
console.log("payment success", data);
if (data && data.razorpay_payment_id) {
orderData.payment = data.razorpay_payment_id;
this.props.payMyOrder(orderData);
}
})
.catch(error => {
// handle failure
this.toast.show(error.description);
});
I am getting only razorpay_payment_id in response but, razorpay_payment_id and razorpay_signature are missing. Also, in Razorpay backend Razorpay Order Id and Order Id are missing.
hey as we can see in the above code options object that you are passing to the checkout you are not passing the order_id, you should pass the order_id as well. Since you are not passing the order_id the same is not getting returned to you after the payment is done. refer to the below link on how to create an order at your server-side.
https://razorpay.com/docs/api/orders/
if you pass the order_id in the request param to the checkout you'll get the order_id and signature as well in the payment response.
Please check the documentation we need to pass the order_id, here.
As per the documentation, once you pass the order_id, then only after payment successful razorpay returns the
razorpay_order_id,razorpay_payment_id and razorpay_signature.
After that you can compare the signature to get acknowledgement of payment success.
Just a note if your id is wrong your razorpaySignature too will not appear
Issue mostly will be because of invalid order Id, the order id received from Backend should be the one backend got from Razorpay.
Something like below should be used at your backend to generate order id (format of order id will be order_<some id>). You can get language based backend implementation at this link
var instance = new Razorpay({ key_id: 'YOUR_KEY_ID', key_secret: 'YOUR_SECRET' })
instance.orders.create({
amount: 50000,
currency: "INR",
receipt: "receipt#1",
notes: {
key1: "value3",
key2: "value2"
}
})

Create Shopify product with Variant SKU using API

I am trying to create Products on Shopify using the API,
In the CSV upload there is a field Variant SKU which sets the (default) product SKU, I can't seem to find the correct way to create a product along with this value?
I tried (python3);
import requests
import json
from config import SHOPIFY_URL
payload = {
'product': {
'title': 'Hello Product',
'variants': {
'option1': 'Primary',
'sku': 'hello-product'
}
}
}
requests.post(
f'{SHOPIFY_URL}/products.json',
headers = {'content-type': 'application/json'},
data=json.dumps(payload)
)
The product get created but the SKU doesn't.
The TL;DR of my question;
What to I need to pass to fill the Product CSV Upload file's field Variant SKU?
Update
Thanks to David Lazar's comments, I realized that I need to use a list of variants.
payload = {
'product': {
'title': 'Hello Product',
'variants': [
{
'option1': 'Primary',
'sku': 'hello-product'
}
]
}
}
This however creates the product with one variant using the passed SKU.However what I am looking is to create the Porduct with its own SKU, no variations for the product, just a SKU for the product.

In prebid.js, How do I set floor price for each bidder while sending request?

In DFP I'm able to set line item and key value pair to target bidders and price. In prebid.js how do I send floor price dynamically to each bidders while sending request?
I have searched in prebid site's and got one function pbjs.adserverTargeting() which returns following details during response:
{ "hb_bidder": "appnexus",
"hb_adid": "7a53a9d3",
"hb_pb: 1.0" }
Here hb_pb means floor price? If yes how can I sent those details during request?
pbjs.adserverTargeting() returns the ad server targeting constructed corresponding to the bids received from the exchanges.
According to the prebid docs only certain bidders allow for sending floor prices through their params, like for example rubicon(http://prebid.org/dev-docs/bidders.html#rubicon) which has an optional param "floor" where you can set the floor price.
hb_pb means Header Bidding Price Bucket which is different from Price Floor. A price floor is the lowest CPM price a bid will need to meet for each Prebid auction. It is a way of preventing low bids from winning your impressions. It also helps filter cheap ads that may be malicious in nature since bad actors don't spend too much on ads.
There are 2 ways o set a price floor.
From your ad server - If you use GAM as your ad server, you can do this by going into inventory/pricing rules/New unified price rules. The rest is self-explanatory. You can set a price floor for the device, placement, or bidder.
From the bidder's dashboard - Most bidders let you set a price floor from the dashboard. Those who don't can usually do it for you if you reach out to them.
As far as I know, it depends on the bidders you're working with. Because there are some bidders who don't allow the passing of floor price in the parameters.
If your bidder partners support floor price, then the bidder parameter consists of "bidFloor" i.e. that represents the floor value. Some of the bidders pass floor price via "floorPriceMap"
hb_pb is just a bidder-key that is used to target the line items in the Google Ad Manager. It doesn't mean floor price. If you've integrated Prebid without any header bidding service provider, you can get it from the bidder partners. In case, if you have a provider, then they provide this data which has to be used in the "Targeting section" under Line items settings in Google Ad Manager.
floors: {
currency: 'USD',
schema: {
fields: [ 'mediaType' ]
},
values: [
{key: 'banner', floor: 1.10},
{key: 'video', floor: 2.00}
]
},
If the ad slots are controlled by Google Publisher Tags, then you can take a hint from the following code:
pbjs.setConfig({
floors: {
data: {
currency: 'USD',
schema: {
fields: [ 'gptSlot', 'mediaType' ]
},
values: [
{key: '/1111/homepage/top-rect|banner', floor: 0.80},
{key: '/1111/homepage/top-rect|video', floor: 1.20},
{key: '/1111/homepage/left-nav|banner', floor: 0.90},
...
{key: '/1111/tech/left-nav|banner', floor: 1.50}
],
default: 0.75
}
}
});
Also, you can delay the auction for some time to receive optimal floor price for specific pages or ad units if you're working with a third-party floor provider:
pbjs.setConfig({
floors: {
auctionDelay: 100, // in milliseconds
endpoint: {
url: 'https://floorprovider.com/a1001-mysite.json',
method: 'GET'
},
data: { // default if endpoint doesn't return in time
currency: 'USD',
schema: {
fields: [ 'mediaType' ]
},
values: [
{key: 'banner', floor: 0.80},
{key: 'video', floor: 1.20}
]
}
}
});