Logunath
Logunath

Reputation: 477

Braintree Perl SDK- How to access $credit_card_verification result object in Customer->create API call

I am integrating Braintree Perl's SDK (Payment gateway) with an existing project.In that project I want to return response_code, response_text. CVV_response, AVS_response on each Transaction->sale and Customer->create API call both in success and failure states.

I can able to access the result objects in both success and failure states in Transaction->sale API call and also in customer->create API call on failure status, I can't able to access result objects like the one below on success status,

$result->credit_card_verification->status
$result->credit_card_verification->processor_response_code

How can I access the $result->credit_card_verification result objects when Customer->create API call gets Succeeded?

I referred below link also, but can't get the idea,

https://developers.braintreepayments.com/javascript+perl/reference/objects/customer https://developers.braintreepayments.com/javascript+perl/reference/objects/transaction https://github.com/braintree/braintree_perl/blob/master/lib/Net/Braintree/CreditCardVerification.pm

Please find snippet of my sample code,

if ( $result->is_success ) {
    print "\nThe result is" . $result;
    print "\n" . $result->customer->id;

    #can't able to access these details here
    my $verification = $result->credit_card_verification;
    print $result->status;
    print $result->processor_response_code;
    print $verification->processor_response_text;

    $self->new_agreement_id( $result->customer->credit_cards->[0]->token );
    $self->collection_status( $status_codes{Authorized} );
    $self->status_text( $result->credit_card_verification->status );
    $self->status( $result->credit_card_verification->processor_response_code );
    $self->cvv_response( $result->credit_card_verification->cvv_response_code );
    $self->avs( $result->credit_card_verification->avs_postal_code_response_code );
}
else {
    print "\nResult is" . $result->errors . "\n";
    print "Message is:" . $result->message . "\n";

    #can able to access these details here
    my $verification = $result->credit_card_verification;
    print $verification->status;
    print $verification->processor_response_code;
    print $verification->processor_response_text;

    $self->collection_status( $status_codes{failed} );
    $self->status( $verification->processor_response_code );
    $self->cvv_response( $result->credit_card_verification->cvv_response_code );
    $self->avs( $result->credit_card_verification->avs_postal_code_response_code );
    $self->status_text( $verification->status );
}

Here, I am using verify_card option in my Customer->create API call always.

Any help is appreciated.

Upvotes: 1

Views: 348

Answers (1)

agf
agf

Reputation: 176910

I work at Braintree. If you have more questions, please feel free to reach out to our support team.

You can't get a credit card verification object on success. The credit card verification will only be returned if it failed:

The result of a customer or payment method create may contain a verification result object. The verification result object will only be present if a verification ran and the verification comes back processor_declined or gateway_rejected. Successful results will not return a verification result object.

Upvotes: 2

Related Questions