Skip to content

Commit

Permalink
Merge pull request #286 from Adyen/readme-useCallback
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
descorp authored Oct 4, 2023
2 parents 697ac47 + 773c5e1 commit dace212
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,28 @@ const MyCheckoutView = () => {

```javascript
import { AdyenCheckout } from '@adyen/react-native';
import { useCallback } from 'react';

<AdyenCheckout
config={configuration}
paymentMethods={paymentMethods}
onSubmit={(paymentData, component) => {
const onSubmit = useCallback( (data, nativeComponent ) => {
/* Call your server to make the `/payments` request */
/* When the API request contains `action`, you should call `component.handle(response.action)` to dismiss the payment UI. */
/* When the API request is completed, you must now call `component.hide(true | false)` to dismiss the payment UI. */
}}
onAdditionalDetails={(paymentData, component) => {
}, [some, dependency]);
const onAdditionalDetails = useCallback( (paymentData, component) => {
/* Call your server to make the `/payments/details` request */
/* When the API request is completed, you must now call `component.hide(true | false)` to dismiss the payment UI. */
}}
onError={(error, component) => {
}, []);
const onError = useCallback( (error, component) => {
/* Handle errors or termination by shopper */
/* When the API request is completed, you must now call `component.hide(false)` to dismiss the payment UI. */
}}
}, []);

<AdyenCheckout
config={configuration}
paymentMethods={paymentMethods}
onSubmit={onSubmit}
onAdditionalDetails={onAdditionalDetails}
onError={onError}
>
<MyCheckoutView />
</AdyenCheckout>;
Expand Down

0 comments on commit dace212

Please sign in to comment.