我如何在JS中获取ID交易贝宝

时间:2018-10-26 15:37:55

标签: javascript paypal transactions id

我有这个问题,需要ID交易。这是我的代码:

payment: 
        function(data, actions) 
        {
            var hola = 0.01;
            return actions.payment.create(
            {
                payment: 
                {
                    transactions: 
                    [{
                        amount: 
                        {
                            total: hola,
                            currency: 'MXN',
                            details: 
                            {
                                subtotal: '0.01'
                            }
                        },
                        //invoice_number: '12345', Insert a unique invoice number
                        payment_options: 
                        {
                            allowed_payment_method: 'INSTANT_FUNDING_SOURCE'
                        },
                        item_list: 
                        {
                            items: 
                            [
                                {
                                    name: 'carrito del cafe',
                                    description: 'tu pedido del cafe',
                                    quantity: '1',
                                    price: '0.01',
                                    sku: '1',
                                    currency: 'MXN'
                                }
                            ],

                            shipping_address: 
                            {
                                recipient_name: 'Brian Robinson',
                                line1: '4th Floor',
                                line2: 'Unit #34',
                                city: 'San Jose',
                                country_code: 'US',
                                postal_code: '95131',
                                phone: '011862212345678',
                                state: 'CA'
                            }
                        }

                    }],
                }
            });
        },

        onAuthorize: function(data, actions) 
        {
            return actions.payment.execute().then(function(data, actions) 
            {
                var idt = actions.payment.transactions[0].related_resources[0].sale.id;
                window.alert(idt);
            });
        }

我需要在onAuthorize中查看ID交易;有人可以帮我吗?

0 个答案:

没有答案