Checkout Script for Determining Payment Source

JP_PEI
Tourist
5 0 1

We are trying to implement PayPal Shopping Store Cash Tags on our site and would like to use the optional "srce" payment parameter in the "additional scripts" section at checkout to determine the order payment(s):

JP_PEI_2-1632225777533.png

So far we have the following, but wanted to confirm if this would be the correct approach using the first transaction information in the "thank you" page:

<script>
  {% if transactions[0].receipt.charges.data[0].payment_method_details.card.wallet.type == 'apple_pay' %}
    {% capture source_payment %}apple_pay{% endcapture %}
  {% elsif transactions[0].gateway == 'paypal' %}
    {% capture source_payment %}paypal{% endcapture %}
  {% elsif transactions[0].payment_details.credit_card_company %}
    {% case handle %}
    {% when 'Visa' %}
      {% capture source_payment %}card_visa{% endcapture %}
    {% when 'Mastercard' %}
      {% capture source_payment %}card_mastercard{% endcapture %}
    {% when 'American Express' %}
      {% capture source_payment %}card_amex{% endcapture %}
    {% when 'Discover' %}
      {% capture source_payment %}card_discover{% endcapture %}
    {% when 'Diners Club' %}
      {% capture source_payment %}card_diners{% endcapture %}
    {% when 'JCB' %}
      {% capture source_payment %}card_jcb{% endcapture %}
    {% else %}
      {% capture source_payment %}card_other{% endcapture %}
    {% endcase %}
  {% endif %}

  window.paypalDDL = window.paypalDDL || [];
   paypalDDL.push({
   event: 'txnSuccess',
   txn_id: '{{ order.name }}',
   srce: '{{ source_payment }}',
   tpv: {{ checkout.total_price }},
   curr: {{ order.currency }},
   prcd: {% if order.discounts[0].code %}'PromoUsed'{% else %}'NoPromo'{% endif %}
   });
</script>

Thank you.

Replies 0 (0)