Development discussions around Shopify APIs
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):
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. 🙂
User | RANK |
---|---|
8 | |
7 | |
4 | |
3 | |
3 |
Connect your PayPal account to allow your customers to checkout using the PayPal gateway a...
ByYour online store speed can enhance your store’s discoverability, boost conversion rates a...
ByShopping is at our fingertips with mobile devices. Is your theme optimized to be user-frie...
By