Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stripe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Extensions
Stripe
Commits
40a37004
Commit
40a37004
authored
4 years ago
by
mattwire
Committed by
mattwire
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fixes to 3dsecure for paymentIntents and setupIntents on thankyou page
parent
a9a6b3df
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!152
6.6 to master
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
js/civicrmStripeConfirm.js
+84
-46
84 additions, 46 deletions
js/civicrmStripeConfirm.js
js/civicrm_stripe.js
+0
-1
0 additions, 1 deletion
js/civicrm_stripe.js
with
84 additions
and
47 deletions
js/civicrmStripeConfirm.js
+
84
−
46
View file @
40a37004
...
@@ -11,51 +11,46 @@
...
@@ -11,51 +11,46 @@
/**
/**
* Handle the response from the server for the payment/setupIntent
* Handle the response from the server for the payment/setupIntent
* @param
result
* @param
paymentIntentProcessResponse
*/
*/
handleIntentServerResponse
:
function
(
result
)
{
handleIntentServerResponse
:
function
(
paymentIntentProcessResponse
)
{
CRM
.
payment
.
debugging
(
confirm
.
scriptName
,
'
handleServerResponse
'
);
CRM
.
payment
.
debugging
(
confirm
.
scriptName
,
'
handleIntentServerResponse
'
);
if
(
result
.
error
)
{
if
(
paymentIntentProcessResponse
.
requires_action
)
{
// Show error from server on payment form
// Use Stripe.js to handle required card action
CRM
.
payment
.
debugging
(
confirm
.
scriptName
,
result
.
error
.
message
);
if
(
CRM
.
vars
.
stripe
.
hasOwnProperty
(
'
paymentIntentID
'
))
{
confirm
.
handlePaymentIntentAction
(
paymentIntentProcessResponse
);
}
else
if
(
CRM
.
vars
.
stripe
.
hasOwnProperty
(
'
setupIntentID
'
))
{
confirm
.
handleCardConfirm
();
}
}
else
{
// All good, nothing more to do
CRM
.
payment
.
debugging
(
confirm
.
scriptName
,
'
success - payment captured
'
);
confirm
.
swalFire
({
confirm
.
swalFire
({
title
:
''
,
title
:
ts
(
'
Payment successful
'
),
text
:
result
.
error
.
message
,
icon
:
'
success
'
icon
:
'
error
'
},
''
,
true
);
},
''
,
true
);
}
}
else
if
(
result
.
requires_action
)
{
// Use Stripe.js to handle required card action
if
(
CRM
.
vars
.
stripe
.
hasOwnProperty
(
'
paymentIntentID
'
))
{
confirm
.
handlePaymentIntentAction
(
result
);
}
else
if
(
CRM
.
vars
.
stripe
.
hasOwnProperty
(
'
setupIntentID
'
))
{
confirm
.
handleCardConfirm
();
}
}
else
{
// All good, nothing more to do
CRM
.
payment
.
debugging
(
confirm
.
scriptName
,
'
success - payment captured
'
);
confirm
.
swalFire
({
title
:
ts
(
'
Payment successful
'
),
icon
:
'
success
'
},
''
,
true
);
}
},
},
/**
/**
* Handle the next action for the paymentIntent
* Handle the next action for the paymentIntent
* @param
r
esponse
* @param
paymentIntentProcessR
esponse
*/
*/
handlePaymentIntentAction
:
function
(
r
esponse
)
{
handlePaymentIntentAction
:
function
(
paymentIntentProcessR
esponse
)
{
switch
(
CRM
.
vars
.
stripe
.
paymentIntentMethod
)
{
switch
(
CRM
.
vars
.
stripe
.
paymentIntentMethod
)
{
case
'
automatic
'
:
case
'
automatic
'
:
confirm
.
stripe
.
handleCardPayment
(
r
esponse
.
paymentIntentClientSecret
)
confirm
.
stripe
.
handleCardPayment
(
paymentIntentProcessR
esponse
.
paymentIntentClientSecret
)
.
then
(
function
(
r
esult
)
{
.
then
(
function
(
handleCardPaymentR
esult
)
{
if
(
r
esult
.
error
)
{
if
(
handleCardPaymentR
esult
.
error
)
{
// Show error in payment form
// Show error in payment form
confirm
.
handleCardConfirm
();
CRM
.
payment
.
debugging
(
confirm
.
scriptName
,
handleCardPaymentResult
.
error
.
message
);
confirm
.
swalFire
({
title
:
''
,
text
:
handleCardPaymentResult
.
error
.
message
,
icon
:
'
error
'
},
''
,
true
);
}
}
else
{
else
{
// The card action has been handled
// The card action has been handled
...
@@ -66,11 +61,16 @@
...
@@ -66,11 +61,16 @@
break
;
break
;
case
'
manual
'
:
case
'
manual
'
:
confirm
.
stripe
.
handleCardAction
(
r
esponse
.
paymentIntentClientSecret
)
confirm
.
stripe
.
handleCardAction
(
paymentIntentProcessR
esponse
.
paymentIntentClientSecret
)
.
then
(
function
(
r
esult
)
{
.
then
(
function
(
handleCardActionR
esult
)
{
if
(
r
esult
.
error
)
{
if
(
handleCardActionR
esult
.
error
)
{
// Show error in payment form
// Show error in payment form
confirm
.
handleCardConfirm
();
CRM
.
payment
.
debugging
(
confirm
.
scriptName
,
handleCardActionResult
.
error
.
message
);
confirm
.
swalFire
({
title
:
''
,
text
:
handleCardActionResult
.
error
.
message
,
icon
:
'
error
'
},
''
,
true
);
}
}
else
{
else
{
// The card action has been handled
// The card action has been handled
...
@@ -97,35 +97,72 @@
...
@@ -97,35 +97,72 @@
description
:
document
.
title
,
description
:
document
.
title
,
csrfToken
:
CRM
.
vars
.
stripe
.
csrfToken
csrfToken
:
CRM
.
vars
.
stripe
.
csrfToken
})
})
.
done
(
function
(
result
)
{
.
done
(
function
(
paymentIntentProcessResponse
)
{
confirm
.
swalClose
();
confirm
.
swalClose
();
// Handle server response (see Step 3)
// Handle server response (see Step 3)
confirm
.
handleIntentServerResponse
(
result
);
CRM
.
payment
.
debugging
(
confirm
.
scriptName
,
'
StripePaymentintent.Process done
'
);
if
(
paymentIntentProcessResponse
.
is_error
)
{
// Triggered for api3_create_error or Exception
confirm
.
swalFire
({
title
:
''
,
text
:
paymentIntentProcessResponse
.
error_message
,
icon
:
'
error
'
},
''
,
true
);
}
else
{
paymentIntentProcessResponse
=
paymentIntentProcessResponse
.
values
;
confirm
.
handleIntentServerResponse
(
paymentIntentProcessResponse
);
}
})
})
.
fail
(
function
()
{
.
fail
(
function
(
object
)
{
confirm
.
swalClose
();
var
error
=
'
Unknown error
'
;
if
(
object
.
hasOwnProperty
(
'
statusText
'
)
&&
(
object
.
statusText
!==
'
OK
'
))
{
// A PHP exit can return 200 "OK" but we don't want to display "OK" as the error!
error
=
object
.
statusText
;
}
CRM
.
payment
.
debugging
(
confirm
.
scriptName
,
error
);
confirm
.
swalFire
({
title
:
''
,
text
:
error
,
icon
:
'
error
'
},
''
,
true
);
});
});
}
}
else
if
(
CRM
.
vars
.
stripe
.
hasOwnProperty
(
'
setupIntentID
'
))
{
else
if
(
CRM
.
vars
.
stripe
.
hasOwnProperty
(
'
setupIntentID
'
))
{
if
(
CRM
.
vars
.
stripe
.
setupIntentNextAction
.
type
===
'
use_stripe_sdk
'
)
{
if
(
CRM
.
vars
.
stripe
.
setupIntentNextAction
.
type
===
'
use_stripe_sdk
'
)
{
confirm
.
swalClose
();
confirm
.
swalClose
();
confirm
.
stripe
.
confirmCardSetup
(
CRM
.
vars
.
stripe
.
setupIntentClientSecret
)
confirm
.
stripe
.
confirmCardSetup
(
CRM
.
vars
.
stripe
.
setupIntentClientSecret
)
.
then
(
function
(
result
)
{
.
then
(
function
(
confirmCardSetupResult
)
{
if
(
result
.
error
)
{
// Handle confirmCardSetupResult.error or confirmCardSetupResult.setupIntent
if
(
confirmCardSetupResult
.
error
)
{
// Record error and display message to user
CRM
.
api3
(
'
StripePaymentintent
'
,
'
createorupdate
'
,
{
CRM
.
api3
(
'
StripePaymentintent
'
,
'
createorupdate
'
,
{
stripe_intent_id
:
CRM
.
vars
.
stripe
.
setupIntentID
,
stripe_intent_id
:
CRM
.
vars
.
stripe
.
setupIntentID
,
status
:
'
error
'
,
status
:
'
error
'
,
csrfToken
:
CRM
.
vars
.
stripe
.
csrfToken
csrfToken
:
CRM
.
vars
.
stripe
.
csrfToken
});
});
CRM
.
payment
.
debugging
(
confirm
.
scriptName
,
confirmCardSetupResult
.
error
.
message
);
confirm
.
swalFire
({
title
:
''
,
text
:
confirmCardSetupResult
.
error
.
message
,
icon
:
'
error
'
},
''
,
true
);
}
}
else
{
else
{
// Record success and display message to user
CRM
.
api3
(
'
StripePaymentintent
'
,
'
createorupdate
'
,
{
CRM
.
api3
(
'
StripePaymentintent
'
,
'
createorupdate
'
,
{
stripe_intent_id
:
CRM
.
vars
.
stripe
.
setupIntentID
,
stripe_intent_id
:
CRM
.
vars
.
stripe
.
setupIntentID
,
status
:
r
esult
.
setupIntent
.
status
,
status
:
confirmCardSetupR
esult
.
setupIntent
.
status
,
csrfToken
:
CRM
.
vars
.
stripe
.
csrfToken
csrfToken
:
CRM
.
vars
.
stripe
.
csrfToken
});
});
CRM
.
payment
.
debugging
(
confirm
.
scriptName
,
'
success - payment captured
'
);
confirm
.
swalFire
({
title
:
ts
(
'
Payment successful
'
),
icon
:
'
success
'
},
''
,
true
);
}
}
confirm
.
handleIntentServerResponse
(
result
);
});
});
}
}
}
}
...
@@ -162,7 +199,7 @@
...
@@ -162,7 +199,7 @@
})
})
.
fail
(
function
()
{
.
fail
(
function
()
{
confirm
.
stripeLoading
=
false
;
confirm
.
stripeLoading
=
false
;
debugging
(
'
Failed to load Stripe.js
'
);
CRM
.
payment
.
debugging
(
confirm
.
scriptName
,
'
Failed to load Stripe.js
'
);
});
});
}
}
},
},
...
@@ -193,6 +230,7 @@
...
@@ -193,6 +230,7 @@
Swal
.
close
();
Swal
.
close
();
}
}
}
}
};
};
if
(
typeof
CRM
.
payment
===
'
undefined
'
)
{
if
(
typeof
CRM
.
payment
===
'
undefined
'
)
{
...
...
This diff is collapsed.
Click to expand it.
js/civicrm_stripe.js
+
0
−
1
View file @
40a37004
...
@@ -273,7 +273,6 @@
...
@@ -273,7 +273,6 @@
}
}
})
})
.
fail
(
function
(
object
)
{
.
fail
(
function
(
object
)
{
// Triggered when http code !== 200 (eg. 400 Bad request)
var
error
=
'
Unknown error
'
;
var
error
=
'
Unknown error
'
;
if
(
object
.
hasOwnProperty
(
'
statusText
'
)
&&
(
object
.
statusText
!==
'
OK
'
))
{
if
(
object
.
hasOwnProperty
(
'
statusText
'
)
&&
(
object
.
statusText
!==
'
OK
'
))
{
// A PHP exit can return 200 "OK" but we don't want to display "OK" as the error!
// A PHP exit can return 200 "OK" but we don't want to display "OK" as the error!
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment