Gossamer Forum
Home : Products : Gossamer Mail : Discussion :

Custom Payment Module

Quote Reply
Custom Payment Module
Hi

Here in Norway, we seldom use the large international payment processors, and therefore, need our own. I am trying to make my custom payment module and have come so far:

I have managed to collect all info (I have changed the worldPay template and renamed it in Globals) and sent the user to the payment gateway, so far so good.

But when the payment is sent back, I need some code change in postback-module (since I used the WorldPay-module, I assume Payment->Remote->WorldPay.pm is the correct file to change this in).

I do my own payment check in php and sends the data back to postback.cgi. Therefore, I only need the pay code and do not need any error checking at all. So bacically, I want a "dummy" function in the perl code to log the payment as paid. I do not need recuring payments, only one time payments (and manual renewals, itīs the same, I assume).

I have tried to remove some of the code I do not need and changed it sligthly. But I only get Internal Server Error on whatever I do with this.

Suggestion to later: A custom payment module would have been nice.. Where you spesify the returned values and different required params like gateway url etc.

If anyone would help me in the rigth direction, I would appriciate it ! If not in perl, the sql-codes executed would also be helpfull.


# Glue between GMail and WorldPay payment interface
package GMail::Payment::Remote::WorldPay;
use strict;
# Make sure the payment module is available
use GT::Payment::Remote::WorldPay;
use GMail qw/$IN $CFG $DB $USER/;
use GMail::Payment qw/:status :log/;
use vars qw/%INVALID %EMPTY/;

sub postback {
# -----------------------------------------------------------------------------
my $pay = $DB->table('payments');
my $log = $DB->table('payment_logs');


my $unique = $IN->param('cartId');
my $payment = $pay->select({ payments_id => $unique })->fetchrow_hashref
or return; # Whatever it is, we didn't create it.
my $end = 0; # Returned after processing - if true, a blank page will be displayed,
# if false, a worldpay receipt page.
GT::Payment::Remote::WorldPay::process(
param => $IN,
on_valid => sub {
# A one-time payment (or the initial payment, in the case of recurring payments)
return unless $IN->param('amount') == $payment->{payments_amount};
return if $payment->{payments_status} == COMPLETED;
$pay->update(
{ payments_status => COMPLETED, payments_last => time },
{ payments_id => $payment->{payments_id} }
);
$log->insert({
paylogs_payments_id => $payment->{payments_id},
paylogs_type => LOG_ACCEPTED,
paylogs_time => time,
paylogs_text => (
sprintf($CFG->{language}->{PAYMENT_REMOTE_APPROVED} => 'WorldPay') . "\n" .
"Transaction ID: " . $IN->param('transId') . "\n" .
"Amount: " . $IN->param('amountString') . " (" . $IN->param('authAmountString') . ")\n" .
($IN->param('futurePayId') ? "FuturePay ID: " . $IN->param('futurePayId') . "\n" : "") .
"Authorization Message: " . $IN->param('rawAuthMessage') . "\n"
)
});
GMail::Payment::process_payment($payment->{payments_userid}, $payment->{payments_term}, $payment->{payments_level});
$end = 0;
},

if ($end) {
print $IN->header;
}
else {
$USER->load_user_by_id($payment->{payments_userid});
GMail->print_page($CFG->{states}->{'GMail::Payment'}->{confirm}->[0]->[0]);
}
}
1;
Quote Reply
Re: [areh] Custom Payment Module In reply to
I found out that the log in GT Mail said this:

Invalid postback:
cartId => 19f050d618a7bf4c
amount => 1
amountString => 1
t => brewt


What is the error with this?
Quote Reply
Re: [areh] Custom Payment Module In reply to
Never mind, I will compare changes before and after payment and implement my own postback.php, I came across other problems and would need to do it through sql manually.
Quote Reply
Re: [areh] Custom Payment Module In reply to
Any further experience for a custom Payment Module development?
Did you able to solve it?
Any hints for me, how to develop my own Payment Module?

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...