Skip to content

Commit

Permalink
feat(simple buy): add card -> order creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip London committed Apr 24, 2020
1 parent 59ff101 commit 52ef4b8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function simpleBuyReducer (
...state,
step: 'CURRENCY_SELECTION',
account: Remote.NotAsked,
order: undefined,
pairs: Remote.NotAsked,
quote: Remote.NotAsked,
suggestedAmounts: Remote.NotAsked
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ export default ({

const pollSBCard = function * ({ payload }: ReturnType<typeof A.pollSBCard>) {
let retryAttempts = 0
let maxRetryAttempts = 20
let maxRetryAttempts = 40

const { cardId } = payload
let card: ReturnType<typeof api.getSBCard> = yield call(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,20 @@ class ThreeDSHandler extends PureComponent<Props, State> {
this.setState({ threeDSCallbackReceived: true })
// @ts-ignore
const { card, order, type } = this.props.data.getOrElse({
type: 'ORDER',
type: null,
card: { id: '' },
order: { id: '' }
})

if (type === 'ORDER') {
this.props.simpleBuyActions.pollSBOrder(order.id)
} else if (type === 'CARD') {
this.props.simpleBuyActions.pollSBCard(card.id)
switch (type) {
case 'ORDER':
this.props.simpleBuyActions.pollSBOrder(order.id)
break
case 'CARD':
this.props.simpleBuyActions.pollSBCard(card.id)
break
default:
this.props.simpleBuyActions.setStep({ step: 'ADD_CARD' })
}
}

Expand Down Expand Up @@ -75,6 +80,7 @@ export type SuccessStateType =
| {
card: SBCardType
domains: { walletHelper: string }
order: SBOrderType
providerDetails: SBProviderDetailsType
threeDSDetails: Everypay3DSResponseType
type: 'CARD'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const getData = (state: RootState) => {
walletHelper: 'https://wallet-helper.blockchain.com'
})

if (order && order.attributes) {
if (order && order.paymentMethodId) {
return Remote.Success({
type: 'ORDER',
domains,
Expand All @@ -27,6 +27,7 @@ export const getData = (state: RootState) => {
const transform = (card, providerDetails, threeDSDetails) => ({
card,
domains,
order,
providerDetails,
threeDSDetails,
type: 'CARD'
Expand Down

0 comments on commit 52ef4b8

Please sign in to comment.