#monasterydreams

1 messages · Page 1 of 1 (latest)

pastel swallowBOT
gaunt quiver
tranquil burrow
#

Here is the whole code for context



import BrandIcon from "./brand_icon.svg";

// Initiate communication with the stripe client.
const stripe = new Stripe(STRIPE_API_KEY, {
  httpClient: createHttpClient(),
  apiVersion: '2022-08-01',
})

const ProductDetailView = ({userContext, environment}: ExtensionContextValue) => {

// Call the Stripe API to make updates to customer details.
const updateCurrentProduct = async (newProductName) => {
  try {
    // If the user has permission to update customers, this should succeed.
    const updatedProduct = await stripe.products.update(
      // We can use the current objectContext to get the customer ID.
      environment.objectContext.id,
      {name: newProductName}
    );

    console.log(updatedProduct.name);
  } catch (error) {}
};


const refreshDashboardData = useRefreshDashboardData();

// Stripe API call
const updateProduct = useCallback(async () => {
  try {
    await updateCurrentProduct();

    // Call to refresh the data on the dashboard
    refreshDashboardData();
  } catch (error) {}
}, [refreshDashboardData]);

  return (
    <ContextView
      title="Hello world"
      externalLink={{
        label: "View docs",
        href: "https://stripe.com/docs/stripe-apps",
      }}
    >
              <Button onPress={() => updateProduct("Test")}>Update Product</Button>

     

    </ContextView>
  );
};

export default ProductDetailView;
#

ok will share

#

request ID one of a few req_vGgtTSKS0k3yKg

#

oh I think I know what I did one sec

#

It worked, I was calling the wrong function, thanks for helping