v1.7.1
Version 1.7.1
of Medusa introduces the JobSchedulerService
which changes how scheduled/cron jobs are created.
Overview
Version 1.7.1
of Medusa introduces a new service JobSchedulerService
that handles all logic and functionality related to created scheduled (previously named cron jobs).
With this introduction, the previous use of EventBus
to create a cron job has been deprecated of using the JobSchedulerService
.
In addition, this version features some fixes to gift cards that requires running migrations, and changes to how payment providers are implemented.
Actions Required
Run Migrations
In the directory of your Medusa backend, run the following command after updating the backend:
Run Migration Script
Following the fix gift cards calculation, you also need to run a migration script after updating the backend.
Start by adding the following environment variables in .env
:
Make sure to replace <DATABASE_URL>
, <DATABASE_USERNAME>
, <DATABASE_PASSWORD>
, and <DATABASE_DATABASE>
with your database connection details.
Then, run the following command in the root directory of your Medusa backend:
Change to JobSchedulerService
In your loader file that creates a cron job, replace the use of eventBus
to jobSchedulerService
:
You can learn more in the How to Create a Scheduled Job documentation.
Change to Payment Provider
This version of Medusa introduces a change in how payment providers are implemented. Mainly, the signature of the createPayment
and updatePayment
methods have changed, and the old signature is now deprecated.
Although this change is currently backwards compatible, it is recommended to change the signature of these methods to the following:
import { Cart, PaymentSessionData, PaymentContext, PaymentSessionResponse } from "@medusajs/medusa"
// ...
class MyPaymentService extends AbstractPaymentService<TransactionBaseService> {
// ...
async createPayment(
context: Cart & PaymentContext
): Promise<PaymentSessionResponse> {
// ...
}
async updatePayment(
paymentSessionData: PaymentSessionData,
context: Cart & PaymentContext
): Promise<PaymentSessionResponse> {
// ...
}
}
Where context
in both createPayment
and updatePayment
is made up of the following properties:
So, you can pass the previous cart
parameter inside the new context
parameter.
Furthermore, these methods are now expected to return PaymentSessionResponse
. It is made up of the following properties:
Where session_data
would include the previously returned data from these methods. The property update_requests
allows you to pass data from the payment provider plugin to the core to update internal resources. Currently, it can only be used to update the metadata
field of the customer entity.