+ if (
+ $content->{card_token}
+ || ( $content->{card_number} && $content->{card_number} =~ /^99\d{14}$/ )
+ ) {
+ # Process payment against a stored Payment Profile, whose
+ # customer_code is used as the card_token
+
+ my $card_token = $content->{card_token} || $content->{card_number};
+
+ unless ( $card_token =~ /^99\d{14}$/ ) {
+ $self->error_message(
+ "Invalid card_token($card_token): Expected 16-digit "
+ . " beginning with 99"
+ );
+ return $self->is_success(0);
+ }
+
+ $post{payment_method} = 'payment_profile';
+
+ $post{payment_profile} = {
+ customer_code => $card_token,
+ card_id => 1,
+ };
+
+ } elsif ( $content->{card_number} ) {
+