- paypal.Buttons(
- {
- createOrder: function(data, actions)
- {
- // This function sets up the details of the transaction, including the amount and line item details.
- // console.log($('span.total-price').data('total_price'));
- return actions.order.create(
- {
- purchase_units: [
- {
- amount:
- {
- value: $('ul.cart-total li.cart-total-amount').data('total')
- }
- }
- ]
- });
- },
- onApprove: function(data, actions)
- {
- // This function captures the funds from the transaction.
- return actions.order.capture().then(function(details)
- {
- // This function shows a transaction success message to your buyer.
- $('ul.total-price li.paypal-payment').hide();
- $.post(URL, {action: 'paypalcreateorder', paypal_id:details.id},
- function(res)
- {
- var result = $.parseJSON(res);
- if (result.status)
- {
- location.href = window.location.protocol+'//'+window.location.hostname+'/uprofile/get#pending';
- }
- else
- {
- alert('Payment completed, but something went wrong');
- }
- }
- );
- });
- }
- }).render('#paypal-button-container');
Raw Paste