Get your keys from Midtrans
Pick the environment
Open the access keys
Copy the keys
Set the notification URL in Midtrans
Open the payment settings
Enter the URL
Save
Add the keys in MagicPost
Open the Midtrans card
Enable it
Paste the keys
- Live Midtrans Client Key
- Live Midtrans Server Key
- Sandbox Midtrans Client Key
- Sandbox Midtrans Server Key
Save
How payments work
One-time plans (Prepaid, Lifetime). MagicPost creates a Midtrans Snap transaction with an order ID that starts withPRE-, followed by the plan’s internal number and a random string. The window opens on a page that shows “Opening Midtrans…”. If it does not appear, the page offers an Open Midtrans button.
When the customer finishes, MagicPost asks Midtrans for the order status:
settlementorcapturerecords the order. For Lifetime plans MagicPost also creates the subscription.pendingorauthorizeshows “Your payment is being processed. You will be notified once confirmed.” and sends the customer to the Billing page.- Anything else shows “Payment was not completed.”
accept, and the notification carries the user and plan details MagicPost attached to the order (the custom_field1 and custom_field2 values). Cancelled, expired, denied and failed notifications are only written to the log.
Recurring plans (Monthly, Yearly). The first payment is a Snap transaction with an order ID that starts with SUB-, and the card is saved with 3-D Secure turned on. Once it is paid, MagicPost creates a Midtrans subscription from the saved card token. Midtrans has no plan objects, so there is nothing to create ahead of time.
The subscription MagicPost registers has these properties:
- It repeats every 1 month for a Monthly plan and every 1 year for a Yearly plan, with no end.
- Its start time is one day after the first payment.
- Its amount is the plan price rounded to a whole number, in the plan’s currency.
Currency
MagicPost sends the Snap amount as a whole number (the plan price rounded) and does not send a currency code with it, so create Midtrans plans with a currency Midtrans Snap can charge, normally IDR. The recurring subscription also sends the plan’s currency, defaulting to IDR when a plan has none.Test mode
Put the sandbox Client Key and Server Key in the two Sandbox fields, select Sandbox under Mode and save. MagicPost then calls Midtrans’ sandbox API and loads the sandbox Snap script. Set the Payment Notification URL in the sandbox environment too. Switch Mode back to Live before you sell.Common errors
This payment method is not available right now.
This payment method is not available right now.
We could not start the payment. Please try again or contact support.
We could not start the payment. Please try again or contact support.
Midtrans could not start the payment. Please try again. / Midtrans returned an unexpected response.
Midtrans could not start the payment. Please try again. / Midtrans returned an unexpected response.
storage/logs/laravel.log.We could not prepare this plan for Midtrans billing. Please contact support.
We could not prepare this plan for Midtrans billing. Please contact support.
Missing Midtrans session reference. / Midtrans status lookup failed.
Missing Midtrans session reference. / Midtrans status lookup failed.
Midtrans shows the notification failing with status 400
Midtrans shows the notification failing with status 400
invalid signature: the Server Key saved for the active Mode is not the one for the environment that sent the notification.
