@@ -23,23 +23,13 @@ function getCardConfig() {
2323 merchantDisplayName : window . merchantAccount ,
2424 } ,
2525 exposeExpiryDate : false ,
26- onChange ( state , component ) {
26+ onChange ( state ) {
2727 store . isValid = state . isValid ;
2828 const method = state . data . paymentMethod . storedPaymentMethodId
2929 ? `storedCard${ state . data . paymentMethod . storedPaymentMethodId } `
3030 : store . selectedMethod ;
3131 store . updateSelectedPayment ( method , 'isValid' , store . isValid ) ;
32- if ( state . data ?. paymentMethod ?. storedPaymentMethodId ) {
33- const { holderName } = component . props ;
34- const { paymentMethod } = state . data ;
35- paymentMethod . holderName = holderName ;
36- store . updateSelectedPayment ( method , 'stateData' , {
37- ...state . data ,
38- paymentMethod,
39- } ) ;
40- } else {
41- store . updateSelectedPayment ( method , 'stateData' , state . data ) ;
42- }
32+ store . updateSelectedPayment ( method , 'stateData' , state . data ) ;
4333 } ,
4434 onSubmit : ( ) => {
4535 helpers . assignPaymentMethodValue ( ) ;
@@ -287,11 +277,7 @@ function getGiftCardConfig() {
287277}
288278
289279function handleOnChange ( state ) {
290- let { type } = state . data . paymentMethod ;
291- const multipleTxVariantComponents = constants . MULTIPLE_TX_VARIANTS_COMPONENTS ;
292- if ( multipleTxVariantComponents . includes ( store . selectedMethod ) ) {
293- type = store . selectedMethod ;
294- }
280+ const { type } = state . data . paymentMethod ;
295281 store . isValid = state . isValid ;
296282 if ( ! store . componentsObj [ type ] ) {
297283 store . componentsObj [ type ] = { } ;
@@ -397,6 +383,29 @@ function getKlarnaConfig() {
397383 return null ;
398384}
399385
386+ function getUpiConfig ( ) {
387+ return {
388+ showPayButton : true ,
389+ onSubmit : ( state , component ) => {
390+ $ ( '#dwfrm_billing' ) . trigger ( 'submit' ) ;
391+ helpers . assignPaymentMethodValue ( ) ;
392+ helpers . paymentFromComponent ( state . data , component ) ;
393+ } ,
394+ onAdditionalDetails : ( state ) => {
395+ document . querySelector ( '#additionalDetailsHidden' ) . value = JSON . stringify (
396+ state . data ,
397+ ) ;
398+ document . querySelector ( '#showConfirmationForm' ) . submit ( ) ;
399+ } ,
400+ onError : ( component ) => {
401+ if ( component ) {
402+ component . setStatus ( 'ready' ) ;
403+ }
404+ document . querySelector ( '#showConfirmationForm' ) . submit ( ) ;
405+ } ,
406+ } ;
407+ }
408+
400409function setCheckoutConfiguration ( ) {
401410 store . checkoutConfiguration . onChange = handleOnChange ;
402411 store . checkoutConfiguration . onAdditionalDetails = handleOnAdditionalDetails ;
@@ -425,6 +434,7 @@ function setCheckoutConfiguration() {
425434 klarna_account : getKlarnaConfig ( ) ,
426435 klarna_paynow : getKlarnaConfig ( ) ,
427436 cashapp : getCashAppConfig ( ) ,
437+ upi : getUpiConfig ( ) ,
428438 } ;
429439}
430440
0 commit comments