mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 10:55:00 +08:00
Submit axo_nonce during block checkout
Initial logic supports Ryan flow, when paying with a saved card.
This commit is contained in:
parent
861034855e
commit
d4c242c013
1 changed files with 29 additions and 1 deletions
|
@ -42,12 +42,40 @@ if ( typeof window.PayPalCommerceGateway === 'undefined' ) {
|
||||||
|
|
||||||
const axoConfig = window.wc_ppcp_axo;
|
const axoConfig = window.wc_ppcp_axo;
|
||||||
|
|
||||||
const Axo = () => {
|
const Axo = ( props ) => {
|
||||||
|
const { eventRegistration, emitResponse } = props;
|
||||||
|
const { onPaymentSetup } = eventRegistration;
|
||||||
const [ paypalLoaded, setPaypalLoaded ] = useState( false );
|
const [ paypalLoaded, setPaypalLoaded ] = useState( false );
|
||||||
const [ shippingAddress, setShippingAddress ] = useState( null );
|
const [ shippingAddress, setShippingAddress ] = useState( null );
|
||||||
const [ card, setCard ] = useState( null );
|
const [ card, setCard ] = useState( null );
|
||||||
const fastlaneSdk = useAxoBlockManager( axoConfig, ppcpConfig );
|
const fastlaneSdk = useAxoBlockManager( axoConfig, ppcpConfig );
|
||||||
|
|
||||||
|
useEffect( () => {
|
||||||
|
const unsubscribe = onPaymentSetup( async () => {
|
||||||
|
// Validate payment options and emit response.
|
||||||
|
|
||||||
|
// Note: This response supports the Ryan flow (payment via saved card-token)
|
||||||
|
return {
|
||||||
|
type: emitResponse.responseTypes.SUCCESS,
|
||||||
|
meta: {
|
||||||
|
paymentMethodData: {
|
||||||
|
axo_nonce: card?.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
} );
|
||||||
|
|
||||||
|
// Unsubscribes when this component is unmounted.
|
||||||
|
return () => {
|
||||||
|
unsubscribe();
|
||||||
|
};
|
||||||
|
}, [
|
||||||
|
emitResponse.responseTypes.ERROR,
|
||||||
|
emitResponse.responseTypes.SUCCESS,
|
||||||
|
onPaymentSetup,
|
||||||
|
card,
|
||||||
|
] );
|
||||||
|
|
||||||
const { setIsAxoActive, setIsGuest, setIsAxoScriptLoaded } =
|
const { setIsAxoActive, setIsGuest, setIsAxoScriptLoaded } =
|
||||||
useDispatch( STORE_NAME );
|
useDispatch( STORE_NAME );
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue