Pass default styles to the button config

This way we can overwrite it with user selected options
This commit is contained in:
Mészáros Róbert 2020-04-09 19:15:28 +03:00
parent 6f5f8b5f41
commit 18bf5497a4
2 changed files with 19 additions and 10 deletions

View file

@ -1,4 +1,4 @@
import onApprove from "./onApproveForContinue.js";
import onApprove from './onApproveForContinue.js';
class CartConfig {
@ -8,31 +8,34 @@ class CartConfig {
}
configuration() {
const createOrder = (data, actions) => {
return fetch(this.config.ajax.create_order.endpoint, {
method: 'POST',
body: JSON.stringify({
nonce: this.config.ajax.create_order.nonce,
purchase_units:[]
})
}).then(function (res) {
purchase_units: [],
}),
}).then(function(res) {
return res.json();
}).then(function (data) {
}).then(function(data) {
if (!data.success) {
//Todo: Error handling
return;
}
return data.data.id;
});
}
};
const style = this.config.button.style;
return {
createOrder,
onApprove:onApprove(this),
onApprove: onApprove(this),
onError: (error) => {
this.errorHandler.message(error);
}
}
},
style,
};
}
}