How do I update customer store credit programmatically

How do I update customer store credit programmatically

August 14, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How do I update customer store credit programmatically

Updating Customer Store Credit in Magento: A Step-by-Step Guide

Hello developers! Today, we’re going to dive into the world of Magento and explore how to update customer store credit programmatically. If you’re familiar with Laravel, you’ll find that Magento also provides a robust set of APIs for handling such tasks. Let’s jump right in!

Understanding Customer Store Credit in Magento

Before we begin, let’s quickly recap what customer store credit is in Magento. It refers to the virtual money that customers can use as payment towards their orders. This feature is quite useful for rewards programs or as a retention tool.

In Magento 1.x (which you’re using), customer store credit is managed through the core_resource and salesrule_quote_rule tables. The core_resource table stores the total amount of store credit available, while salesrule_quote_rule links this to specific customers.

Why Create a Credit Memo?

You mentioned finding code that creates a credit memo. In Magento, a credit memo is a document used to reverse an invoice or order total, essentially adding money back to a customer’s account (which increases their store credit). Creating a credit memo could indeed be one way to update the store credit balance.

However, there are other ways to achieve this without necessarily creating a credit memo. This depends on your specific use case and requirements. For example, if you have a single customer who needs a manual adjustment to their store credit, it might not make sense to create a full credit memo process when a simple database update would suffice.

Updating Customer Store Credit Directly

Given that you’re making an HTTP request from a server, let’s explore the direct approach using Magento’s web API layer. The salesOrderCreditmemo resource allows you to manage credit memos and therefore modify store credit directly.

Here’s a step-by-step guide:

  1. Authenticate: First, you need to authenticate your request by providing valid credentials (username and password). You can set these up in the Magento admin panel under System > Web Setup Wizard > Secure > Set Up Authentication for Integrated Solutions.

  2. Create API Request: Use the salesOrderCreditmemo resource with a POST method to create a new credit memo. In your JSON payload, specify the customer ID and the amount of store credit you want to add or subtract.

Here’s an example using cURL:

curl -X POST -H "Content-Type: application/json" -d '{"entity_id": 12345, "adjustment_negative": 50.00}' http://<your_magento_url>/index.php/rest/V1/salesOrderCreditmemo

Replace 12345 with the actual customer ID and adjust the amount as needed.

  1. Process Response: The API will return a JSON response containing the new credit memo details, including the updated store credit balance for that customer.

Remember to handle errors gracefully and ensure you have proper exception handling in place, especially if your request fails due to network issues or invalid credentials.

Conclusion

In this post, we’ve explored two primary methods for updating customer store credit in Magento: using credit memos (ideal for complex scenarios) and direct API manipulation (great for simple adjustments).

The choice between these approaches depends on your specific business logic. If you’re dealing with a single adjustment or processing data from an external system, the direct API method is usually more efficient.

As always, make sure to test any updates thoroughly in a staging environment before deploying them to production. This helps avoid unexpected impacts on customer balances and maintains data integrity within your Magento setup.

Happy coding! If you’re looking for more advanced Magento customizations or need expert assistance with your eCommerce platform, don’t hesitate to reach out to Laravel Company. Our team of experienced developers is always ready to help!

Until next time, keep exploring the endless possibilities of Magento development!

Magento 1 Database API Orders

Our network