import { PaymentRequestParams } from 'react-payment-request-api' ; const details = { displayItems : [ { label : 'Original donation amount' , amount : { currency : 'USD' , value : '65.00' } , } , { label : 'Friends and family discount' , amount : { currency : 'USD' , value : '-10.00' } , } , { label : 'Delivery tax' , pending : true , amount : { currency : 'USD' , value : '10.00' } , } ] , total : { label : 'Total due' , amount : { currency : 'USD' , value : '55.00' } , } , } ; const getConfig = ( supportedPaymentCards , onShowSuccess ) => ( { methodData : [ { supportedMethods : [ 'basic-card' ] , data : { supportedNetworks : supportedPaymentCards , } , } ] , details : details , options : { requestShipping : true , requestPayerEmail : true , requestPayerPhone : true , } , onShowSuccess : ( result , resolve , reject ) : void => { console . log ( 'Result:' , result ) ; setTimeout ( ( ) => { onShowSuccess ( ) ; resolve ( ) ; } , 2000 ) ; } , onShowFail : ( error ) => console . log ( 'Error' , error ) , onShippingAddressChange : ( request , resolve , reject ) : void => { console . log ( 'ShippingAddress:' , request . shippingAddress ) ; details . shippingOptions = [ { id : 'all' , label : 'Wherever you want for free' , amount : { currency : 'USD' , value : '0.00' } , selected : true } ] ; details . displayItems ! [ 2 ] = { label : 'Tax' , pending : false , amount : { currency : 'USD' , value : '8.00' } , } ; resolve ( details ) ; } , onShippingOptionChange : ( request , resolve , reject ) : void => { resolve ( details ) ; } , } ) as PaymentRequestParams ; export default getConfig ;