-
-}
-
-sub _get_xml_template {
- my $action = shift;
-
- my $xml_template = q|<Request >
- <MerchantData>
- <Platform>[% auth.platform %]</Platform>
- <UserId>[% auth.userid %]</UserId>
- <GID>[% auth.gid %]</GID>
- <Tid>[% auth.tid %]</Tid>
- </MerchantData>
- |;
-
- if ($action eq 'charge') {
- $xml_template .= _get_xml_template_charge();
- }elsif($action eq 'void') {
- $xml_template .= _get_xml_template_void();
- }elsif($action eq 'authorize') {
- $xml_template .= _get_xml_template_auth();
- }elsif($action eq 'authorize_cancel') {
- $xml_template .= _get_xml_template_auth_cancel();
- }elsif($action eq 'refund') {
- $xml_template .= _get_xml_template_refund();
- }elsif($action eq 'capture') {
- $xml_template .= _get_xml_template_capture();
- }elsif($action eq 'create_token') {
- $xml_template .= _get_xml_template_create_token();
- }elsif($action eq 'delete_token') {
- $xml_template .= _get_xml_template_delete_token();
- }elsif($action eq 'query_token') {
- $xml_template .= _get_xml_template_query_token();
- }elsif($action eq 'update_exp_date') {
- $xml_template .= _get_xml_template_update_exp_date();
- }elsif($action eq 'update_token') {
- $xml_template .= _get_xml_template_update_token();
- }
-
- $xml_template .= "</Request>";
- $xml_template =~ s/[\n\t\s]*//g;
-
- return $xml_template;
-}
-
-sub _get_xml_template_charge {
- my $xml_template = q|<ProcessPayment>
- <Amount>[% payment.amount %]</Amount>
- <Trk1>[% payment.track1 %]</Trk1>
- <Trk2>[% payment.track2 %]</Trk2>
- <TypeOfSale>[% payment.type %]</TypeOfSale>
- <Cf1>[% payment.cf1 %]</Cf1>
- <Cf2>[% payment.cf2 %]</Cf2>
- <Cf3>[% payment.cf3 %]</Cf3>
- <AccountNumber>[% payment.account_number %]</AccountNumber>
- <ExpirationMonth>[% payment.exp_month %]</ExpirationMonth>
- <ExpirationYear>[% payment.exp_year %]</ExpirationYear>
- <Cvv>[% payment.cvv %]</Cvv>
- <CardHolderFirstName>[% payment.first_name %]</CardHolderFirstName>
- <CardHolderLastName>[% payment.last_name %]</CardHolderLastName>
- <AvsZip>[% payment.postal_code %]</AvsZip>
- <AvsStreet>[% payment.street_address %]</AvsStreet>
- <IndustryType>
- <IndType >[% payment.industry_type %]</IndType >
- <IndInvoice>[% payment.invoice_num %]</IndInvoice>
- </IndustryType>
- <ApplicationId>[% payment.appid %]</ApplicationId>
- <Recurring>[% payment.recurring %]</Recurring>
- </ProcessPayment>|;
-
- # other options (that we are not using right now):
-# <Level2PurchaseInfo>
-# <Level2CardType>[% level2.card_type %]</Level2CardType >
-# <PurchaseCode>[% level2.purchase_code %]</PurchaseCode>
-# <ShipToCountryCode>[% level2.country_code %]</ShipToCountryCode>
-# <ShipToPostalCode>[% level2.ship_tp_postal_code %]</ShipToPostalCode>
-# <ShipFromPostalCode>[% level2.ship_from_postal_code %]</ShipFromPostalCode>
-# <SalesTax>[% level2.sales_tax %]</SalesTax>
-# <ProductDescription1>[% level2.product_description1 %]</ProductDescription1>
-# <ProductDescription2>[% level2.product_description2 %]</ProductDescription2>
-# <ProductDescription3>[% level2.product_description3 %]</ProductDescription3>
-# <ProductDescription4>[% level2.product_description4 %]</ProductDescription4>
-# </Level2PurchaseInfo>
-# <Level3PurchaseInfo>
-# <PurchaseOrderNumber>[% level3.purchase_order_num %]</PurchaseOrderNumber>
-# <OrderDate>[% level3.order_date %]</OrderDate>
-# <DutyAmount>[% level3.duty_amount %]</DutyAmount>
-# <AlternateTaxAmount>[% level3.alt_tax_amount %]</AlternateTaxAmount>
-# <DiscountAmount>[% level3.discount_amount %]</DiscountAmount>
-# <FreightAmount>[% level3.freight_amount %]</FreightAmount>
-# <TaxExemptFlag>[% level3.tax_exempt %]</TaxExemptFlag>
-# <LineItemCount>[% level3.line_item_count %]</LineItemCount>
-# <PurchaseItems>
-# [% level3.purchase_items %]
-# </PurchaseItems>
-# </Level3PurchaseInfo>
-
- return $xml_template;
-}
-
-sub _parse_line_items {
- my $self = shift;
- my %content = $self->content();
-
- return '' if (!$content{'items'});
-
- my @line_items;
- my $template = q| <LineItem>
- <ItemSequenceNumber>[% seq_num %]</ItemSequenceNumber>
- <ItemCode>[% code %]</ItemCode>
- <ItemDescription>[% desc %]</ItemDescription>
- <ItemQuantity>[% qty %]</ItemQuantity>
- <ItemUnitOfMeasure>[% unit %]</ItemUnitOfMeasure>
- <ItemUnitCost>[% unit_cost %]</ItemUnitCost>
- <ItemAmount>[% amount %]</ItemAmount>
- <ItemDiscountAmount>[% discount_amount %]</ItemDiscountAmount>
- <ItemTaxAmount>[% tax_amount %]</ItemTaxAmount>
- <ItemTaxRate>[% tax_rate %]</ItemTaxRate>
- </LineItem>|;
-
-
- my @items = $content{'items'};
- foreach my $item (@items) {
- # fille in the slots from $template with details in $item
- # push to @line_items
- }
-
- return join("\n", @line_items);
-}
-
-sub _get_xml_template_void {
- my $xml_template = q|<ProcessVoid>
- <Amount>[% payment.amount %]</Amount>
- <AccountNumber>[% payment.account_number %]</AccountNumber>
- <ExpirationMonth>[% payment.exp_month %]</ExpirationMonth>
- <ExpirationYear>[% payment.exp_year %]</ExpirationYear>
- <ReferenceNumber>[% payment.reference_number %]</ReferenceNumber>
- <TransactionDate/>
- <IndustryType1>[% payment.industry_type %]</IndustryType1>
- <ApplicationId>[% payment.appid %]</ApplicationId>
- </ProcessVoid>|;
-
- return $xml_template;
-}
-
-sub _get_xml_template_refund {
- my $xml_template = q|<ProcessRefund>
- <Amount>[% payment.amount %]</Amount>
- <AccountNumber>[% payment.account_number %]</AccountNumber>
- <ExpirationMonth>[% payment.exp_month %]</ExpirationMonth>
- <ExpirationYear>[% payment.exp_year %]</ExpirationYear>
- <ApplicationId>[% payment.appid %]</ApplicationId>
- </ProcessRefund>|;
-
- return $xml_template;
-}
-
-sub _get_xml_template_auth {
- my $xml_template = '';
-
- return $xml_template;