Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsegura committed Dec 20, 2024
1 parent 973db4f commit ffa5b25
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 7 deletions.
Binary file added assets/images/Swile_black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/restoflash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,10 @@
"card": "Credit card",
"cash_on_delivery": "Cash on delivery",
"edenred": "Edenred",
"edenred+card": "Edenred"
"edenred+card": "Edenred",
"conecs": "Titres-restaurant",
"swile": "Swile",
"restoflash": "Restoflash"
},
"CASH_ON_DELIVERY_DISCLAIMER": "You are going to pay by cash on delivery. Please prepare the exact amount and make sure to be reachable.",
"STORES": "Stores",
Expand Down
10 changes: 7 additions & 3 deletions src/navigation/checkout/Payment.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import { Center } from 'native-base';
import { View } from 'react-native';
import { Linking, View } from 'react-native';
import { connect } from 'react-redux';

import {
Expand Down Expand Up @@ -42,8 +42,12 @@ class CreditCard extends Component {
'edenred+card': 'CheckoutPaymentMethodEdenred',
};

this.props.setPaymentMethod(type, () => {
this.props.navigation.navigate(routesByMethod[type]);
this.props.setPaymentMethod(type, (result) => {
if (result.redirectUrl) {
Linking.openURL(result.redirectUrl);
} else {
this.props.navigation.navigate(routesByMethod[type]);
}
})
}

Expand Down
2 changes: 2 additions & 0 deletions src/navigation/checkout/components/CreditCardPaygreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const CreditCardPaygreen = ({ baseURL, paymentDetails, loadPaymentDetails, cart,
loadPaymentDetails()
}, []);

Check failure on line 30 in src/navigation/checkout/components/CreditCardPaygreen.js

View workflow job for this annotation

GitHub Actions / Basic tests

React Hook useEffect has a missing dependency: 'loadPaymentDetails'. Either include it or remove the dependency array. If 'loadPaymentDetails' changes too often, find the parent component that defines it and wrap that definition in useCallback

console.log('paymentDetails', paymentDetails)

if (!paymentDetails?.paygreenWebviewUrl) {
return <Text>LOADING</Text>
}
Expand Down
37 changes: 35 additions & 2 deletions src/navigation/checkout/components/PaymentMethodIcon.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react';
import { Icon } from 'native-base';
import { Image } from 'react-native';
import { Box, Icon } from 'native-base';
import Foundation from 'react-native-vector-icons/Foundation';
import Svg, { Path, G } from 'react-native-svg';
import ConecsIcon from './PaymentMethodIcon/ConecsIcon';

const icons = {
card: 'credit-card',
Expand All @@ -19,16 +21,47 @@ const PaymentMethodIcon = ({ type }) => {
/>)
}

if (type === 'conecs') {
return (
<Icon size="xl" mr="2">
<ConecsIcon />
</Icon>
)
}

if (type === 'restoflash') {
return (
<Box mr="2">
<Image
resizeMode="contain"
source={require('../../../../assets/images/restoflash.png')}
style={{ width: 30, height: 30 }} />
</Box>
)
}

if (type === 'swile') {
return (
<Box mr="2">
<Image
resizeMode="contain"
source={require('../../../../assets/images/Swile_black.png')}
style={{ width: 40, height: 40 }} />
</Box>
)
}

if (type === 'edenred' || type === 'edenred+card') {
return (
<Icon size="xl" viewBox="0 0 413.24 265.47" mr="2">
<Icon size="xl" mr="2">
<Svg
xmlns="http://www.w3.org/2000/svg"
xmlSpace="preserve"
id="Layer_1"
x={0}
y={0}
fill={ '#000000' }
viewBox="0 0 413.24 265.47"
>
<Path
d="M160.43 117.34c-6.79 0-11.1 4.42-12.44 10.28h24.16c-.82-6.47-5.35-10.28-11.72-10.28zM95.86 119.91c-8.64 0-14.09 5.96-14.09 14.29 0 8.23 5.55 14.39 14.09 14.39s14.29-5.86 14.29-14.39c0-8.53-5.76-14.29-14.29-14.29z"
Expand Down
33 changes: 33 additions & 0 deletions src/navigation/checkout/components/PaymentMethodIcon/ConecsIcon.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/redux/Checkout/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1937,12 +1937,14 @@ export function setPaymentMethod(paymentMethod, cb) {
},
)
.then(res => {
console.log('setPaymentMethod', JSON.stringify(res))
console.log('redirectUrl', res.redirectUrl)
// We update the state with the same cart
// We can't use response, because it's not a cart
// TODO Use the payments returned
// https://github.com/coopcycle/coopcycle-app/issues/1925
dispatch(updateCartSuccess(cart));
cb()
cb(res)
})
.catch(e => dispatch(checkoutFailure(e)));
};
Expand Down

0 comments on commit ffa5b25

Please sign in to comment.