payment gateway 2 digit month

Posts: 34
Joined: 08/19/2007

Just putting the finishing touches on a beanstream gateway
they (bank) want the submission to include 2 digits for the cc exp month and year

i found some code for shortening the year to 2 digits (from linkpoint API module)
'trnExpYear' => substr($order->payment_details['cc_exp_year'], 2, 2),
that works fine...

however for the month it works for oct nov dec (10,11,12) but not the other months
i.e. sept (is 9 I need it to be 09)
any thoughts on how to add a zero only when the month is one digit
here is the line that drops the month value into the array
'trnExpMonth' => $order->payment_details['cc_exp_month'],

thanks

Posts: 50
Joined: 08/17/2007
Getting busy with the Ubercode.Spreading the word - Ubercart for president.

I had to do that when I wrote the myvirtualmerchant payment module. Here's the code to do the trick:

if (intval($order->payment_details['cc_exp_month']) < 10){
    $expdate = '0'. $order->payment_details['cc_exp_month'] . substr($order->payment_details['cc_exp_year'], 2);
  }
  else {
    $expdate = $order->payment_details['cc_exp_month'] . substr($order->payment_details['cc_exp_year'], 2);
  }

Then, when you are calling the expiration date, you now use $expdate which will be two digits long...

-Aaron