Skip to content

Commit

Permalink
Merge pull request #1006 from oxaudo/updates
Browse files Browse the repository at this point in the history
set credit_card_enabled to false if partner_product_merchant_account not found for partner
  • Loading branch information
mzikherman authored Apr 18, 2018
2 parents 36fe444 + ed40291 commit 91c249d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
30 changes: 30 additions & 0 deletions src/schema/__tests__/partner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,35 @@ describe("Partner type", () => {
})
})
})

it("returns false if partner_product_merchant_account call to lewitt returns errors", () => {
const typeDefs = fs.readFileSync(
path.resolve(__dirname, "../../data/lewitt.graphql"),
"utf8"
)

const resolvers = {
RootQuery: {
partner_product_merchant_account: () => {
throw new Error("Lewitt error")
},
},
}

const lewittSchema = makeExecutableSchema({
typeDefs,
resolvers,
})

rootValue.lewittSchema = lewittSchema

return runQuery(query, rootValue).then(data => {
expect(data).toEqual({
partner: {
acceptsCardPayments: false,
},
})
})
})
})
})
5 changes: 2 additions & 3 deletions src/schema/partner.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,8 @@ const PartnerType = new GraphQLObjectType({
partner_id: _id,
}).then(response => {
if (response.errors) {
throw new Error(
`Lewitt errors: ${JSON.stringify(response.errors)}`
)
// Something is off in Lewitt so cards are not accepted at the moment
return false
}
const { data: { partner_product_merchant_account } } = response
return partner_product_merchant_account.credit_card_enabled
Expand Down

0 comments on commit 91c249d

Please sign in to comment.