Balanced payment customer with multiple cards - balanced-payments

My question is:
For the same card, each time the user (owner) use it, I'll use balanced JS to tokenize it and get a different URI. Then I'll add this card to this customer on Balanced. This will cause a customer has lots of cards although they are the same one.
So what's the suggested way to implement this? Assume that I will let user types his card each time he uses it.
More background on our project:
I integrate balanced payment with my website in this way:
Front end JS will tokenize a card and pass the card URI to our backend.
Backend uses python to assign this card uri to a customer and debit at some point.

Why not use the same card each time? It's a bit of a hassle for the user to have to enter their card info for every purchase, I think.
If you really must have the user re-enter the same card info multiple times, but don't want duplicate card resources sitting around, you can check the hash attribute of the card object that was just created. If it matches the hash of an existing card, don't associate the card to the customer, but instead use the previously-existing one.
https://docs.balancedpayments.com/current/api.html?language=bash#tokenize-a-card

You could use an if statement in the jquery on the page where you collect the card. If the customer has selected an existing card then the balanced.js code does not execute.
If the customer adds a new card then it is tokenized and we use the following function (in php) to add the card to the existing customer:
function add_card($customer_id = NULL, $card_token = NULL){
$customer = \Balanced\Customer::get($customer_id);
$customer->addCard($card_token);
}

Related

Integrating Shopify and third-party gift-card system

Background
I am working with a retailer who has a store on Shopify. The store is not
on Shopify Plus.
The retailer has gift cards from a company other than Shopify. Each gift
card has a number on it that uniquely identifies the card. Associated with
the cards is a HTTP API, available to authenticated users, which can be used
to get or change the balance on a card.
Requirement
The retailer wants to allow customers to use these cards when ordering from
his Shopify store.
Ideal UI
From the user-interface point of view, the ideal would probably be something
like the following. We would add an input field to the Shopify payment
form, near the input field that has the placeholder "Gift card or discount
code". This new input field would be for the third-party gift-card number.
Suppose a customer had a gift card and entered its number into this input
field. Some custom software would check whether the gift-card number was
valid and the gift-card had funds. If either check failed, an error message
would appear in the form.
If both checks succeeded, the form would show success (perhaps by putting a
green check mark) next to the input field. Then it would adjust the balance
to be paid by the customer. For example, if the customer was ordering $300
worth of shoes, and tendered a gift card holding $50, then the $300 would be
adjusted to $250.
When the customer pressed the button to place the order, Shopify would debit
$250 from his credit or debit card, and some custom software would debit $50
from his gift card. It's probably acceptable for this custom software to
run after a delay of 5 seconds or so. (For example, it might be triggered
by a webhook.)
Discussion
I've been looking for a way to do the above. The really hard part is to
adjust $300 to $250 (not just in the form, but when Shopify actually charges
the customer). I have considered the following, singly and in combination:
Changing the Liquid templates.
Putting some custom JavaScript in the Shopify pages.
Writing an app that uses the Shopify Storefront API.
(3) seems the most promising, but it's not easy to see how to do in a "surgical"
way so that I only replace one screen.
I don't want to have to reimplement an entire Shopify store using the Storefront API.
Alternative UI
If you can think of an alternative UI that would achieve the same thing,
please feel free to propose it.
Similar question
This question,
including the questioner's two comments, describes a situation
identical to mine.
However, the only answer (if I understand it correctly) is unacceptable to me.
Ruled-out alternative
I proposed a web service to turn these third-party gift cards into Shopify
discount codes. That idea was rejected by the retailer, because he already
uses Shopify discount codes, and Shopify's form only allows a single
discount code.

How to know if my carrier is pick up in-store

I have a prestashop module in which they are asking me in a parameter to indicate if the carrier that was chosen is to pick up in store or not. I am getting the carrier information in this way
$carrier = new Carrier($cart->id_carrier);
This brings me the information of the carrier correctly, the problem is that the only parameter I see to know if it is pick up or not is delay, but this is a parameter which you can always change the value in the carrier configuration.
When creating the store in prestashop this creates 2 carrier by default, one is the pick up in-store, but if I delete this carrier and then I want to create another custom that is pick up in-store, prestashop does not provide a specific option to check that this carrier is of this specific method, the closest thing is the delay but this can change in many prestashop stores.
There is some method, parameter or function that tells me 100% if the carrier is pick up in-store, a parameter or something that never changes in any prestashop store?
Every carrier has id_reference in database, it is something what is always same, as you might know, every time you edit Carrier in PrestaShop, a new instance is created and inserted into database, id_reference field helps you track original id of Carrier.

