Closed sats268842 closed 1 year ago
Does it return an error? Can you post the response from Postman?
The method needs to be POST and the body should be formatted like this, as an example:
{
"template_id":"order_placed",
"from":"Company <orders@company.com>",
"to":"me@example.com",
"data": {
"customer": {
"first_name": "Pevey"
}
}
}
ALSO, be sure that you are pulling that environment variable into your medusa-config.js, like so:
{ resolve: `medusa-plugin-ses`, options: { ... enable_endpoint: process.env.SES_ENABLE_ENDPOINT, ... } },
Also I hardcoded "42" as the value for "enable_endpoint" in the medusa-config.js file.
Can you post the plugin portion of your config file, with the secrets removed? I would imagine it is a formatting error.
{
resolve: medusa-plugin-ses
,
options: {
access_key_id: '**',
secret_access_key: '',
region: '****',
from: '***',
enable_endpoint: '42',
template_path: __dirname+ '/data/templates',
order_placed_template: 'order_placed',
order_shipped_template: 'order_shipped',
customer_password_reset_template: 'customer_password_reset',
user_password_reset_template: 'user_password_reset',
gift_card_created_template: 'gift_card_created',
order_canceled_template: 'order_canceled',
order_refund_created_template: 'order_refund_created',
order_return_requested_template: 'order_return_requested',
order_items_returned_template: 'order_items_returned',
swap_created_template: 'swap_created',
swap_shipment_created_template: 'swap_shipment_created',
swap_received_template: 'swap_received',
claim_shipment_created_template: 'claim_shipment_created',
medusa_restock_template: 'medusa_restock',
}
}
I'm quite baffled. The only condition for which it should return false
instead of an error is here on line 166 of the services/ses.js file:
if (this.options_.enable_endpoint !== '42') { return false }
It is working properly in my setup, and I have the latest version from npm installed.
If you recently changed the setting in the config, did you restart your server to be sure the changes were loaded?
Maybe someone else will have more ideas you can try.
I looked at the code again, and there is another case in which it will return false.
if (!subject || (!html && !text)) { return false }
If there is an issue compiling the templates, it will return false. Do you have a subject.hbs and either a text.hbs OR html.hbs for the template_id you are trying to use?
I bet that is the issue, not the setting to enable the endpoint. In the next version, I will capture these errors and return them via the API to make debugging templates a bit easier. Maybe I can do that tonight.
HTML template path was not rendering correctly, but it is now working. Thanks
This was addressed in version 2.0.9. The API now returns a more useful error message when templates are not found or compile errors are encountered.
SES_ENABLE_ENDPOINT is set to '42' in the environment variable, but when I checked the endpoint with Postman, it was always returning a false value.