payment system: platnosci.pl

Posts: 5
Joined: 08/22/2007

Hi

I writing module for polish payment system: platnosci.pl
This system offer several types of payment:
- credit card
- transfer for several banks.

I will have:
admin/store/settings/payment/edit/methods
- one configuration: auth_key, id_shop etc.
- checkbox for types of payment

cart/checkout:
- user can choose one of active types of payment

cart/checkout/review:
- form action to platnosci.pl system with order values and type payment

How do it? Smiling

I try:
1) If I define several methods for every type payment in function uc_platnosci_pl_payment_method()
then I have several configuration in admin/store/settings/payment/edit/methods

2) I define one method in uc_platnosci_pl_payment_method and:

<?php
/**
* Implementation of hook_form_alter().
*/
function uc_platnosci_pl_form_alter($form_id, &$form) {
  if (
$form_id == 'uc_cart_checkout_review_form' && ($order_id = intval($_SESSION['cart_order'])) > 0) {
   
$order = uc_order_load($order_id);

    if (
substr($order->payment_method,'platnosci_pl')) {
      unset(
$form['submit']);
     
$form['#prefix'] = '<table style="display: inline; padding-top: 1em;"><tr><td>';
     
$form['#suffix'] = '</td><td>'. drupal_get_form('uc_platnosci_pl_form', $order) .'</td></tr></table>';
    }
  }
  elseif (
$form_id == 'uc_cart_checkout_form') {
   
drupal_set_message('Form elements:<pre>'. print_r($form[panes][payment][pane][payment_method]['#options'], true) .'</pre>');
    unset(
$form[panes][payment][pane][payment_method]['#options'][platnosci_pl]);
   
$form['panes']['payment']['pane']['payment_method']['#options']['platnosci_pl_a'] = 'platnosci: A';
   
$form['panes']['payment']['pane']['payment_method']['#options']['platnosci_pl_b'] = 'platnosci: B';
   
$form['panes']['payment']['pane']['payment_method']['#options']['platnosci_pl_c'] = 'platnosci: C';
  } else {
   
drupal_set_message('Form elements:<pre>'. print_r($form_id, true) .'</pre>');
  }
}
?>

Any other/better ideas?

Thanks,
Artur

Posts: 5367
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Hey Artur! Glad to see you're working on this. You seem to be on the right track with where you expect forms and things to be, but there's a better way to make it all work. The Payment system was designed so you can use the hooks to add your info to the forms without having to use hook_form_alter().

Also, if this is primarily to be used for CC payments, you may consider simply using hook_payment_gateway() to interface with the credit module. I guess I'd need to know a little more about that service to help out... for example, if it's a redirect service like PayPal Website Payments Standard, you'll need to keep using hook_payment_method().

Posts: 5
Joined: 08/22/2007

Thanks Smiling I'll look at this and write later.