@MaxSemenov

Как передать значение в функцию оплаты PayPal button?

Мне нужно передать значение (общая сумма заказа) в функцию PayPal оплаты
<script>

export default {
  layout: 'product',
  async asyncData({$axios,params}){
    const order = await $axios.$get('/order/' + params.order);
    return {order};
  },

  mounted: function(){
   const script = document.createElement('script');
    script.src =
    'https://www.paypal.com/sdk/js?client-id=AW57StLIev6D0ylC6lZh_0w8Ty3Ygi3BiY4eqMEw6rDiQJIiigZnWpRkefbXu5XCn8OM_3MKfhveOjFx&disable-funding=credit,card';
    script.addEventListener("load",this.setLoaded);
    document.body.appendChild(script);
  },
  methods: {
    setLoaded: () => {
      window.paypal.
      Buttons({
         createOrder: function(data, actions) {
            // This function sets up the details of the transaction, including the amount and line item details.
            return actions.order.create({
                purchase_units: [{
                    amount: {
                      value: order.data.billing_total
                    }
                }]
          });
        },

я пробовал создавать
data: () => ({
    order:[]
  })

и записать туда заказ но не получилось, пишет Cannot set property 'order' of undefined
  • Вопрос задан
  • 59 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы