veritrans / SNAP-Woocommerce

MIT License
19 stars 16 forks source link

Payment paid via Midtrans WC plugin does not have WC Order's transaction ID #54

Closed oxcid closed 2 years ago

oxcid commented 3 years ago

Hi,

Currently using Midtrans - WooCommerce Payment Gateway version 2.22.0.

Wanted to confirm if it's actually by design not to return transaction ID ( https://woocommerce.github.io/code-reference/classes/WC-Order.html#method_get_transaction_id ) ?

I tried using sandbox mode, and credit card payment method.

I asked because one of the plugins I'm working with actually rely on the transaction ID to confirm whether a payment was made or not.

Thanks.

rizdaprasetya commented 3 years ago

Hi @oxcid thanks for reaching us! Did you mean order paid with Midtrans WC plugins does not have WC order transaction ID? Looks like this is not intentional (e.g. the param/function to set transaction ID was not available at the time this plugin was developed), and we will be adding it in future version. Thanks for letting us know your needs.

But if you are in a hurry and want to add it right now, this is what we can quickly identify to fix the issue: Replace these codes here: https://github.com/veritrans/SNAP-Woocommerce/blob/9bd6102d6b7401bc16f72e3b42bec5daca38b9dd/class/class.midtrans-gateway-notif-handler.php#L261

https://github.com/veritrans/SNAP-Woocommerce/blob/9bd6102d6b7401bc16f72e3b42bec5daca38b9dd/class/class.midtrans-gateway-notif-handler.php#L281

With:

$order->payment_complete($midtrans_notification->transaction_id);

Thus will add transaction ID to successfully paid WC orders.

Additionally, do you mind explaining what is your use case with WC transaction ID? what is it being used for, and/or what plugin use it for? So we can further understand and identify if there is better way to implement it according to the needs.

Thanks! 🙂

rizdaprasetya commented 2 years ago

Hi @oxcid this now has been addressed on latest relase 3 days ago, you can update to latest v2.30.0 https://wordpress.org/plugins/midtrans-woocommerce Thanks! hope it solve your issue!

oxcid commented 1 year ago

Thanks @rizdaprasetya , appreciated! It did solve my issue.