Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Add additional metadata to cybersource auth response (#258)
Browse files Browse the repository at this point in the history
Add processorInformation.approvalCode and processorInformation.responseCode to cybersource auth response.
  • Loading branch information
linw50 authored Jun 29, 2023
1 parent cce88d1 commit 1ac8771
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions gateways/cybersource/cybersource.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,18 @@ func (client *CybersourceClient) AuthorizeWithContext(ctx context.Context, reque
response.CvvResult = translateCvv(cybersourceResponse.ProcessorInformation.CardVerification.ResultCode)
response.CvvResultRaw = cybersourceResponse.ProcessorInformation.CardVerification.ResultCode
response.ExternalTransactionID = cybersourceResponse.ProcessorInformation.TransactionID
response.Metadata = buildResponseMetadata(*cybersourceResponse.ProcessorInformation)
}
return response, nil
}

func buildResponseMetadata(processorInformation ProcessorInformation) map[string]string {
metadata := make(map[string]string)
metadata[sleet.ApprovalCodeMetadata] = processorInformation.ApprovalCode
metadata[sleet.ResponseCodeMetadata] = processorInformation.ResponseCode
return metadata
}

// Capture captures an authorized payment through CyberSource. If successful, the capture response will be returned.
// Multiple captures can be made on the same authorization, but the total amount captured should not exceed the
// total authorized amount.
Expand Down
4 changes: 3 additions & 1 deletion types.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ type AuthorizationRequest struct {
}

const (
AuthCodeMetadata string = "authCode"
AuthCodeMetadata string = "authCode"
ApprovalCodeMetadata string = "approvalCode"
ResponseCodeMetadata string = "responseCode"
)

// AuthorizationResponse is a generic response returned back to client after data massaging from PsP Response
Expand Down

0 comments on commit 1ac8771

Please sign in to comment.