commercelayer / commercelayer-sdk Goto Github PK
View Code? Open in Web Editor NEWThe official Commerce Layer JavaScript library wrapper, that makes it quick and easy to interact with Commerce Layer API.
License: MIT License
The official Commerce Layer JavaScript library wrapper, that makes it quick and easy to interact with Commerce Layer API.
License: MIT License
Type: Versioning issue
Hey there!
While trying to upgrade this sdk from version 2.0.1
to 2.3.6
, I'm getting issues with the install related to my node
version.
In the previous release the engine version was not set, but with this change the node engine version is introduced (asking for v16.0.0
) causing the install to fail.
4846a36#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R72
Node version: v14.18.1
This change wouldn't be expected to land in a minor
version following semantic versioning.
Is it related to some installed dependency necessary for this SDK?
Is it possible to backport the added changes to a stable 2.x.x
version?
Additional note:
There's no changelog kept in which we could find the previous version to resolve easily, which does not include these changes so we can use a stable version of this package.
Type: Bug
Hey guys!
After updating to v2.3.7
I found that our imports (like import * from '@commercelayer/sdk/lib/resources/...'
) do not work anymore as the entrypoint is changed from lib/index.js
to lib/cjs/index.js
. We still could resolve through the cjs
path, but this change requires unexpected updates inside our codebase.
This was introduced in this change.
937310f
For now I have made the version strict to v2.2.0
which does not change the build process.
This kind of change would be a breaking change as the consumers of the package need to actively update their applications to support it!
Thanks for looking into it!
No response
Update SDK resources to API schema v4.5.1
No response
no
No response
sdk4
branch failed. π¨I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. Iβm sure you can fix this πͺ.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the sdk4
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here are some links that can help you:
If those donβt help, or if this issue is reporting something you think isnβt right, you can always ask the humans behind semantic-release.
4.27.1
on branch sdk4
cannot be published as it is out of range.Based on the releases published on other branches, only versions within the range >=5.0.0
can be published from branch sdk4
.
The following commits are responsible for the invalid release:
Those commits should be moved to a valid branch with git merge or git cherry-pick and removed from branch sdk4
with git revert or git reset.
A valid branch could be main
or sdk4
.
See the workflow configuration documentation for more details.
Good luck with your project β¨
Your semantic-release bot π¦π
Let's say we have an order with two line items:
{
"id": "abc",
"type": "orders",
"line_items": [{
"id": "111",
"type": "line_items"
}, {
"id": "222",
"type": "line_items"
}]
}
When executing a CRUD action on one of the line items and including the order
and order.line_items
references, the normalized order.line_items
object doesn't include the line item that the CRUD operation was executed upon:
await client.line_items.update({
id: "111",
quantity: 1,
}, {
include: ["order", "order.line_items"],
})
returns
{
id: "111",
type: "line_items",
// ...
order: {
id: "abc",
type: "orders",
// ...
line_items: [{
id: "222",
type: "line_items",
}
// line item "111" is missing here, while it's part of the order
]
},
}
My guess is the API doesn't return this information to save on bytes sent, but the normalization function doesn't take this circular reference into account.
Could the SDK be changed such that the line item with ID "111" would be included in the response?
Any chance you can build a isomorphic SDK here? Currently, you use axios for the fetch in client.ts, which makes it impossible to use this SDK on the newer edge platforms like Cloudflare Workers (NextJs Edge also, which runs on Cloudflare) or Deno. I believe if you just switched the client to simply use standard fetch, it would work fine on Cloudflare Workers/Deno.
Hi @pviti - @acasazza - We are trying to create a PayPal payment source to an order where user selected this payment method, the order entity is:
{
"id": "wLmohaoYRy",
"type": "orders",
"number": 17093789,
"autorefresh": true,
"status": "draft",
"payment_status": "unpaid",
"fulfillment_status": "unfulfilled",
"guest": true,
"editable": true,
"customer_email": null,
"language_code": "en",
"currency_code": "CAD",
"tax_included": false,
"tax_rate": null,
"freight_taxable": null,
"requires_billing_info": false,
"country_code": "CA",
"shipping_country_code_lock": null,
"coupon_code": null,
"gift_card_code": null,
"gift_card_or_coupon_code": null,
"subtotal_amount_cents": 7200,
"subtotal_amount_float": 72,
"formatted_subtotal_amount": "$72.00",
"shipping_amount_cents": 0,
"shipping_amount_float": 0,
"formatted_shipping_amount": "$0.00",
"payment_method_amount_cents": 0,
"payment_method_amount_float": 0,
"formatted_payment_method_amount": "$0.00",
"discount_amount_cents": 0,
"discount_amount_float": 0,
"formatted_discount_amount": "$0.00",
"adjustment_amount_cents": 0,
"adjustment_amount_float": 0,
"formatted_adjustment_amount": "$0.00",
"gift_card_amount_cents": 0,
"gift_card_amount_float": 0,
"formatted_gift_card_amount": "$0.00",
"total_tax_amount_cents": 0,
"total_tax_amount_float": 0,
"formatted_total_tax_amount": "$0.00",
"subtotal_tax_amount_cents": 0,
"subtotal_tax_amount_float": 0,
"formatted_subtotal_tax_amount": "$0.00",
"shipping_tax_amount_cents": 0,
"shipping_tax_amount_float": 0,
"formatted_shipping_tax_amount": "$0.00",
"payment_method_tax_amount_cents": 0,
"payment_method_tax_amount_float": 0,
"formatted_payment_method_tax_amount": "$0.00",
"adjustment_tax_amount_cents": 0,
"adjustment_tax_amount_float": 0,
"formatted_adjustment_tax_amount": "$0.00",
"total_amount_cents": 7200,
"total_amount_float": 72,
"formatted_total_amount": "$72.00",
"total_taxable_amount_cents": 7200,
"total_taxable_amount_float": 72,
"formatted_total_taxable_amount": "$72.00",
"subtotal_taxable_amount_cents": 7200,
"subtotal_taxable_amount_float": 72,
"formatted_subtotal_taxable_amount": "$72.00",
"shipping_taxable_amount_cents": 0,
"shipping_taxable_amount_float": 0,
"formatted_shipping_taxable_amount": "$0.00",
"payment_method_taxable_amount_cents": 0,
"payment_method_taxable_amount_float": 0,
"formatted_payment_method_taxable_amount": "$0.00",
"adjustment_taxable_amount_cents": 0,
"adjustment_taxable_amount_float": 0,
"formatted_adjustment_taxable_amount": "$0.00",
"total_amount_with_taxes_cents": 7200,
"total_amount_with_taxes_float": 72,
"formatted_total_amount_with_taxes": "$72.00",
"fees_amount_cents": 0,
"fees_amount_float": 0,
"formatted_fees_amount": "$0.00",
"duty_amount_cents": null,
"duty_amount_float": null,
"formatted_duty_amount": null,
"skus_count": 7,
"line_item_options_count": 0,
"shipments_count": 1,
"payment_source_details": null,
"cart_url": null,
"return_url": null,
"terms_url": null,
"privacy_url": null,
"checkout_url": null,
"placed_at": null,
"approved_at": null,
"cancelled_at": null,
"payment_updated_at": null,
"fulfillment_updated_at": null,
"refreshed_at": null,
"archived_at": null,
"expires_at": null,
"created_at": "2021-12-15T14:48:43.093Z",
"updated_at": "2021-12-15T14:48:47.323Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"shipping_address": {
"id": "bRMNuORrex",
"type": "addresses",
"business": false,
"first_name": "Alonso",
"last_name": "Shipping",
"company": null,
"full_name": "Alonso Shipping",
"line_1": "shipping address test street 23",
"line_2": null,
"city": "Toronto",
"zip_code": "66777",
"state_code": "ON",
"country_code": "CA",
"phone": "877 734 9292",
"full_address": "shipping address test street 23, 66777 Toronto ON (CA) 877 734 9292",
"name": "Alonso Shipping, shipping address test street 23, 66777 Toronto ON (CA) 877 734 9292",
"email": null,
"notes": null,
"lat": null,
"lng": null,
"is_localized": false,
"is_geocoded": false,
"provider_name": null,
"map_url": null,
"static_map_url": null,
"billing_info": null,
"created_at": "2021-12-15T14:48:44.568Z",
"updated_at": "2021-12-15T14:48:44.568Z",
"reference": null,
"reference_origin": null,
"metadata": {}
},
"billing_address": null,
"available_payment_methods": [
{
"id": "ZMDJWsDzzm",
"type": "payment_methods",
"payment_source_type": "paypal_payments",
"name": "Paypal Payment",
"moto": false,
"disabled_at": null,
"price_amount_cents": 0,
"price_amount_float": 0,
"formatted_price_amount": "$0.00",
"created_at": "2021-12-01T18:49:07.218Z",
"updated_at": "2021-12-01T18:49:07.218Z",
"reference": "",
"reference_origin": "",
"metadata": {}
},
{
"id": "GMvVesxZxM",
"type": "payment_methods",
"payment_source_type": "stripe_payments",
"name": "Stripe Payment",
"moto": false,
"disabled_at": null,
"price_amount_cents": 0,
"price_amount_float": 0,
"formatted_price_amount": "$0.00",
"created_at": "2021-11-30T20:38:09.590Z",
"updated_at": "2021-11-30T20:38:09.590Z",
"reference": "",
"reference_origin": "",
"metadata": {}
}
],
"payment_method": {
"id": "ZMDJWsDzzm",
"type": "payment_methods",
"payment_source_type": "paypal_payments",
"name": "Paypal Payment",
"moto": false,
"disabled_at": null,
"price_amount_cents": 0,
"price_amount_float": 0,
"formatted_price_amount": "$0.00",
"created_at": "2021-12-01T18:49:07.218Z",
"updated_at": "2021-12-01T18:49:07.218Z",
"reference": "",
"reference_origin": "",
"metadata": {}
},
"payment_source": null,
"line_items": [
{
"id": "NmnptYWOdo",
"type": "line_items",
"sku_code": null,
"bundle_code": null,
"quantity": 1,
"currency_code": "CAD",
"unit_amount_cents": 0,
"unit_amount_float": 0,
"formatted_unit_amount": "$0.00",
"options_amount_cents": 0,
"options_amount_float": 0,
"formatted_options_amount": "$0.00",
"discount_cents": 0,
"discount_float": 0,
"formatted_discount": "$0.00",
"total_amount_cents": 0,
"total_amount_float": 0,
"formatted_total_amount": "$0.00",
"tax_amount_cents": 0,
"tax_amount_float": 0,
"formatted_tax_amount": "$0.00",
"name": "Paypal Payment",
"image_url": null,
"discount_breakdown": {},
"tax_rate": 0,
"tax_breakdown": {},
"item_type": "payment_methods",
"created_at": "2021-12-15T14:48:47.321Z",
"updated_at": "2021-12-15T14:48:47.321Z",
"reference": null,
"reference_origin": null,
"metadata": {}
},
{
"id": "yWEZtQwBlD",
"type": "line_items",
"sku_code": "10152101048",
"bundle_code": null,
"quantity": 2,
"currency_code": "CAD",
"unit_amount_cents": 1100,
"unit_amount_float": 11,
"formatted_unit_amount": "$11.00",
"options_amount_cents": 0,
"options_amount_float": 0,
"formatted_options_amount": "$0.00",
"discount_cents": 0,
"discount_float": 0,
"formatted_discount": "$0.00",
"total_amount_cents": 2200,
"total_amount_float": 22,
"formatted_total_amount": "$22.00",
"tax_amount_cents": 0,
"tax_amount_float": 0,
"formatted_tax_amount": "$0.00",
"name": "AEROCHAMBER PLUS* FLOW-VU* Chamber Small Mask",
"image_url": "",
"discount_breakdown": {},
"tax_rate": 0,
"tax_breakdown": {},
"item_type": "skus",
"created_at": "2021-12-15T14:48:43.576Z",
"updated_at": "2021-12-15T14:48:43.576Z",
"reference": null,
"reference_origin": null,
"metadata": {}
},
{
"id": "kqYatlnXgB",
"type": "line_items",
"sku_code": "12350101060",
"bundle_code": null,
"quantity": 5,
"currency_code": "CAD",
"unit_amount_cents": 1000,
"unit_amount_float": 10,
"formatted_unit_amount": "$10.00",
"options_amount_cents": 0,
"options_amount_float": 0,
"formatted_options_amount": "$0.00",
"discount_cents": 0,
"discount_float": 0,
"formatted_discount": "$0.00",
"total_amount_cents": 5000,
"total_amount_float": 50,
"formatted_total_amount": "$50.00",
"tax_amount_cents": 0,
"tax_amount_float": 0,
"formatted_tax_amount": "$0.00",
"name": "AEROCHAMBER2GO* Chamber",
"image_url": "",
"discount_breakdown": {},
"tax_rate": 0,
"tax_breakdown": {},
"item_type": "skus",
"created_at": "2021-12-15T14:48:43.562Z",
"updated_at": "2021-12-15T14:48:43.562Z",
"reference": null,
"reference_origin": null,
"metadata": {}
}
],
"shipments": [
{
"id": "YOvmCZzmZb",
"type": "shipments",
"number": "17093789/S/001",
"status": "draft",
"currency_code": "CAD",
"cost_amount_cents": 0,
"cost_amount_float": 0,
"formatted_cost_amount": "$0.00",
"skus_count": 7,
"selected_rate_id": null,
"rates": [],
"purchase_error_code": null,
"purchase_error_message": null,
"get_rates_started_at": null,
"get_rates_completed_at": null,
"purchase_started_at": null,
"purchase_completed_at": null,
"purchase_failed_at": null,
"created_at": "2021-12-15T14:48:44.940Z",
"updated_at": "2021-12-15T14:48:44.940Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"shipping_method": null,
"available_shipping_methods": [
{
"id": "vNKdPFoGXV",
"type": "shipping_methods",
"name": "SM.CAD.FlatFee",
"disabled_at": null,
"currency_code": "CAD",
"price_amount_cents": 500,
"price_amount_float": 5,
"formatted_price_amount": "$5.00",
"free_over_amount_cents": 20000,
"free_over_amount_float": 200,
"formatted_free_over_amount": "$200.00",
"price_amount_for_shipment_cents": 500,
"price_amount_for_shipment_float": 5,
"formatted_price_amount_for_shipment": "$5.00",
"created_at": "2021-11-08T21:39:12.242Z",
"updated_at": "2021-12-13T13:37:48.438Z",
"reference": "",
"reference_origin": "",
"metadata": {}
},
{
"id": "yVwXrFDLlE",
"type": "shipping_methods",
"name": "SM.CAD.Ground",
"disabled_at": null,
"currency_code": "CAD",
"price_amount_cents": 1000,
"price_amount_float": 10,
"formatted_price_amount": "$10.00",
"free_over_amount_cents": 20000,
"free_over_amount_float": 200,
"formatted_free_over_amount": "$200.00",
"price_amount_for_shipment_cents": 1000,
"price_amount_for_shipment_float": 10,
"formatted_price_amount_for_shipment": "$10.00",
"created_at": "2021-11-08T21:39:47.653Z",
"updated_at": "2021-12-14T17:56:11.448Z",
"reference": "",
"reference_origin": "",
"metadata": {}
},
{
"id": "ZEkJxFoMRV",
"type": "shipping_methods",
"name": "SM.CAD.Express",
"disabled_at": null,
"currency_code": "CAD",
"price_amount_cents": 1500,
"price_amount_float": 15,
"formatted_price_amount": "$15.00",
"free_over_amount_cents": 20000,
"free_over_amount_float": 200,
"formatted_free_over_amount": "$200.00",
"price_amount_for_shipment_cents": 1500,
"price_amount_for_shipment_float": 15,
"formatted_price_amount_for_shipment": "$15.00",
"created_at": "2021-11-08T21:40:16.684Z",
"updated_at": "2021-12-14T17:56:31.552Z",
"reference": "",
"reference_origin": "",
"metadata": {}
}
]
}
]
}
When calling the payment source creation like this:
const paymentSource = {
{
"return_url": "https://checkout.yourdomain.com/jNbQLhMeqo/success",
"cancel_url": "https://checkout.yourdomain.com/jNbQLhMeqo/cancel",
order: clClient.orders.relationship(order.id),
}
await clClient.paypal_payments.create(paymentSource)
We received the following error:
Is hard to know what's happening because the 500 error don't provide any details, the PayPal gateway is properly configured in the CL administration UI and the required parameters are passed following the API TS definition and the example from: https://docs.commercelayer.io/developers/v/how-tos/payments/paypal/adding-a-paypal-payment-source
Can you provide guidance on what is missing in this API call that could be originating this error?
Thanks!
When creating a order SKU line item and resolving the response, the resulting resource is not providing the order entity nor the order reference ID, this force the need of fetching again the created line item or the order including 'line_items'.
We have implemented a code like this:
const createPromises = orderItems.map((orderItem) => {
return clClient.line_items.create(orderItem)
})
// TODO: Created order items don't return associated order, open CL issue.
const itemsCreated = await Promise.all(createPromises)
console.log('Create line item: ', itemsCreated)
// Get order ID from first create line item reference and load the latest order state.
const orderId = first(orderItems).order.id
const order = await clClient.orders.retrieve(orderId, {
include: ['line_items']
})
dispatch(composeDataAction(actionTypes.CREATE_DRAFT_ORDER, order))
} catch (error) {
console.log('Add order items error: ', error)
}
The orderItems are LineItemCreate objects like this:
const orderItems = [
{
sku_code: 'BABYONBU000000E63E746MXX',
quantity: 2,
order: clClient.orders.relationship(order.id)
}
]
When the line item is created, this is the returned resource:
Create line item: [
{
id: 'ywLGtLwwaA',
type: 'line_items',
sku_code: 'BABYONBU000000E63E746MXX',
bundle_code: null,
quantity: 2,
currency_code: 'USD',
unit_amount_cents: 3480,
unit_amount_float: 34.8,
formatted_unit_amount: '$34.80',
options_amount_cents: 0,
options_amount_float: 0,
formatted_options_amount: '$0.00',
discount_cents: 0,
discount_float: 0,
formatted_discount: '$0.00',
total_amount_cents: 6960,
total_amount_float: 69.6,
formatted_total_amount: '$69.60',
tax_amount_cents: 0,
tax_amount_float: 0,
formatted_tax_amount: '$0.00',
name: 'Black Baby Onesie Short Sleeve with Pink Logo (6 Months)',
image_url: 'https://img.commercelayer.io/skus/BABYONBU000000E63E74.png?fm=jpg&q=90',
discount_breakdown: {},
tax_rate: 0,
tax_breakdown: {},
item_type: 'skus',
created_at: '2021-10-26T20:23:45.757Z',
updated_at: '2021-10-26T20:23:45.757Z',
reference: null,
reference_origin: null,
metadata: {}
}
]
I tried to experiment with the params object as you did in the test https://github.com/commercelayer/commercelayer-sdk/blob/main/specs/resources/line_items.spec.ts#L34 to see if there was a way to include the "order" field but all the experiments that tried don't work and still need another request to get the order. Please let me know if there is a way to include the order in the response. Thanks!
Attribute payment_source_type
has wrong enum and description in the following resources:
payment_methods
payment_options
No response
No response
No response
Hi guys. I can't find a migration guide from the commercelayer-js-sdk to this one.
Is there one, or is it just a straight swap?
I am trying to update the line item's quantity in the order but the API returns a validation error.
external_price
set to true
.line_items.update({id, quantity})
.unit_amount_cents - doesn't match with the associated item one
.I think it is because I haven't created a dedicated price for this SKU.
It should let me update the quantity as I added the item to the cart using an external pricing mechanism.
I spent some time reading the source code searching for a way to use the SDK types given a Commerce Layer response, and I could not find it.
I'm currently working on an external tax calculator. From the order payload it receives, I would like to use the Order
type as if I was fetching the data manually.
As far as I can see, internally, the SDK has the normalize
and denormalize
functions that help with that. However, they are not being exposed to me.
Is there a way to do it?
What I have in mind right now would be something like the following:
const handler = (req: Request, res: Response) => {
const order = denormalize<Order>(req.body) // `const order` is now implicitly of the `type Order`
...
}
Am I missing something? Is there an easier way to tackle that?
Any help is appreciated. Thank you!
Hi @pviti - We are experiencing many SDK timeout requests when placing an order (transition to placed state) that use a PayPal payment source. Looks like behind the scenes CL backend is doing some operations that are time consuming and the SDK that tolerate a max timeout of 3 seconds determined that it took so much time and aborts the request. This is the error we see:
However, besides this error, it looks that the order transition correctly to "placed" state and completes the PayPal payment processing because the order state looks like this:
Is there a way to extend the SDK timeout? Can you help us to debug and determine why the "place" operation is taking 3 seconds sometimes and other times completing without exceeding the timeout?
The order ID of this test is: NbQLhleWOz
Thanks for your support!
SDK fails when an error ha an empty body (it shouldn't never happen but sometimes happens)
No response
No response
No response
sdk4
branch failed. π¨I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. Iβm sure you can fix this πͺ.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the sdk4
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here are some links that can help you:
If those donβt help, or if this issue is reporting something you think isnβt right, you can always ask the humans behind semantic-release.
4.28.0
on branch sdk4
cannot be published as it is out of range.Based on the releases published on other branches, only versions within the range >=5.32.0
can be published from branch sdk4
.
The following commits are responsible for the invalid release:
Those commits should be moved to a valid branch with git merge or git cherry-pick and removed from branch sdk4
with git revert or git reset.
A valid branch could be main
or sdk4
.
See the workflow configuration documentation for more details.
Good luck with your project β¨
Your semantic-release bot π¦π
Hi @pviti, we are experiencing an error when updating a Payment Gateway resource to add a metadata field using a SDK procedure that is working well in other resources like SDK or PriceLists so seems to be specific issue to the Payment Gateway resource:
We have the following resource and apply the update with the following payload:
The update procedure looks like this:
Once the update run we receive the following error:
Can you help us to investigate why the update is indicating that the resource is not found (404 error).
Thanks for your support!
We might have found a bug in your SDK library.
We are trying to search for a user with a specific field value in his metadata object.
According to this documentation it says that what we need to do is filter[q][metadata_jcont]={"key": "value"}
So here is how our SDK function call looks like.
client.customers.list({ filters: { metadata_jcont: { firstName: 'joh' } } });
But it seems like the SDK doesnβt transform this into the correct query params.
Looking at the SDK code we have found that inside generateQueryStringParams function you are doing
if (params.filters) {
Object.entries(params.filters).forEach(([p, v]) => {
qp[filter[q][${p}]
] = String(v)
})
}
However String(v) in our case it will be String({ firstName: 'joh' }) which will result in [object Object]
We have changed it to
qp[filter[q][${p}]
] = JSON.stringify(v)
which it seems like is fixing the problem.
Unfortunately that is not a valid fix because if we do for example
client.customers.list({ filters: { id_eq: "id_value" } });
That will not work, because JSON.stringify("id_value") will result to '"id_value"' .
We are going to with a dirty patch fix for now which it will be something like this
if (params.filters) {
Object.entries(params.filters).forEach(([p, v]) => {
if (p === 'metadata_jcont') {
qp[filter[q][${p}]
] = JSON.stringify(v);
} else {
qp[filter[q][${p}]
] = String(v);
}
});
}
but do you think it is a bug that you may consider fixing soon ?
No response
No response
No response
Hi @pviti - We was trying to figure out how to add a stripe payment source for a guest order but got errors when following the guides:
We are able to successfully get the order available payment methods and select (reference) one of this methods as the order payment method but when trying to create a payment source the example from your documentation is only passing the following payload:
"data": {
"type": "stripe_payments",
"attributes": {},
"relationships": {
"order": {
"data": {
"type": "orders",
"id": "eqkykhjlVw"
}
}
}
With the CL SDK I'm replicating this step in the following manner:
const order = myOrderEntity
const paymentSource = {
options: {},
order: clClient.orders.relationship(order.id),
}
// Create payment method source.
const newPaymentSource = await clClient.stripe_payments.create(paymentSource)
console.log('NewPaymentSource: ', newPaymentSource)
This produces the following errors:
If we don't pass the options argument, the stripe_payments.create call don't produce an exception but returns undefined. Also is not clear at what step the customer needs to fill the credit card details and if that data should be passed as options, we was not able to find any example in the SDK specs tests or in the official documentation. Can you guide us on how to properly create a customer Stripe credit card payment source and associate to a guest order?
Thanks!
No response
This SDK uses Axios under the hood, but doesn't expose it, making it unable for users to use libraries like axios-retry or axios-debug-log.
Even implementing something like axios-retry (exponential backoff) yourself for this client is nearly impossible because of the limited flexibility of the middleware. (There's no way to retry an operation in the error interceptor.)
I think this client could greatly benefit from exposing a standard way of adding request middleware, preferably by just using fetch
and allowing developers to pass their own fetch
implementation:
import { CommerceLayer } from "@commercelayer/sdk";
const extendedFetch = extendFetch(fetch);
const client = CommerceLayer({ fetch: extendedFetch });
Having control over the fetch function (or the Axios instance) function gives developers the ability to make all sorts of middlewares.
No response
no
No response
const findIncluded = (rel, included = []) => {
^
RangeError: Maximum call stack size exceeded
at findIncluded (/Users/elian/Documents/GitHub/viu/playground/clplayground/node_modules/@commercelayer/sdk/lib/cjs/jsonapi.js:28:22)
at /Users/elian/Documents/GitHub/viu/playground/clplayground/node_modules/@commercelayer/sdk/lib/cjs/jsonapi.js:48:70
at Array.map ()
at /Users/elian/Documents/GitHub/viu/playground/clplayground/node_modules/@commercelayer/sdk/lib/cjs/jsonapi.js:48:41
at Array.forEach ()
at denormalizeResource (/Users/elian/Documents/GitHub/viu/playground/clplayground/node_modules/@commercelayer/sdk/lib/cjs/jsonapi.js:44:40)
at /Users/elian/Documents/GitHub/viu/playground/clplayground/node_modules/@commercelayer/sdk/lib/cjs/jsonapi.js:50:37
at Array.forEach ()
at denormalizeResource (/Users/elian/Documents/GitHub/viu/playground/clplayground/node_modules/@commercelayer/sdk/lib/cjs/jsonapi.js:44:40)
at /Users/elian/Documents/GitHub/viu/playground/clplayground/node_modules/@commercelayer/sdk/lib/cjs/jsonapi.js:48:50
const test = await cl.shipments.retrieve("eQqGCXaLqE", {
include: ["stock_transfers.line_item.stock_transfers"]
})
No response
const denormalizeResource = (res, included, lastResources = []) => {
if (!res)
return res;
const resource = {
id: res.id,
type: res.type,
...res.attributes,
};
if (res.relationships)
Object.keys(res.relationships).forEach(key => {
const rel = res.relationships[key].data;
if (rel) {
if (Array.isArray(rel))
resource[key] = rel.map(r => {
if (lastResources.filter(element => element === r.id).length <= 2) {
return denormalizeResource(findIncluded(r, included), included, [...lastResources, r.id])
}
return null
}).filter(element => element !== null);
else
resource[key] = denormalizeResource(findIncluded(rel, included), included, [...lastResources, rel.id]);
} else if (rel === null)
resource[key] = null;
});
return resource;
};
We are using the following SDK query to get all the prices that belong to a price list:
const prices = await clSdk.prices.list({
include: ['sku'],
filters: { price_list_eq: 'nLNWECENrB' },
pageSize: 25,
pageNumber: 1,
})
The expectation is to get only the prices that reference the price list with ID "nLNWECENrB" but we are getting prices that belong to different price lists so it seems that the filter is just omitted, here is the response:
(Note that mix prices in different currencies that are from different price lists)
`
[
{
"id": "aydWUmyjKg",
"type": "prices",
"currency_code": "EUR",
"sku_code": "TSHIRTMM000000E63E74MXXX",
"amount_cents": 2900,
"amount_float": 29,
"formatted_amount": "β¬29,00",
"compare_at_amount_cents": 3770,
"compare_at_amount_float": 37.7,
"formatted_compare_at_amount": "β¬37,70",
"created_at": "2021-08-24T19:59:53.219Z",
"updated_at": "2021-08-24T19:59:53.219Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "nGDMSAXPoZ",
"type": "skus",
"code": "TSHIRTMM000000E63E74MXXX",
"name": "Black Men T-shirt with Pink Logo (M)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMM000000E63E74.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.205Z",
"updated_at": "2021-08-24T19:59:53.205Z",
"reference": "TSHIRTMM000000E63E74",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "adKYUZrjVg",
"type": "prices",
"currency_code": "USD",
"sku_code": "TSHIRTMM000000E63E74MXXX",
"amount_cents": 3480,
"amount_float": 34.8,
"formatted_amount": "$34.80",
"compare_at_amount_cents": 4524,
"compare_at_amount_float": 45.24,
"formatted_compare_at_amount": "$45.24",
"created_at": "2021-08-24T19:59:53.260Z",
"updated_at": "2021-08-24T19:59:53.260Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "nGDMSAXPoZ",
"type": "skus",
"code": "TSHIRTMM000000E63E74MXXX",
"name": "Black Men T-shirt with Pink Logo (M)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMM000000E63E74.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.205Z",
"updated_at": "2021-08-24T19:59:53.205Z",
"reference": "TSHIRTMM000000E63E74",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "aORmUXZVWg",
"type": "prices",
"currency_code": "EUR",
"sku_code": "TSHIRTMM000000E63E74LXXX",
"amount_cents": 2900,
"amount_float": 29,
"formatted_amount": "β¬29,00",
"compare_at_amount_cents": 3770,
"compare_at_amount_float": 37.7,
"formatted_compare_at_amount": "β¬37,70",
"created_at": "2021-08-24T19:59:53.292Z",
"updated_at": "2021-08-24T19:59:53.292Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "ZwpOSxRjeW",
"type": "skus",
"code": "TSHIRTMM000000E63E74LXXX",
"name": "Black Men T-shirt with Pink Logo (L)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMM000000E63E74.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.279Z",
"updated_at": "2021-08-24T19:59:53.279Z",
"reference": "TSHIRTMM000000E63E74",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "abDKUDNOPA",
"type": "prices",
"currency_code": "USD",
"sku_code": "TSHIRTMM000000E63E74LXXX",
"amount_cents": 3480,
"amount_float": 34.8,
"formatted_amount": "$34.80",
"compare_at_amount_cents": 4524,
"compare_at_amount_float": 45.24,
"formatted_compare_at_amount": "$45.24",
"created_at": "2021-08-24T19:59:53.329Z",
"updated_at": "2021-08-24T19:59:53.329Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "ZwpOSxRjeW",
"type": "skus",
"code": "TSHIRTMM000000E63E74LXXX",
"name": "Black Men T-shirt with Pink Logo (L)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMM000000E63E74.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.279Z",
"updated_at": "2021-08-24T19:59:53.279Z",
"reference": "TSHIRTMM000000E63E74",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "pvKWUNYLvA",
"type": "prices",
"currency_code": "EUR",
"sku_code": "TSHIRTMM000000E63E74XLXX",
"amount_cents": 2900,
"amount_float": 29,
"formatted_amount": "β¬29,00",
"compare_at_amount_cents": 3770,
"compare_at_amount_float": 37.7,
"formatted_compare_at_amount": "β¬37,70",
"created_at": "2021-08-24T19:59:53.366Z",
"updated_at": "2021-08-24T19:59:53.366Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "WOpOSjROrB",
"type": "skus",
"code": "TSHIRTMM000000E63E74XLXX",
"name": "Black Men T-shirt with Pink Logo (XL)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMM000000E63E74.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.348Z",
"updated_at": "2021-08-24T19:59:53.348Z",
"reference": "TSHIRTMM000000E63E74",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "gwYzUwqYKp",
"type": "prices",
"currency_code": "USD",
"sku_code": "TSHIRTMM000000E63E74XLXX",
"amount_cents": 3480,
"amount_float": 34.8,
"formatted_amount": "$34.80",
"compare_at_amount_cents": 4524,
"compare_at_amount_float": 45.24,
"formatted_compare_at_amount": "$45.24",
"created_at": "2021-08-24T19:59:53.409Z",
"updated_at": "2021-08-24T19:59:53.409Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "WOpOSjROrB",
"type": "skus",
"code": "TSHIRTMM000000E63E74XLXX",
"name": "Black Men T-shirt with Pink Logo (XL)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMM000000E63E74.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.348Z",
"updated_at": "2021-08-24T19:59:53.348Z",
"reference": "TSHIRTMM000000E63E74",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "gBklUBwQEa",
"type": "prices",
"currency_code": "EUR",
"sku_code": "TSHIRTMM000000FFFFFFMXXX",
"amount_cents": 2900,
"amount_float": 29,
"formatted_amount": "β¬29,00",
"compare_at_amount_cents": 3770,
"compare_at_amount_float": 37.7,
"formatted_compare_at_amount": "β¬37,70",
"created_at": "2021-08-24T19:59:53.435Z",
"updated_at": "2021-08-24T19:59:53.435Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "WzPQSjgQxn",
"type": "skus",
"code": "TSHIRTMM000000FFFFFFMXXX",
"name": "Black Men T-shirt with White Logo (M)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMM000000FFFFFF.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.426Z",
"updated_at": "2021-08-24T19:59:53.426Z",
"reference": "TSHIRTMM000000FFFFFF",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "gqwEUejbnp",
"type": "prices",
"currency_code": "USD",
"sku_code": "TSHIRTMM000000FFFFFFMXXX",
"amount_cents": 3480,
"amount_float": 34.8,
"formatted_amount": "$34.80",
"compare_at_amount_cents": 4524,
"compare_at_amount_float": 45.24,
"formatted_compare_at_amount": "$45.24",
"created_at": "2021-08-24T19:59:53.469Z",
"updated_at": "2021-08-24T19:59:53.469Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "WzPQSjgQxn",
"type": "skus",
"code": "TSHIRTMM000000FFFFFFMXXX",
"name": "Black Men T-shirt with White Logo (M)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMM000000FFFFFF.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.426Z",
"updated_at": "2021-08-24T19:59:53.426Z",
"reference": "TSHIRTMM000000FFFFFF",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "pVOMUKQjVA",
"type": "prices",
"currency_code": "EUR",
"sku_code": "TSHIRTMM000000FFFFFFLXXX",
"amount_cents": 2900,
"amount_float": 29,
"formatted_amount": "β¬29,00",
"compare_at_amount_cents": 3770,
"compare_at_amount_float": 37.7,
"formatted_compare_at_amount": "β¬37,70",
"created_at": "2021-08-24T19:59:53.500Z",
"updated_at": "2021-08-24T19:59:53.500Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "BrxeSvwjDZ",
"type": "skus",
"code": "TSHIRTMM000000FFFFFFLXXX",
"name": "Black Men T-shirt with White Logo (L)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMM000000FFFFFF.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.489Z",
"updated_at": "2021-08-24T19:59:53.489Z",
"reference": "TSHIRTMM000000FFFFFF",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "gLQzUGRzwa",
"type": "prices",
"currency_code": "USD",
"sku_code": "TSHIRTMM000000FFFFFFLXXX",
"amount_cents": 3480,
"amount_float": 34.8,
"formatted_amount": "$34.80",
"compare_at_amount_cents": 4524,
"compare_at_amount_float": 45.24,
"formatted_compare_at_amount": "$45.24",
"created_at": "2021-08-24T19:59:53.539Z",
"updated_at": "2021-08-24T19:59:53.539Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "BrxeSvwjDZ",
"type": "skus",
"code": "TSHIRTMM000000FFFFFFLXXX",
"name": "Black Men T-shirt with White Logo (L)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMM000000FFFFFF.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.489Z",
"updated_at": "2021-08-24T19:59:53.489Z",
"reference": "TSHIRTMM000000FFFFFF",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "peNYUBEYJA",
"type": "prices",
"currency_code": "EUR",
"sku_code": "TSHIRTMM000000FFFFFFXLXX",
"amount_cents": 2900,
"amount_float": 29,
"formatted_amount": "β¬29,00",
"compare_at_amount_cents": 3770,
"compare_at_amount_float": 37.7,
"formatted_compare_at_amount": "β¬37,70",
"created_at": "2021-08-24T19:59:53.563Z",
"updated_at": "2021-08-24T19:59:53.563Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "WLgbSAmwMZ",
"type": "skus",
"code": "TSHIRTMM000000FFFFFFXLXX",
"name": "Black Men T-shirt with White Logo (XL)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMM000000FFFFFF.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.554Z",
"updated_at": "2021-08-24T19:59:53.554Z",
"reference": "TSHIRTMM000000FFFFFF",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "aGqWUqLkJA",
"type": "prices",
"currency_code": "USD",
"sku_code": "TSHIRTMM000000FFFFFFXLXX",
"amount_cents": 3480,
"amount_float": 34.8,
"formatted_amount": "$34.80",
"compare_at_amount_cents": 4524,
"compare_at_amount_float": 45.24,
"formatted_compare_at_amount": "$45.24",
"created_at": "2021-08-24T19:59:53.596Z",
"updated_at": "2021-08-24T19:59:53.596Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "WLgbSAmwMZ",
"type": "skus",
"code": "TSHIRTMM000000FFFFFFXLXX",
"name": "Black Men T-shirt with White Logo (XL)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMM000000FFFFFF.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.554Z",
"updated_at": "2021-08-24T19:59:53.554Z",
"reference": "TSHIRTMM000000FFFFFF",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "gMJQUProNa",
"type": "prices",
"currency_code": "EUR",
"sku_code": "TSHIRTMMFFFFFF000000MXXX",
"amount_cents": 2900,
"amount_float": 29,
"formatted_amount": "β¬29,00",
"compare_at_amount_cents": 3770,
"compare_at_amount_float": 37.7,
"formatted_compare_at_amount": "β¬37,70",
"created_at": "2021-08-24T19:59:53.622Z",
"updated_at": "2021-08-24T19:59:53.622Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "ZjwqSkrbgW",
"type": "skus",
"code": "TSHIRTMMFFFFFF000000MXXX",
"name": "White Men T-shirt with Black Logo (M)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMMFFFFFF000000.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.609Z",
"updated_at": "2021-08-24T19:59:53.609Z",
"reference": "TSHIRTMMFFFFFF000000",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "glnlUDQXkp",
"type": "prices",
"currency_code": "USD",
"sku_code": "TSHIRTMMFFFFFF000000MXXX",
"amount_cents": 3480,
"amount_float": 34.8,
"formatted_amount": "$34.80",
"compare_at_amount_cents": 4524,
"compare_at_amount_float": 45.24,
"formatted_compare_at_amount": "$45.24",
"created_at": "2021-08-24T19:59:53.658Z",
"updated_at": "2021-08-24T19:59:53.658Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "ZjwqSkrbgW",
"type": "skus",
"code": "TSHIRTMMFFFFFF000000MXXX",
"name": "White Men T-shirt with Black Logo (M)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMMFFFFFF000000.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.609Z",
"updated_at": "2021-08-24T19:59:53.609Z",
"reference": "TSHIRTMMFFFFFF000000",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "ARXmUZyRKa",
"type": "prices",
"currency_code": "EUR",
"sku_code": "TSHIRTMMFFFFFF000000LXXX",
"amount_cents": 2900,
"amount_float": 29,
"formatted_amount": "β¬29,00",
"compare_at_amount_cents": 3770,
"compare_at_amount_float": 37.7,
"formatted_compare_at_amount": "β¬37,70",
"created_at": "2021-08-24T19:59:53.683Z",
"updated_at": "2021-08-24T19:59:53.683Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "WvAJSAoRKZ",
"type": "skus",
"code": "TSHIRTMMFFFFFF000000LXXX",
"name": "White Men T-shirt with Black Logo (L)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMMFFFFFF000000.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.671Z",
"updated_at": "2021-08-24T19:59:53.671Z",
"reference": "TSHIRTMMFFFFFF000000",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "grBlUPVrzg",
"type": "prices",
"currency_code": "USD",
"sku_code": "TSHIRTMMFFFFFF000000LXXX",
"amount_cents": 3480,
"amount_float": 34.8,
"formatted_amount": "$34.80",
"compare_at_amount_cents": 4524,
"compare_at_amount_float": 45.24,
"formatted_compare_at_amount": "$45.24",
"created_at": "2021-08-24T19:59:53.723Z",
"updated_at": "2021-08-24T19:59:53.723Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "WvAJSAoRKZ",
"type": "skus",
"code": "TSHIRTMMFFFFFF000000LXXX",
"name": "White Men T-shirt with Black Logo (L)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMMFFFFFF000000.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.671Z",
"updated_at": "2021-08-24T19:59:53.671Z",
"reference": "TSHIRTMMFFFFFF000000",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "gmnyUdvqba",
"type": "prices",
"currency_code": "EUR",
"sku_code": "TSHIRTMMFFFFFF000000XLXX",
"amount_cents": 2900,
"amount_float": 29,
"formatted_amount": "β¬29,00",
"compare_at_amount_cents": 3770,
"compare_at_amount_float": 37.7,
"formatted_compare_at_amount": "β¬37,70",
"created_at": "2021-08-24T19:59:53.749Z",
"updated_at": "2021-08-24T19:59:53.749Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "BbpjSEVXkZ",
"type": "skus",
"code": "TSHIRTMMFFFFFF000000XLXX",
"name": "White Men T-shirt with Black Logo (XL)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMMFFFFFF000000.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.739Z",
"updated_at": "2021-08-24T19:59:53.739Z",
"reference": "TSHIRTMMFFFFFF000000",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "pZBYUDoNBp",
"type": "prices",
"currency_code": "USD",
"sku_code": "TSHIRTMMFFFFFF000000XLXX",
"amount_cents": 3480,
"amount_float": 34.8,
"formatted_amount": "$34.80",
"compare_at_amount_cents": 4524,
"compare_at_amount_float": 45.24,
"formatted_compare_at_amount": "$45.24",
"created_at": "2021-08-24T19:59:53.785Z",
"updated_at": "2021-08-24T19:59:53.785Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "BbpjSEVXkZ",
"type": "skus",
"code": "TSHIRTMMFFFFFF000000XLXX",
"name": "White Men T-shirt with Black Logo (XL)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMMFFFFFF000000.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.739Z",
"updated_at": "2021-08-24T19:59:53.739Z",
"reference": "TSHIRTMMFFFFFF000000",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "AJJmULMGwA",
"type": "prices",
"currency_code": "EUR",
"sku_code": "TSHIRTMMFFFFFFE63E74MXXX",
"amount_cents": 2900,
"amount_float": 29,
"formatted_amount": "β¬29,00",
"compare_at_amount_cents": 3770,
"compare_at_amount_float": 37.7,
"formatted_compare_at_amount": "β¬37,70",
"created_at": "2021-08-24T19:59:53.818Z",
"updated_at": "2021-08-24T19:59:53.818Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "ByyESmQNOB",
"type": "skus",
"code": "TSHIRTMMFFFFFFE63E74MXXX",
"name": "White Men T-shirt with Pink Logo (M)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMMFFFFFFE63E74.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.797Z",
"updated_at": "2021-08-24T19:59:53.797Z",
"reference": "TSHIRTMMFFFFFFE63E74",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "gNzPUPmNVg",
"type": "prices",
"currency_code": "USD",
"sku_code": "TSHIRTMMFFFFFFE63E74MXXX",
"amount_cents": 3480,
"amount_float": 34.8,
"formatted_amount": "$34.80",
"compare_at_amount_cents": 4524,
"compare_at_amount_float": 45.24,
"formatted_compare_at_amount": "$45.24",
"created_at": "2021-08-24T19:59:53.855Z",
"updated_at": "2021-08-24T19:59:53.855Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "ByyESmQNOB",
"type": "skus",
"code": "TSHIRTMMFFFFFFE63E74MXXX",
"name": "White Men T-shirt with Pink Logo (M)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMMFFFFFFE63E74.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.797Z",
"updated_at": "2021-08-24T19:59:53.797Z",
"reference": "TSHIRTMMFFFFFFE63E74",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "ajKQUyXWDp",
"type": "prices",
"currency_code": "EUR",
"sku_code": "TSHIRTMMFFFFFFE63E74LXXX",
"amount_cents": 2900,
"amount_float": 29,
"formatted_amount": "β¬29,00",
"compare_at_amount_cents": 3770,
"compare_at_amount_float": 37.7,
"formatted_compare_at_amount": "β¬37,70",
"created_at": "2021-08-24T19:59:53.881Z",
"updated_at": "2021-08-24T19:59:53.881Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "WKjRSbrYvZ",
"type": "skus",
"code": "TSHIRTMMFFFFFFE63E74LXXX",
"name": "White Men T-shirt with Pink Logo (L)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMMFFFFFFE63E74.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.871Z",
"updated_at": "2021-08-24T19:59:53.871Z",
"reference": "TSHIRTMMFFFFFFE63E74",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "AKeQUMlmLa",
"type": "prices",
"currency_code": "USD",
"sku_code": "TSHIRTMMFFFFFFE63E74LXXX",
"amount_cents": 3480,
"amount_float": 34.8,
"formatted_amount": "$34.80",
"compare_at_amount_cents": 4524,
"compare_at_amount_float": 45.24,
"formatted_compare_at_amount": "$45.24",
"created_at": "2021-08-24T19:59:53.916Z",
"updated_at": "2021-08-24T19:59:53.916Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "WKjRSbrYvZ",
"type": "skus",
"code": "TSHIRTMMFFFFFFE63E74LXXX",
"name": "White Men T-shirt with Pink Logo (L)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMMFFFFFFE63E74.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.871Z",
"updated_at": "2021-08-24T19:59:53.871Z",
"reference": "TSHIRTMMFFFFFFE63E74",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "pYwMUExGvg",
"type": "prices",
"currency_code": "EUR",
"sku_code": "TSHIRTMMFFFFFFE63E74XLXX",
"amount_cents": 2900,
"amount_float": 29,
"formatted_amount": "β¬29,00",
"compare_at_amount_cents": 3770,
"compare_at_amount_float": 37.7,
"formatted_compare_at_amount": "β¬37,70",
"created_at": "2021-08-24T19:59:53.943Z",
"updated_at": "2021-08-24T19:59:53.943Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "WJoqSwYAOB",
"type": "skus",
"code": "TSHIRTMMFFFFFFE63E74XLXX",
"name": "White Men T-shirt with Pink Logo (XL)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMMFFFFFFE63E74.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.930Z",
"updated_at": "2021-08-24T19:59:53.930Z",
"reference": "TSHIRTMMFFFFFFE63E74",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "aWQNURXEzA",
"type": "prices",
"currency_code": "USD",
"sku_code": "TSHIRTMMFFFFFFE63E74XLXX",
"amount_cents": 3480,
"amount_float": 34.8,
"formatted_amount": "$34.80",
"compare_at_amount_cents": 4524,
"compare_at_amount_float": 45.24,
"formatted_compare_at_amount": "$45.24",
"created_at": "2021-08-24T19:59:53.997Z",
"updated_at": "2021-08-24T19:59:53.997Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "WJoqSwYAOB",
"type": "skus",
"code": "TSHIRTMMFFFFFFE63E74XLXX",
"name": "White Men T-shirt with Pink Logo (XL)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTMMFFFFFFE63E74.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:53.930Z",
"updated_at": "2021-08-24T19:59:53.930Z",
"reference": "TSHIRTMMFFFFFFE63E74",
"reference_origin": null,
"metadata": {}
}
},
{
"id": "gQVmULNOOa",
"type": "prices",
"currency_code": "EUR",
"sku_code": "TSHIRTWF000000E63E74SXXX",
"amount_cents": 2900,
"amount_float": 29,
"formatted_amount": "β¬29,00",
"compare_at_amount_cents": 3770,
"compare_at_amount_float": 37.7,
"formatted_compare_at_amount": "β¬37,70",
"created_at": "2021-08-24T19:59:54.021Z",
"updated_at": "2021-08-24T19:59:54.021Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"sku": {
"id": "WaDeSqJPEZ",
"type": "skus",
"code": "TSHIRTWF000000E63E74SXXX",
"name": "Black Women T-shirt with Pink Logo (S)",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pellentesque in neque vitae tincidunt. In gravida eu ipsum non condimentum. Curabitur libero leo, gravida a dictum
vestibulum, sollicitudin vel quam.",
"image_url": "https://img.commercelayer.io/skus/TSHIRTWF000000E63E74.png?fm=jpg&q=90",
"pieces_per_pack": null,
"weight": null,
"unit_of_weight": null,
"hs_tariff_number": null,
"do_not_ship": false,
"do_not_track": false,
"created_at": "2021-08-24T19:59:54.008Z",
"updated_at": "2021-08-24T19:59:54.008Z",
"reference": "TSHIRTWF000000E63E74",
"reference_origin": null,
"metadata": {}
}
}
]
Is there something we are doing wrong in this filter? Thanks for your support!
Hi @pviti, we are experiencing a weird error, when associating a shipping method to an order shipment resource.
We created a Redux Thunk action to get the available shipping methods from an order shipment resource and other action to set (select) that shipping method to the shipment resource. When trying to handle the shipment update to associate the shipping method as is indicated in the steps from API docs: https://docs.commercelayer.io/developers/v/how-tos/checkout/selecting-a-shipping-method but using SDK, we experience JS execution breaking without any error and no exception, this are the steps:
We have a shipment resource from a draft order:
{
"id": "YzgnCNnnOa",
"type": "shipments",
"number": "16088866/S/001",
"status": "draft",
"currency_code": "EUR",
"cost_amount_cents": 0,
"cost_amount_float": 0,
"formatted_cost_amount": "$0.00",
"skus_count": 7,
"selected_rate_id": null,
"rates": [],
"purchase_error_code": null,
"purchase_error_message": null,
"get_rates_started_at": null,
"get_rates_completed_at": null,
"purchase_started_at": null,
"purchase_completed_at": null,
"purchase_failed_at": null,
"created_at": "2021-11-29T21:40:31.683Z",
"updated_at": "2021-11-29T21:40:31.683Z",
"reference": null,
"reference_origin": null,
"metadata": {},
"available_shipping_methods": [
{
"id": "RNpozFzMgO",
"type": "shipping_methods",
"name": "Standard Canada",
"disabled_at": null,
"currency_code": "EUR",
"price_amount_cents": 700,
"price_amount_float": 7,
"formatted_price_amount": "β¬7,00",
"free_over_amount_cents": null,
"free_over_amount_float": null,
"formatted_free_over_amount": null,
"price_amount_for_shipment_cents": 700,
"price_amount_for_shipment_float": 7,
"formatted_price_amount_for_shipment": "β¬7,00",
"created_at": "2021-11-29T18:25:37.231Z",
"updated_at": "2021-11-29T18:25:37.231Z",
"reference": "",
"reference_origin": "",
"metadata": {}
}
]
}
There is only one available shipping method so we try to associate it as the selected method in the order shipment with the following code:
const shippingMethodId = 'RNpozFzMgO'
// This object is the one dumped in previous JSON code block
const firstShipment = first(order.shipments)
/**
* @type {ShipmentUpdate}
*/
const updateData = {
id: firstShipment.id,
shipping_method: clClient.shipping_methods.relationship(shippingMethodId),
}
const result = await clClient.shipments.update(updateData)
const updatedOrder = await retrieveOrder(clClient, order.id)
When the call to "clClient.shipments.update" is executed, the Jest test we wrote with an integration test, breaks without any error or exception. It just stop the JS process. Therefore, the retrieve order is never reached.
Here is the date that is composed in updateData variable:
updateData: {
id: 'YzgnCNnnOa',
shipping_method: { id: 'RNpozFzMgO', type: 'shipping_methods' }
}
Can you confirm our procedure to set a shipping method selection is correct? Any idea what could be causing the silent error that breaks execution?
Thanks for your support!
Hi, the Satispay related resources are missing and I was wondering when the schema will be updated. Could you give me an idea of when we might expect the update to happen?
Thanks!
No response
const customers = await cl.customers.list({ filters: { 'email_cont_any': ['[email protected]','[email protected]'] } })
No response
yes, I can
No response
No response
cl.tags.releationship([]) to empty a 1-n relationship
cl.tags.relationship() to empty a 1-1 relationship (would solve also TS type problem)
cl.tags.relationship('id1', 'id2', 'id3') to create a 1-n relationship
...
Make relationship function abstract in parent class to handle common cases
yes, I can
No response
No response
Add the possibility to definr header User-Agent during initialization of Commerce Layer client
No response
yes, I can
No response
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.