Jump to content

Determine ID of payment used in order


Recommended Posts

No, un

 

 

LOL. Sorry I think I deleted the method name  by mistake
 

$order_payment = OrderPayment::getByOrderId($id_order);

 

Unfortunately not :(

 

 

 

Array ( [0] => OrderPayment Object ( [order_reference] => IXLSJUSDA [id_currency] => 1 [amount] => 10.32 [payment_method] => Bankoverførsel [conversion_rate] => 1.000000 [transaction_id] => [card_number] => [card_brand] => [card_expiration] => [card_holder] => [date_add] => 2017-07-21 22:40:56 [id] => 5 [id_lang:protected] => [id_shop:protected] => [id_shop_list] => [get_shop_from_context:protected] => 1 [table:protected] => order_payment [identifier:protected] => id_order_payment [fieldsRequired:protected] => Array ( [0] => id_currency [1] => amount ) [fieldsSize:protected] => Array ( [order_reference] => 9 [transaction_id] => 254 [card_number] => 254 [card_brand] => 254 [card_expiration] => 254 [card_holder] => 254 ) [fieldsValidate:protected] => Array ( [order_reference] => isAnything [id_currency] => isUnsignedId [amount] => isNegativePrice [payment_method] => isGenericName [conversion_rate] => isFloat [transaction_id] => isAnything [card_number] => isAnything [card_brand] => isAnything [card_expiration] => isAnything [card_holder] => isAnything [date_add] => isDate ) [fieldsRequiredLang:protected] => Array ( ) [fieldsSizeLang:protected] => Array ( ) [fieldsValidateLang:protected] => Array ( ) [tables:protected] => Array ( ) [webserviceParameters:protected] => Array ( ) [image_dir:protected] => [image_format:protected] => jpg [def:protected] => Array ( [table] => order_payment [primary] => id_order_payment [fields] => Array ( [order_reference] => Array ( [type] => 3 [validate] => isAnything => 9 ) [id_currency] => Array ( [type] => 1 [validate] => isUnsignedId [required] => 1 ) [amount] => Array ( [type] => 4 [validate] => isNegativePrice [required] => 1 ) [payment_method] => Array ( [type] => 3 [validate] => isGenericName ) [conversion_rate] => Array ( [type] => 4 [validate] => isFloat ) [transaction_id] => Array ( [type] => 3 [validate] => isAnything => 254 ) [card_number] => Array ( [type] => 3 [validate] => isAnything => 254 ) [card_brand] => Array ( [type] => 3 [validate] => isAnything => 254 ) [card_expiration] => Array ( [type] => 3 [validate] => isAnything => 254 ) [card_holder] => Array ( [type] => 3 [validate] => isAnything => 254 ) [date_add] => Array ( [type] => 5 [validate] => isDate ) ) [classname] => OrderPayment ) [update_fields:protected] => [force_id] => ) ) 1

 

I don't see the ID mentioned in there (should be 3)

The only numer 3 I see is related to some creditcard information.

Link to comment
Share on other sites

Are you looking for payments from `ps_order_payment` table ?
I see there is an `id_order_paymentdot.gif` fields as primary key.
 
From OrderPayment.php file here are the methods. I think

$order_payment->id_order_payment;

  will return the payment id. Never tested, but I think you're closer..
 

/**

* Get the detailed payment of an order
*
* @deprecated 1.5.3.0
* @param int $id_order
* @return array
*/
public static function getByOrderId($id_order)
{
Tools::displayAsDeprecated();
$order = new Order($id_order);
return OrderPayment::getByOrderReference($order->reference);
}
/**
* Get the detailed payment of an order
* @param int $order_reference
* @return array
* @since 1.5.0.13
*/
public static function getByOrderReference($order_reference)
{
return ObjectModel::hydrateCollection(
'OrderPayment',
Db::getInstance()->executeS(
'SELECT *
             FROM `'._DB_PREFIX_.'order_payment`
             WHERE `order_reference` = \''.pSQL($order_reference).'\''
)
);
}
Link to comment
Share on other sites

I need to get the ID of the payment type used in the order, but I can only find the translated name for the payment.

$order = new Order($params['id_order']);
$payment = $order->payment;

Do any of you guys know how to get the ID?

Can you better explain what the "ID of a payment type" is?  Are you referring to a Transaction ID?

 

What payment module are you using?  Who is the payment provider? 

Link to comment
Share on other sites

Can you better explain what the "ID of a payment type" is?  Are you referring to a Transaction ID?

 

What payment module are you using?  Who is the payment provider? 

 

 

Yes.

I want to match the used payment option in the order with that returned from PaymentModule::getInstalledPaymentModules()

 

Example:

A customer pays by bankwire (ID 3), then I need some way to get that specific ID from the order, to match it up against some actions based on settings for PaymentModule::getInstalledPaymentModules()

I'm writing a module that hooks into hookPostUpdateOrderStatus, to do different actions regarding to accounting, as putting values in a ledger.

But I need to differentiate the account number in the ledger to match the used payment option.

 

Hope that makes sense :)

Link to comment
Share on other sites

Based on your latest code you're trying to find what order was made with what payment module? If that's the case

$paymentModules = PaymentModule::getInstalledPaymentModules();
$order = new Order($id_order);
$order_module = $order->module // will return the payment module eg. ps_checkpayment , ps_wirepayment
foreach ($paymentModules as $pM)
{
     if ( $pM["id_module"] == $order_module ) {
     //Do something
     break;
     }
}

Is this what you're looking for?

Link to comment
Share on other sites

Based on your latest code you're trying to find what order was made with what payment module? If that's the case

$paymentModules = PaymentModule::getInstalledPaymentModules();
$order = new Order($id_order);
$order_module = $order->module // will return the payment module eg. ps_checkpayment , ps_wirepayment
foreach ($paymentModules as $pM)
{
     if ( $pM["id_module"] == $order_module ) {
     //Do something
     break;
     }
}

Is this what you're looking for?

 

Not quite as this will return the translated name of the module - hence the wish for the ID and not the name.

Link to comment
Share on other sites

Not quite as this will return the translated name of the module - hence the wish for the ID and not the name.

 

Sorry - I stand corrected, it actually seems to return the module name, and not the localized (translated) name.

 

I'll try and Work with this, as it might do the work.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...