first commit
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
paypalcheckout:
|
||||
resource: "@PayPalCheckoutBundle/Controller/"
|
||||
type: annotation
|
||||
@@ -0,0 +1,9 @@
|
||||
services:
|
||||
_defaults:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
public: false
|
||||
|
||||
KupShop\PayPalCheckoutBundle\:
|
||||
resource: ../../{Controller}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<script src="https://www.paypal.com/sdk/js?client-id={$cfg.Modules.payments.PayPalCheckout.clientID}¤cy={$ctrl.active_currency}"></script>
|
||||
<div class="paypal-container">
|
||||
<div id="paypal-button-container"></div>
|
||||
</div>
|
||||
<script>
|
||||
paypal.Buttons({
|
||||
createOrder: function() {
|
||||
return fetch('/paypal-checkout/create-paypal-order/', {
|
||||
method: 'post',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
}
|
||||
}).then(function(res) {
|
||||
return res.json();
|
||||
}).then(function(response) {
|
||||
console.log('/paypal-checkout/create-paypal-order/ response');
|
||||
console.log(response);
|
||||
if (response.result.status == 'CREATED') {
|
||||
return response.result.id; // Use the same key name for order ID on the client and server
|
||||
} else if (response.hasOwnProperty('error')) {
|
||||
alert(response.error);
|
||||
}
|
||||
});
|
||||
},
|
||||
style: {
|
||||
layout: 'horizontal',
|
||||
color: 'silver',
|
||||
},
|
||||
onApprove: function(data, actions) {
|
||||
$('input, button').prop('disabled', true);
|
||||
$('#paypal-button-container').hide();
|
||||
window.location.replace('/paypal-checkout/capture-paypal-order/' + data.orderID + '/');
|
||||
}
|
||||
}).render('#paypal-button-container');
|
||||
</script>
|
||||
Reference in New Issue
Block a user