How to generate card nonce for repeated transactions without making users to enter card details? - square-connect

We have a requirement that payment should be initiated repeatedly without user's intervention just like monthly/yearly subscription fees for Mobile Apps in Google Play store . The payment should be triggered from the back end automatically after a particular interval (amount may not be same for every interval). We found that in square payment card nonce is used for performing a transaction. Card nonce is generated from the Payment form when the users enter their card information for the first time. How to generate the nonce for further transactions without making users to enter their card details in square payment form?

You would want to utilize the Card on File functionality. Basically, the first time a customer enters their credit card details in the Square Payment Form, you would generate a nonce, and then use the nonce to save the card to a customer's profile (so you would of course need to create a Square customer as well). In the future, you would be able to charge the card on file, rather than making them enter their card details again.
Details around saving cards on file with Square: https://docs.connect.squareup.com/payments/transactions/cookbook/save-cards-on-file
Details around charging charges on file with Square: https://docs.connect.squareup.com/payments/transactions/cookbook/charge-cards-on-file
Details around the CreateCustomerCard endpoint: https://docs.connect.squareup.com/api/connect/v2#endpoint-customers-createcustomercard

Related

Square Gift Card Balance

Is there a way to check the balance of Square gift cards through the API? I'm making an app on behalf of a merchant at a school who would like to facilitate mobile orders through the use of prepaid gift cards.
According to the user documentation, the receipt of a transaction received by the customer will display any remaining balance, but when I look at the API documentation no such information seems to be provided.
Any advice? Thanks.
You were right to check out the documentation. At this time there isn't an API for any giftcard functionality, including checking balances.

processing loyalty swipe cards in square

I was taking a look at the Square API. I am trying to find a solution for VIP/loyalty cards for a private club. I feel like the square API would be useful. What I am trying to figure out is if it is possible to read data from a gift card/security card in the API. My Idea is to use the reader in two places, at the front door to verify VIP status and for payment. Ideally, the card would have a member id that could be linked to a Facebook account, as well as looking up saved payment info in Square. I would like to use the API to build a tablet app to manage all of these functions as well as provide discounts prior to payment processing.
I noticed mentions of 3rd party gift card support, does that mean this would be possible? or is the data for non credit card swipes still locked down?
You cannot get card data from the readers. The gift card support is only for payments.

Best practice to detect if 2 customers try to use same credit card in braintree

I want to know what's the best practice if:
User1 uses card xyz1 and xyz1 successfully verified and added in braintree.
User2 uses same card xyz1 and xyz1 verification failed and added in braintree with verification failure reason.
I want to find users which try xyz1 (either successful or failed) in braintree.
Anything like fingerprint in stripe.
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.
You can search for transactions in your vault that used the same credit card by using the credit card unique identifier in a transaction search. This will get you a response containing all transactions that made use of the same card. From there, you can inspect the transaction response object for information about the customer that created it.
You cannot use the credit card unique identifier in verification searches. Instead, you could search for verifications based on customer ID or payment method token, then pull the credit card unique identifier from the verification response object.
In Ruby, the transaction search would look something like this:
collection = Braintree::Transaction.search do |search|
search.credit_card_unique_identifier.is "the_unique_identifier"
end
collection.each do |transaction|
puts transaction.customer_details.id
end
Looks like there's an option in their PaymentMethod.create call that will fail if the same card has already been added to your Braintree Vault. Link to that attribute here

how can i implement recurring payment for payeezy in codeigniter?

