Skip to content

Commit

Permalink
Rename status and json constants in drop-in checkout script.
Browse files Browse the repository at this point in the history
  • Loading branch information
rvdsteege committed Feb 3, 2020
1 parent 8294f7f commit b4e2f72
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
8 changes: 4 additions & 4 deletions js/dist/checkout-drop-in.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/dist/checkout-drop-in.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions js/src/checkout-drop-in.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@

const checkout = new AdyenCheckout( pronamicPayAdyenCheckout.configuration );

const status = response => {
const validate_http_status = response => {
if ( response.status >= 200 && response.status < 300 ) {
return Promise.resolve( response );
}

return Promise.reject( new Error( response.statusText ) );
};

const json = response => response.json();
const get_json = response => response.json();

const dropin = checkout.create( 'dropin', {
paymentMethodsConfiguration: pronamicPayAdyenCheckout.paymentMethodsConfiguration,
onSubmit: ( state, dropin ) => {

send_request( pronamicPayAdyenCheckout.paymentsUrl, state.data )
.then( status )
.then( json )
.then( validate_http_status )
.then( get_json )
.then( response => {
// Handle action object.
if ( response.action ) {
Expand All @@ -44,8 +43,8 @@
},
onAdditionalDetails: ( state, dropin ) => {
send_request( pronamicPayAdyenCheckout.paymentsDetailsUrl, state.data )
.then( status )
.then( json )
.then( validate_http_status )
.then( get_json )
.then( response => {
// Handle action object.
if ( response.action ) {
Expand Down

0 comments on commit b4e2f72

Please sign in to comment.