2 # * AdditionalFields are used to hold fields that do not have separate
\r
3 # * specifications. Each AdditionalField consists of a name and a value,
\r
4 # * which are set in the constructor and are retrieved using the get methods.
\r
6 # * TransactionRequests (including CreditCardRequests) hold
\r
7 # * a Vector of AdditionalField objects to permit them to be
\r
8 # * interoperable with future releases.
\r
10 # * @see TransactionRequest#setAdditionalField
\r
11 # * @see TransactionRequest#setAdditionalFields
\r
16 # * Make an AdditionalField object with the given name and value.
\r
18 # * @param name Must not be NULL or "". May not contain ' ', '=', or '+'.
\r
23 package Business::OnlinePayment::PPIPayMover::AdditionalField;
\r
26 my $paramSeparator = "&";
\r
31 my ($name, $value) = @_; # name and value as two arguements
\r
32 $self->{strError} = "";
\r
33 if (!$name || $name eq "" ) {
\r
34 $self->{strError} .= "AdditionalField constructor: must provide a name";
\r
36 if (!$value || $value eq "") {
\r
37 $self->{strError} .= "AdditionalField constructor: must provide a value";
\r
39 if (index($name, " ") != -1 || index($name, "=") != -1) {
\r
40 $self->{strError} .= "AdditionalField constructor: name may not contain space or =";
\r
42 if (index($value, " ") != -1 || index($value, "=") != -1) {
\r
43 $self->{strError} .= "AdditionalField constructor: value may not contain space or =";
\r
45 if (index($value, "+") != -1) {
\r
46 $self->{strError} .= "AdditionalField constructor: value may not contain +";
\r
48 if (defined $name) { $self->{name} = $name }
\r
49 if (defined $value) { $self->{value} = $value }
\r
51 bless $self, $class;
\r
55 # * Get the name associated with this AdditionalField object.
\r
57 # * @return The name of the additional field.
\r
65 # * Get the value associated with this AdditionalField object.
\r
67 # * @return The value of the additional field.
\r
80 # * This method only checks the name field. This is ok because
\r
81 # * a TransactionRequest is not allowed to have two AdditionalField
\r
82 # * objects with the same name.
\r
87 if($self->{name} eq $other->getName) { return 1 }
\r
94 my $outString = shift;
\r
95 $self->{value} =~ tr/ /+/;
\r
96 $$outString .= $self->{name};
\r
98 $$outString .= $self->{value};
\r
99 $$outString .= $paramSeparator;
\r