Akopia Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

RE: [ic] Can i use http post for payment verification?



Hi,
Here is the code to implement itransact's http protocal.  It is a proof of
concecpt that we whipped up one afternoon, but should be mostly
functional.  At the very least, a good starting point for implementing a
similar system.  It is undocumented at the moment, but if somebody asks
nice and specific questions regarding the code, I will probably answer
them.

---
Sonny Cook 
Akopia

"I don't want fifteen dollars."  --Franklin D. Rooselvelt

On Thu, 19 Oct 2000, Cameron B. Prince wrote:

> Yes, you can do this. What you will need to do is create a Global Sub that
> uses LWP to submit the form and wait for results.
> 
> Sonny Cook and I coded a module for iTransact that does just that. I have
> copied him on this note so maybe he will post that module to the list. It's
> on his machine right now. You should be able to modify the iTransact module
> to fit your payment gateway's form.
> 
> Good luck,
> 
> Cameron
> 
> 
> 
> -----Original Message-----
> From: interchange-users-admin@minivend.com
> [mailto:interchange-users-admin@minivend.com]On Behalf Of Nik Lim
> Sent: Thursday, October 19, 2000 2:19 AM
> To: interchange-users@minivend.com
> Subject: [ic] Can i use http post for payment verification?
> 
> 
> Can Interchange support http post method for payment verification? I am
> using www.paydirect.com.my as the hosted payment server. It uses hidden
> field in the shopping cart to post merchant information, order id, billing
> amount
> to paydirect system. Users key in credit card info at paydirect pages and
> upon successful or failure, they are redirect back to my site. Here are the
> compulsory hidden fields for paydirect system to work.
> 
> 1) MerchantApprovalURL
> 2) MerchantUnApprovalURL
> 3) MerchantReturnURL
> 4) TransactionType
> 5) CurrencyCode
> 6) FullTotal
> 7) Merchantname
> 8) MerchantEmail
> 9) OrderID
> 
> Any one have any idea if these can work with Interchange?
> 
> ___________________________________________________
> Nik Lim
> Special Project Manager
> Catcha.com
> 
> Phone (60)3 7490 9999
> Fax (60)3 7490 9900
> DID (60)3 7490 9962
> 
> Mobile +6012 395 8800
> 
> www.catcha.com.my
> We know .my better
> 
> www.catcha.com
> South East Asia's Leading Network of Localised Portals
> ___________________________________________________
> 
> 
> _______________________________________________
> Interchange-users mailing list
> Interchange-users@www.minivend.com
> http://www.minivend.com/mailman/listinfo/interchange-users
> 
> 
> _______________________________________________
> Interchange-users mailing list
> Interchange-users@www.minivend.com
> http://www.minivend.com/mailman/listinfo/interchange-users
> 
GlobalSub <<EOS
sub itransact {

  my %actual = Vend::Order::map_actual();

  $actual{mv_credit_card_exp_month} =~ s/\D//g;
  $actual{mv_credit_card_exp_month} =~ s/^0+//;
  $actual{mv_credit_card_exp_year} =~ s/\D//g;

  my $exp_year = $actual{mv_credit_card_exp_year};
  $exp_year += 2000 unless $exp_year =~ /\d{4}/;

  $actual{mv_credit_card_number} =~ s/\D//g;

  my @month = (qw/January
				 Febuary
				 March
				 April
				 May
				 June
				 July
				 August
				 September
				 October
				 November
				 December/);

  my $exp_month = @month[$actual{mv_credit_card_exp_month} - 1];
  my $precision = $::Variable->{MV_PAYMENT_PRECISION} ||
	$::Variable->{CYBER_PRECISION} || 2;
  my $amount = Vend::Interpolate::total_cost();
  $amount = sprintf("%.${precision}f", $amount);

  my $address = $actual{b_address1};
  my $address .= ", $actual{b_address2}" if $actual{b_address2};

  ::logDebug("address: $address\n actual-address: " . $actual{address});

  my %values = (
				vendor_id   =>   $::Variable->{MV_MERCHANT_ID},
				home_page   =>   "http://"; . $::Variable->{SERVER_NAME},
				ret_addr    =>   "success",
				'1-qty'     =>   1,
				'1-desc'    =>   $::Variable->{COMPANY}. " Order",
				'1-cost' 	=>   $amount,
				first_name  =>   $actual{b_fname},
				last_name   =>   $actual{b_lname},
				address     =>   $actual{address},
				city        =>   $actual{b_city},
				state       =>   $actual{b_state},
				zip         =>   $actual{b_zip},
				country     =>   $actual{b_country},
				phone       =>   $::Values->{phone_day},
				email       =>   $::Values->{email},
				ccnum       =>   $actual{mv_credit_card_number},
				ccmo        =>   $exp_month,
				ccyr        =>   $exp_year,
				ret_mode    =>   "redirect",
			   );

  my $submit_url = "https://secure.itransact.com/cgi-bin/rc/ord.cgi";;
  use LWP::UserAgent;
  use HTTP::Request::Common qw(POST);

  my $ua = LWP::UserAgent->new();
  my $req = POST $submit_url, \%values;

  my $resp = $ua->request($req);
  my %result;

  ## check for errors
  my $error;
  unless ($resp->as_string() =~ m/Location: success/) {
	my $content = $resp->content();
	if ($content =~ m/BEGIN ERROR DESCRIPTION --\>(.*)\<\!-- END ERROR DESCRIPTION/s) {
	  $error = $1;
	  $error =~ s/\<.*?\>//g;
	  $error =~ s/[^-A-Za-z_0-9 ]//g;
	} else {
	  ## something very bad happened
	  $error = "something bad happened--we don't know what is is.";
	}

	::logError("iTransact Error: " . $error);
	$result{MStatus} = 'denied';
	$result{ErrMsg} = $error;

	return %result;
  }

  ## at this point, we assume everything worked just fine
  $result{MStatus} = 'success';
  $result{'order-id'} = "1";

  return %result;
}
EOS

Search for: Match: Format: Sort by: