How to use the @paypal/sdk-constants/src.FPTI_KEY.TRANSITION function in @paypal/sdk-constants

To help you get started, we’ve selected a few @paypal/sdk-constants examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github paypal / paypal-card-components / src / component.js View on Github external
}).then((payload) => {
        // does contingency flow give a payload?
        logger.track({
          comp:                                'hostedpayment',
          // risk_correlation_id: 'TODO',
          card_brand:                          payload && payload.payment_source && payload.payment_source.card.card_type,
          api_integration_type:                'PAYPALSDK',
          product_identifier:                  'PAYPAL_FOR_MARKETPLACES',
          [FPTI_KEY.STATE]:                    'CARD_PAYMENT_FORM',
          [FPTI_KEY.TRANSITION]:               'process_card_payment',
          hosted_payment_session_cre_dt:       (new Date()).toString(),
          hosted_payment_session_cre_ts_epoch: Date.now().toString()
        });
        logger.flush();

        return {
          card:             payload.payment_source.card,
          liabilityShifted: payload.success,
          orderId
        };
      });
    });
github paypal / paypal-sdk-client / src / experiment.js View on Github external
logTreatment({ treatment, payload }) {
            logger.track({
                [FPTI_KEY.STATE]:           FPTI_STATE.PXP,
                [FPTI_KEY.TRANSITION]:      FPTI_TRANSITION.PXP,
                [FPTI_KEY.EXPERIMENT_NAME]: name,
                [FPTI_KEY.TREATMENT_NAME]:  treatment,
                ...payload
            });
            logger.flush();
        },
github paypal / paypal-smart-payment-buttons / src / button / props / onCancel.js View on Github external
return createOrder().then(orderID => {
            getLogger()
                .info('button_cancel')
                .track({
                    [FPTI_KEY.TRANSITION]: FPTI_TRANSITION.CHECKOUT_CANCEL,
                    [FPTI_KEY.TOKEN]:      orderID
                }).flush();

            return onCancel(buildXOnCancelData({ orderID }), buildXOnCancelActions());
        }).catch(err => {
            return onError(err);
github paypal / paypal-smart-payment-buttons / src / api / order.js View on Github external
}).then((body) : string => {

        const orderID = body && body.id;

        if (!orderID) {
            throw new Error(`Order Api response error:\n\n${ JSON.stringify(body, null, 4) }`);
        }

        getLogger().track({
            [FPTI_KEY.TRANSITION]:   FPTI_TRANSITION.CREATE_ORDER,
            [FPTI_KEY.CONTEXT_TYPE]: FPTI_CONTEXT_TYPE.ORDER_ID,
            [FPTI_KEY.TOKEN]:        orderID,
            [FPTI_KEY.CONTEXT_ID]:   orderID
        });

        return orderID;
    });
}
github paypal / paypal-sdk-client / src / api.js View on Github external
}).then(({ body }) : string => {

        if (!body || !body.id) {
            throw new Error(`Order Api response error:\n\n${ JSON.stringify(body, null, 4) }`);
        }

        getLogger().track({
            [FPTI_KEY.STATE]:        fptiState,
            [FPTI_KEY.TRANSITION]:   FPTI_TRANSITION.CREATE_ORDER,
            [FPTI_KEY.CONTEXT_TYPE]: FPTI_CONTEXT_TYPE.ORDER_ID,
            [FPTI_KEY.TOKEN]:        body.id,
            [FPTI_KEY.CONTEXT_ID]:   body.id
        });

        return body.id;
    });
}
github paypal / paypal-smart-payment-buttons / src / button / props / onShippingChange.js View on Github external
return createOrder().then(orderID => {
                getLogger()
                    .info('button_shipping_change')
                    .track({
                        [FPTI_KEY.TRANSITION]: FPTI_TRANSITION.CHECKOUT_SHIPPING_CHANGE,
                        [FPTI_KEY.TOKEN]:      orderID
                    }).flush();

                return onShippingChange(buildXOnShippingChangeData(data), buildXShippingChangeActions({ orderID, facilitatorAccessToken, buyerAccessToken, actions, partnerAttributionID }));
            });
        };
github paypal / paypal-smart-payment-buttons / src / button / props / createOrder.js View on Github external
}).then(orderID => {
            if (!orderID || typeof orderID !== 'string') {
                throw new Error(`Expected an order id to be passed`);
            }
    
            if (orderID.indexOf('PAY-') === 0 || orderID.indexOf('PAYID-') === 0) {
                throw new Error(`Do not pass PAY-XXX or PAYID-XXX directly into createOrder. Pass the EC-XXX token instead`);
            }

            const duration = Date.now() - startTime;
    
            getLogger().track({
                [FPTI_KEY.STATE]:              FPTI_STATE.BUTTON,
                [FPTI_KEY.TRANSITION]:         FPTI_TRANSITION.RECEIVE_ORDER,
                [FPTI_KEY.CONTEXT_TYPE]:       FPTI_CONTEXT_TYPE.ORDER_ID,
                [FPTI_KEY.CONTEXT_ID]:         orderID,
                [FPTI_KEY.TOKEN]:              orderID,
                [FPTI_KEY.BUTTON_SESSION_UID]: buttonSessionID,
                [FPTI_KEY.RESPONSE_DURATION]:  duration.toString()
            }).flush();
    
            return orderID;
        });
    });
github paypal / paypal-smart-payment-buttons / src / api / payment.js View on Github external
}).then(body => {

        const paymentID = body && body.id;

        if (!paymentID) {
            throw new Error(`Payment Api response error:\n\n${ JSON.stringify(body, null, 4) }`);
        }

        getLogger().track({
            [FPTI_KEY.TRANSITION]:   FPTI_TRANSITION.CREATE_PAYMENT,
            [FPTI_KEY.CONTEXT_TYPE]: FPTI_CONTEXT_TYPE.PAYMENT_ID,
            [FPTI_KEY.TOKEN]:        paymentID,
            [FPTI_KEY.CONTEXT_ID]:   paymentID
        });

        return body;
    });
}
github paypal / paypal-smart-payment-buttons / src / button / logs.js View on Github external
const fundingSources = Array.prototype.slice.call(document.querySelectorAll(`[${ DATA_ATTRIBUTES.FUNDING_SOURCE }]`)).map(el => {
            return el.getAttribute(DATA_ATTRIBUTES.CARD) || el.getAttribute(DATA_ATTRIBUTES.FUNDING_SOURCE);
        }).filter(source => {
            return source && source !== FUNDING.CARD;
        });

        const { layout, color, shape, label, tagline = true } = style;

        logger.info(`button_render_color_${ color }`);
        logger.info(`button_render_shape_${ shape }`);
        logger.info(`button_render_label_${ label }`);
        logger.info(`button_render_layout_${ layout }`);
        logger.info(`button_render_tagline_${ tagline.toString() }`);

        logger.track({
            [FPTI_KEY.TRANSITION]:                    FPTI_TRANSITION.BUTTON_LOAD,
            [FPTI_KEY.FUNDING_LIST]:                  fundingSources.join(':'),
            [FPTI_KEY.FUNDING_COUNT]:                 fundingSources.length.toString(),
            [FPTI_KEY.PAGE_LOAD_TIME]:                pageRenderTime ? pageRenderTime.toString() : '',
            [FTPI_BUTTON_KEY.BUTTON_LAYOUT]:          layout,
            [FTPI_BUTTON_KEY.BUTTON_COLOR]:           color,
            [FTPI_BUTTON_KEY.BUTTON_SIZE]:            'responsive',
            [FTPI_BUTTON_KEY.BUTTON_SHAPE]:           shape,
            [FTPI_BUTTON_KEY.BUTTON_LABEL]:           label,
            [FTPI_BUTTON_KEY.BUTTON_WIDTH]:           window.innerWidth,
            [FTPI_BUTTON_KEY.BUTTON_TYPE]:            FPTI_BUTTON_TYPE.IFRAME,
            [FTPI_BUTTON_KEY.BUTTON_TAGLINE_ENABLED]: tagline ? '1' : '0'
        });

        logger.flush();
    });
}
github paypal / paypal-smart-payment-buttons / src / button / props / onApprove.js View on Github external
}).then(orderID => {

            getLogger()
                .info('button_approve')
                .track({
                    [FPTI_KEY.TRANSITION]: FPTI_TRANSITION.CHECKOUT_AUTHORIZE,
                    [FPTI_KEY.TOKEN]:      orderID
                }).flush();

            const data = { orderID, payerID, paymentID, billingToken, subscriptionID, facilitatorAccessToken };
            const actions = buildXApproveActions({ orderID, paymentID, payerID, intent, restart, subscriptionID, facilitatorAccessToken, buyerAccessToken, partnerAttributionID, forceRestAPI });

            return onApprove(data, actions).catch(err => {
                return ZalgoPromise.try(() => {
                    return onError(err);
                }).then(() => {
                    throw err;
                });
            });
        });
    });