Skip to content

Commit

Permalink
feat: return empty actions on paymentHandler short-circuit (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Gardiner authored Jun 4, 2020
1 parent 1ffe59d commit a4463d5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions extension/src/lambda.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ exports.handler = async function (event) {

return {
responseType: paymentResult.success ? 'UpdateRequest' : 'FailedValidation',
// Null check around paymentResult.data,
// which can be null if paymentHandler short circuits when not an adyen payment
// paymentResult.data can be null when paymentHandler short-circuits on non-Adyen payment
errors: paymentResult.data ? paymentResult.data.errors : undefined,
actions: paymentResult.data ? paymentResult.data.actions : undefined
actions: paymentResult.data ? paymentResult.data.actions : []
}
} catch (e) {
logger.error(e, `Unexpected error when processing event ${JSON.stringify(event)}`)
Expand Down
2 changes: 1 addition & 1 deletion extension/test/unit/lambda.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Lambda handler', () => {

expect(result.responseType).equals('UpdateRequest')
expect(result.errors).equals(undefined)
expect(result.actions).to.equal(undefined)
expect(result.actions).to.be.empty
})

it('logs and throws unhandled exceptions', async () => {
Expand Down

0 comments on commit a4463d5

Please sign in to comment.