Midtrans ❤️ Drupal 8/9! Let your Drupal Commerce 2 store integrated with Midtrans payment gateway.
This is the official Midtrans module for the Drupal Commerce 2 E-commerce platform. Also Available on Drupal Project Module
Want to see Midtrans Drupal payment plugins in action? We have some demo web-stores for Drupal that you can use to try the payment journey directly, click the link below.
2.1.0 (for Drupal v8.x and Drupal v9.x)
The following module is tested under following environment:
- PHP v5.6.x or greater
- MySQL version 5.0 or greater
- Drupal v8.x or greater
- Drupal Commerce 8.x-2.xx
If you are using Composer, you can install via composer CLI
- Open terminal
- Move to your drupal site folder:
cd /[drupal site folder]/
- Run:
composer require drupal/midtrans_commerce
The manual installation method involves downloading our feature-rich plugin and uploading it to your webserver via your favourite FTP application.
- Download the plugin file to your computer and unzip it, rename folder to
midtrans_commerce
. - Using an FTP program, or your hosting control panel, upload the unzipped plugin folder to your Drupal modules installation's
[Drupal folder]/modules/contrib/
directory.
- Open drupal admin page, open menu Extend.
- Look for Commerce Midtrans modules under COMMERCE (CONTRIB) group, enable by ticking the checkboxes.
- Scroll down and click Install.
- Go to Commerce > Configuration > Payment > Payment gateways.
- Look for Midtrans and click it.
- Click Add payment gateway, click Midtrans under Plugin Actions.
- Fill the following config fields as instructed on each settings description.
- Click save.
- Now Snap Midtrans should appear as a payment options when your customer checkout.
- Go to Settings > Configuration.
- Insert
http://[your web]/payment/notify/midtrans
as your Payment Notification URL in your MAP. - Insert
http://[your web]/payment/finish/midtrans
link as Finish/Unfinish/Error Redirect URL in your MAP configuration.
Note on Customer Phone Number
Unfortunately Drupal Commerce by default doesn't have phone number
as customer data [1], so there will be no phone
data passed to Midtrans side.
If you have modified your Drupal Commerce site to have phone number input field, you may want to customize/edit this payment module to also send phone
data to Midtrans side.
You can do so by editing these line of codes in this file /src/PluginForm/MidtransForm.php
:
Midtrans-Drupal8/src/PluginForm/MidtransForm.php
Lines 173 to 181 in 12c1e4b
You can uncomment this line:
//'phone' => ,
Then modify it to something like this:
'phone' => myCustomFunctionToGetCustomerPhone(),
But you will need to figure out on your own, how to programmatically retrieve customer phone
number based on your site implementation.
You can also add more custom Snap API payload to add more data related to the transaction. Learn more on the API payload on Snap API docs
[1] At this time of writing, based on
[DrupalCommerceFolder]/modules/contrib/address/src/Plugin/Field/FieldType/AddressItem.php
, the class doesn't have any phone attribute by default.And no explanation of it on the Drupal Commerce PG module development guide
- Please follow this step by step guide for complete configuration. If you have any feedback or request, please do let us know here.
- Midtrans sandbox login
- Midtrans production login
- Midtrans registration
- Midtrans documentation
- Technical support [email protected]