I want to integrate recurring payment using Payeezy in codeigniter. I have implement the single time payment using curl and now i want to recurring payment with acknowledgement to update my DB.
I created a WordPress plugin for Payeezy that also handles recurring. You should be able to use the underlying PHP code for CodeIgniter.
https://wordpress.org/plugins/wp-payeezy-pay/
I can explain the process that will get you the least PCI compliance issues, and that's the token-based API.
1. Generate Token in Payment Form
So basically you'll use the Javascript API to generate your authorize token. An authorize token doesn't charge the card. It's for validating the card and returning a token for better PCI compliance. This API source code and explanation is here:
https://github.com/payeezy/payeezy_js
2. Post Form To Your Server for the Curl Call to FirstData
Then, once you have this token, you post it back to your controller file with a standard form post, but remove the name attribute on your credit card number and credit card CVC fields so that these do not post to your server. Note that you'll need to store this data (but not card number and CVC) because on refunds (and subscription cancellations) you'll need to reply back with the last purchase token, cardholder name, card type, card expiration date, amount spent, and currency code. You may wonder why FirstData/PayEezy is asking you to store cardholder name, card type, and card expiration date. Well, there's a perfectly good explanation for that. Your call center may need that detail for troubleshooting an issue over the phone with a customer. Also, you need that for refunds. And, most importantly, if you're doing a recurring subscription payment, your code needs to look at the expiration date ahead of time before charging because the API call will fail if the card is past expiration. Last, because you're not storing the credit card number and credit card validation (CVC) code, you're going to be in stronger PCI compliance.
From there, since you are already familiar with the Curl process for a single-purchase, it's just a minor single field change (transaction_type becomes 'recurring') in the Curl to do the recurring. For anyone not familiar with the Curl process, it's explained here:
https://developer.payeezy.com/payeezy-api/apis/post/transactions-4
Also, for those unfamiliar people, you'll need to read up on how FirstData/PayEezy wants you to send in the Curl request with a special header that includes Content-Type: application/json, apikey, token, Authorization, nonce, and timestamp. You can see more detail about that here:
https://github.com/payeezy/payeezy_direct_API/blob/master/payeezy_php/example/src/Payeezy.php
(What I did to make that code simpler was intercept the Curl calls from that script into a log file so that I could make it much more straightforward in a single function instead of breaking it up into all these little functions. That made it far easier to understand what was going on.)
3. Switching Curl Call for Recurring Payments
So, as you discovered in your Curl call, you saw how to do a one-time purchase by setting the transaction_type to 'purchase'. For doing recurring, you set transaction_type to 'recurring'. You have to do that from the start. So, if I'm selling something for $29.99 monthly, the very first month charge needs to still be set to type 'recurring', as would any subsequent month.
4. Your Responsibilities for Recurring Payments
Now, this is where everyone gets hung up because it's poorly documented unless you check the PayEezy Developer Support Forum. For subscriptions, PayEezy doesn't have a system for setting payment plans with varying durations, nor setting up automatic (set-it-and-forget-it) subscriptions for you. (I think I read that they have something experimental on Apple Pay, but nothing else yet.) So, to achieve this, you have 2 choices:
Use Chargify.com. Unfortunately, though, this increases CPA (Cost Per Acquisition) of your product or service. You'll have to factor that in if you want to use that. This basically is a SaaS service that you send the transaction to and they handle the automatic subscription plan for you against FirstData/PayEezy.
Roll your own cron job solution. To do this, you basically take the Curl code for a single transaction, and change the transaction type from 'purchase' to 'recurring'. (Do that from the start -- don't start with 'purchase' on a recurring charge.) From there, it's up to you with your own cron job to check for product or service expiration terms, and then send the API call back off to FirstData/PayEezy for charging that card again with the 'recurring' transaction_type.
On either of those options, the customer never gets asked to enter in credit card data past the first time unless their card expires or unless you have some problem billing that card (like insufficient funds).
Of course, doing your own cron job route for the recurring payment has implications you'll need to prepare for:
Add some failsafe code so that you prevent the possibility of duplicate transactions, such as a database field.
Add some failsafe code such that if you have cancelled a subscription, you won't charge them again.
Add some failsafe code such that if they cancel their subscription, yet purchase it again as a subscription at a later time, that you do charge them again and don't block it from your other failsafe code.
Add some sort of grace period on your product or service such that even if you "say" that the term expired, you have like a 2 day grace period so that your API has a chance to do a renewal.
It's probably a good idea to email the customer before their renewal period so that they can make certain they have money in their account and have a way to cancel that charge (like call your office or call center, or have a link to click where you provide a way to cancel).
If their card has expired before the renewal, and you detect that in the warning email that comes before renewal, then you'll want to let them know this.
If their card has been declined for any reason at the point of renewal, then you'll want to let them know this and give them a link to go through the cart again to buy it again, or some other way to save that transaction in your code.
How To Do Subscription Cancellations / Stop Recurring Payments
To stop a recurring payment, you treat it just like a refund on a single purchase, but use the transaction ID of the last purchase. This is documented with this Curl example here:
https://developer.payeezy.com/payeezy-api/apis/post/transactions/%7Bid%7D-0
Look under "Refund" and choose Token.

Stripe & transferring funds

I am currently in the process of planning & developing an integrated application using Stripe in addition to some other technologies (a combination of backbone & laravel). As a result I am using Stripejs in combination with the PHP stripe library.
I use stripejs to send Stripe their account info (for savings accounts I send country, routing and account numbers via stripes js lib, I then save off the created token in the response to the backend). I am attempting to transfer money to various recipients following charging accounts (so I have money in my stripe account) but I am a bit confused over exactly what approach to take.
My main questions are as follows.
If I am positive of the identities of the individual’s using the application, is verification required (5 – 10 people max will be using)?
If it is required what is the best approach to verifying the user using the current technique I am using (create a token, save off on the backend)?
From my experience with Stripe, you don't need to 'verify identities' each time you use a token, so long as a customer has been set up for recurring use. So as long as your application is properly secured so that only the 5-10 people can use it, and can only process payments for their own accounts, you are good to go. In other words, you obviously want to do your own user verification to make sure only valid people can use the application, but you don't need to do it as far as Stripe is concerned.
That said, if you are in essence transferring money between people, you might want to go the extra distance and make sure that the user has the correct card number or bank account number each time. In which case I would use something like:
Get user data using tokens stored in DB.
$cu = Stripe_Customer::retrieve("cus_4pn93XXXXXXXXXXX");
$card = $cu->cards->retrieve("card_14g7ZU4rLTyXXXXXXXXXXX");
If Stripe's returned data matches user-submitted data, you know you have the correct user. In particular, if the last 4 digits of the card and the expiry date match the last 4 returned by Stripe and the Stripe returned expiry date, you can be reasonably sure (albeit not certain) that the person actually possesses the card in question.

Resources