How can I charge customers with saved credit cards?
Card object returns ID, how can I transform that ID to credit card nonce?
You don't have to.
The Charge endpoint takes either a card_nonce or a combination of a customer_id and a customer_card_id. In that case your json body would look something like this:
{
"idempotency_key": "xxxx",
"amount_money": {
"amount": 100,
"currency": "USD"
},
"customer_card_id": "{{customer_card_id}}";
"reference_id": "some optional reference id",
"note": "some optional note",
"customer_id":"{{customer_id}}",
"delay_capture": false
}
You can read more about it with a ruby example on this page: https://docs.connect.squareup.com/articles/processing-recurring-payments-ruby
Related
Problem:
On the Shopify Admin, section Products > Inventory, there's a "committed" inventory.
Based on my comprehension it means "reserved stock for pending orders", or "inventory reserved by orders created but not yet completed".
This "committed" stock value can be very useful for stock updates by app. But pratically this value seems hard to retreive.
Question:
How to get this "committed" inventory value in an efficient way ?
Current state of researchs :
Not possible via Shopify APIs (REST & GraphQL, version 2022-07)
Can be approximated (not sure it's the right method) by looping over all unfulfilled orders, and sum up (by variant) the unfulfilled product variant quantity. However, it takes time and consumes a lot of API resources.
According to a Shopify Community Manager (ref. post)
The Committed inventory state isn't added to the API currently.
It's possible now in the 2023-01 version of the API. The InventoryLevel got a new field quantities, which returns this for a product with a total stock of 10 and two sold:
[
{
"quantity": 8,
"name": "available"
},
{
"quantity": 2,
"name": "committed"
},
{
"quantity": 0,
"name": "incoming"
},
{
"quantity": 10,
"name": "on_hand"
},
{
"quantity": 0,
"name": "reserved"
}
]
I'm trying to write an app to track my gains/losses for tax purposes based on the swaps I've made using Bscscan APIs. I can easily retrieve all the swaps I've made using one of BscScan "accounts" module api endpoint (Get a list of 'BEP-20 Token Transfer Events' by Address to be exact). Here's an example of the body response:
{
"status": "1",
"message": "OK",
"result": [{
"blockNumber": "2304192",
"timeStamp": "1605585978",
"hash": "0x7a5abf86c82d3f97a40dd841a9f2089fbe3ac1332157c01bd1a1d89f575c45fc",
"nonce": "57",
"blockHash": "0x703438fd8ba435996895a6b9b711934cc590c3e9297a7066419aa88dd9d83acc",
"from": "0x641414e2a04c8f8ebbf49ed47cc87dccba42bf07",
"contractAddress": "0xc9849e6fdb743d08faee3e34dd2d1bc69ea11a51",
"to": "0x7bb89460599dbf32ee3aa50798bbceae2a5f7f6a",
"value": "27605634758857128698365",
"tokenName": "Bunny Token",
"tokenSymbol": "BUNNY",
"tokenDecimal": "18",
"transactionIndex": "2",
"gas": "5000000",
"gasPrice": "20000000000",
"gasUsed": "2312130",
"cumulativeGasUsed": "2475576",
"input": "deprecated",
"confirmations": "8172919"
}
]
}
So the value input ("value": "27605634758857128698365") gives the value in the underlying coin "currency" - in this case "Bunny Token" - but without knowing the quantity of that coin bought, I can't determine the cost basis of that transaction. I've looked at other bscscan APIs but I couldn't find any that would could help me retrieve the price of the coin for a given transaction.
Does anyone know if there's a way to retrieve the price of a coin (or the quantity bought) based on the transaction data using bsccan api?
TIA
I came across a situation that I hope someone else has seen.
The order looks like this in shopify:
The Discounted Line Item JSON looks like this:
{
"id": XXXXX,
"name": "NAME",
"price": "19.10",
"product_exists": true,
"quantity": 1,
"sku": "SKU",
"total_discount": "9.55",
"discount_allocations": [
{
"amount": "9.55",
"amount_set": {
"shop_money": {
"amount": "9.55",
"currency_code": "USD"
},
"presentment_money": {
"amount": "9.55",
"currency_code": "USD"
}
},
"discount_application_index": 0
}
]
},
An Automatic Discount as a "BOGO at 50% off" was applied to this order, but I cant quite get the discounting right for a net unit price, without also causing issues elsewhere in this particular Shopify Tenant.
Previously I would
line_unit_price = price - (TotalDiscount/Quantity) - SumOfDiscountApplications
But in this case, that would just double discount it to zero, which is not correct. In other cases with this Shopify Tenant, I do need to use the Discount Applications as TotalDiscount would be 0. I cant quite figure out when/where/why to do the math differently for an effective Line Net Unit Price.
Very odd. Any help would be great.
I already tried the solution given in this Cart API V3: Can't create a Cart for product that has options link but it's not working for me.
modifier is extra fitting added to the product like "name tag" for suitcase.
I tried to add the modifier in "option_selections" like below but it returns 422 error.
Request:
{
"quantity":"1",
"product_id":"5846",
"variant_id":150922,
"list_price":" 170.00",
"option_selections":[{"option_id":23800, "option_value":"10088"}]
}
Response:
StatusCode: 422, ReasonPhrase: 'Unprocessable Entity'
Thanks for your reply in advance.
If you're creating a new cart, try this request body (POST to /carts endpoint):
{
"line_items": [
{
"quantity": 1,
"product_id": 76,
"list_price": 170.00,
"option_selections": [
{
"option_id": 21506,
"option_value": 10090
}
]
}
]
}
You shouldn't have quotes around any of these field values--list_price, product_id, etc all accept a number, not a string.
If you want to add a new line item to an existing cart, you can use the same request body as above. The request will be a POST to carts/{cartID}/items
EDIT:
If you are updating a line item that already exists in the cart, you'll want to make a PUT to /carts/{cartID}/items/{itemID}.
Request body:
{
"line_item": {
"quantity": 1,
"product_id": 76,
"list_price": 170.00,
"option_selections": [
{
"option_id": 21506,
"option_value": 10090
}
]
}
}
Note: it does need to be "line_item" rather than "line_items" when updating a single cart item. I'll work with our documentation team to get this updated in the API reference.
I was able to solve the issue, though I agree with Karen White's answer, I wanted to add a product which has options like colors and modifiers too. Which I was not able to achieve with that. I used the following data to add product with option and modifier.
Instead of passing variant_id, pass variant as option (option_id gets option's id and option_value gets option value's id) and pass modifier as option (modifier option_id gets option's id and option_value gets option value's id)
{
"line_items": [{
"quantity": 1,
"product_id": 5846,
"option_selections": [{
"option_id": 23799,
"option_value": 10173
}, {
"option_id": 23800,
"option_value": 10088
}]
}]
}
I'm trying to retrieve each product's custom_fields data on the category list pages in BigCommerce Stencil. This documentation here, and the JSON product representation below, would suggest this is not possible.
It is hard for me to believe this functionality would be left out of Stencil, considering it was available in Blueprint.
{
"id": 691,
"name": "Archipelago Botanicals - Pomegranate Lip Gloss",
"url": "http://******.mybigcommerce.com/archipelago-botanicals-pomegranate-lip-gloss/",
"brand": {
"name": "Archipelago Botanicals"
},
"rating": 0,
"availability": "",
"summary": "Pomegranate lip gloss leaves lips hydrated, shiny and smooth. Apply liberally.Net Weight: 0.42 oz. / 12 g Mineral Oil, Polybutene, Octyidodecanol, Butylene, Ethylene, Styrene Copolymer, Ethylene, Propylene, Styrene Copolymer, C18-36 Acid Triglycerides, Fr",
"image": {
"data": "https://cdn3.bigcommerce.com/*****/images/stencil/{:size}/products/691/41439/arbopolipgl__77026.1464267682.jpg?c=2",
"alt": "Archipelago Botanicals - Pomegranate Lip Gloss"
},
"date_added": "Apr 7th 2016",
"qty_in_cart": 0,
"pre_order": false,
"has_options": false,
"show_cart_action": false,
"price": {
"without_tax": {
"formatted": "$5.00",
"value": 5
},
"rrp_without_tax": {
"formatted": "$12.50",
"value": 12.5
},
"saved": {
"formatted": "$7.50",
"value": 7.5
},
"tax_label": "Tax"
}
},
Am I missing something, or is this functionality not available on Stencil at this time?
Has anyone come up with a creative solution to retrieve this data inside each product card?
Thanks
The product card now allows this to be exposed. It provides an array of all custom fields associated with a product. Information on the product card object is here.
It was a change that had to be made in the BC core app and the fix was released on Sept 20th