Minimum fields to Maximize Payment Conversions?

I took a look at Bluesnap's Auth Capture API - https://developers.bluesnap.com/v8976-XML/docs/auth-capture specifically the "card-holder-info" element.
What minimum fields needs to be passed to maximize payment conversions? I want to map these fields to my checkout UI page where I would like to have my customers enter minimum number of fields to strike a balance between being frictionless vs maximize conversions.
Thanks.
The minimal details of the card holder are first name, last name and zip code. That's all the information BlueSnap requires to process the purchase.
The process is already pretty streamlined. From the optional fields you may add, adding country and state might have some effect as some processors use this information to validate the shopper.

Method for letting customers add additional personal information (ex: default size) in Shopify?

I'm a first-time Shopify developer looking for a way to let customers enter additional data about themselves in Shopify. Specifically, I'd like to add a page or modify the account info page so the customer can enter measurements. I'd then like to take that measurement information, process it, and return a recommended size for products in the shop.
Is this possible in Shopify? I am trying to figure out how to add metafields for customers to record their measurements, but I'm a bit lost.
This should work, but would require a fair bit of customization on the merchant's part and is a bit of a hack:
When a customer is logged in their info is available through Liquid.
This allows you to reference that customer's data when rendering shop pages, e.g. a Product page.
You can assign Metafields to customers using the API. These are also available through Liquid.
Putting this all together, you can have a form on the shopfront asking the customer for info once they're logged in. The form submits to your server where you add the info to the Customer object as Metafields using the API. Then you have some clever Liquid on the Product page that either does the necessary calculations itself or embeds the relevant info into javascript to be processed client-side.

When should the Ecommerce tracking take place?

I am implementing Google analytics onto a ecommerce site. We are already tracking events like adding to cart, removing etc using the event tracking. I would like to know what is the ideal time to use the ecommerce tracking apis (addTrans & addItem). Here are my questions:
Should I call these functions for each product being added to cart?
Should I call these functions only when the payment is complete and them while displaying receipt screen?
What is the ideal way of implementation? please provide best practices if possible.
Thanks in advance
I would track few things,
1.How many got into payment form and failed to buy, which can indicate to you that something wrong with payments or page itself. Count number of visitors in checkout - number of orders.
2.How many users got into site and haven't added at least one product, which will indicate that something wrong with advertisement, landing page or website layout in general. Number of unique visitors - those who added at least one item.
Adding statistics for each product added to cart shows you what? If users buy certain product you can get that this product is most wanted but in cart means noting imho. As for your second question, i would implement my solutions written above.
I wonder if your customers should go to an externally hosted page to make a payment. If they do, then GA tracking will not show you the real source of your profitable traffic - it will show you the payment processor page as the source.
It is recommended, or at least suggested, that you place the eCommerce tracking that includes the _trackTrans call on the "Thank You" or "Confirmation" stage of your checkout process.
Also, it's worth noting that if the user refreshes that page that the tracking is on then the code will be fired again and you may see skewed figures in Google Analytics.
I was like you, I also implemented the event tracking first but I wanted to get a chance to implement the ecommerce tracking to get some $ data in there to browse. So, on the developers page. One of the examples is on the reciept page, but on my implementation that wasn't going to work since I am use a payment API. So, On my checkout page I setup the parent transaction. using :
_gaq.push(['_addTrans',
'1234', // transaction ID - required
'Acme Clothing', // affiliation or store name
'11.99', // total - required
'1.29', // tax
'5', // shipping
'San Jose', // city
'California', // state or province
'USA' // country
]);
Then when I am listing my items in the cart, I use PHP and a foreach to dump each item, sku, price per item and quantity into the parent level transaction like this :
_gaq.push(['_addItem',
'1234', // transaction ID - required
'DD44', // SKU/code - required
'T-Shirt', // product name
'Green Medium', // category or variation
'11.99', // unit price - required
'1' // quantity - required
]);
For the last step in the process, I send transaction data to my merchant processing (paypal) via the SOAP api and get numerous responses back. I do different stuff based on the response I get back. If there is no error from the JSON response I get an COMPLETED response, at that point is when I fire the :
_gaq.push(['_trackTrans']);
I'm not really sure if this is the true way to go about it, but it makes sense to me.