Orders / Transactions / Charge Square Connect - javascript

What are the steps that I need to follow to properly charge a customer using square-connect?
I'm confused because the documentation is not very clear about this.
Do I have to create an Order object then do a Transactions and the Charge?
Do a Transactions and then charge?
Can charge directly?

Generally your workflow is to create a card_nonce using the payment form, and then send that to the charge endpoint with the amount you want to charge.
Create card nonce -> Charge
If you want itemizations for your transaction, you can optionally create an order as well
Create card nonce -> Create Order -> Charge

Related

Stripe Payment Intent / Setup Intent combination in python

We want to have a SetupIntent and PaymentIntent confirmed at the same time. The reason is that we have a product which is paid yearly (beginning) and also metered billing where the customer pays based on usage each month.
Because of the dual durations (month/year) we have two subscriptions with one subscription item each.
To activate one of them we give the client_secret to the frontend where it is used to send payment data.
How can I use that to activate both the SetupIntent and the PaymentIntent as well without sending the customer both client_secrets and expecting to fill out the card data twice.
Beset regards and nice weekend!
I found a solution, where a proof of concept in the test world worked:
Create a setup intent
Give the secret to the user
As soon as the payment method is accepted, I can create both subscriptions
For knowing WHICH subscriptions to create, I put those data into the metadata field -> Can use this data in the called webhook :)
In the webhook I can then create and directly confirm the subscriptions :)
done!
Sounds reasonable, right?

Can we do auth transaction in Telr as continuous authority transaction?

I am developing a service provider mobile app in react-native that uses Telr payment gateway for handling payments through cards. I followed Mobile API Integration Guide and successfully integrated in my app . Till now I am able to make initial transaction with any of the transaction types provided by Telr in Mobile API. Initially I make 1.00 AED transaction using transaction type of sale and transaction class of paypage . This is the minimum amount of transaction that we have to make when adding card in app. After successful initial transaction I get trans_ref(transaction reference) in response which I can use for making further transactions. All required details, such as card number and expiry date, will be retrieved from the transaction reference and I don't have to provide any card details again.
After this when I've to make another transaction using the same card I've to provide previous trans_ref in my transaction request and use transaction type of sale with transaction class of cont. But I want to use transaction type of auth because of my apps business logic. Basically, I am developing a service provider app and when customer book or schedule any service using card, we need to hold the total bill amount until the service is finished and after successfully completion of service we have to transfer the actual amount from customer account to service providers account.
When I use transaction type of auth with transaction class of cont I get error message of Invalid transaction type, but when I use transaction type of sale with transaction class of cont everything works fine. I want to confirm that can we use transaction type of auth with cont transaction class or not?

How to correlate Stripe Token with items purchased; prevent spoofing

I am using Stripe Checkout for the front-end with the back-end creating the charge with the produced token.
How can I check in the back end that the token created for the purchase of a set of items is indeed for that set of items? Here is a more detailed scenario:
Item A costs $10
Item B costs $1,000
User chooses B and uses the front-end to generate a Token that was created with an amount of $1,000.
The front-end sends the token and the purchased item list (just B) to the back-end.
The back-end can calculate the given purchased item list to calculate a cost (but where can it verify with the token?) of $1,000 for verification that the user bought B and then a charge is made with the token.
My concern is if at step 2 the user spoofs the sent purchase list to be just A (I know that it is worth less than B but this should be rejected still). Then at step 3, how should the back-end figure out to reject making a Stripe Charge with the token?
Attempt:
Front-end passes Token, totalCost, listOfItems.
Back-end calculates the cost from the listOfItems and checks that it matches the totalCost before creating a Stripe Charge for an amount totalCost.
Is this as secure as it can get?
That's why you should use webhook
webhook documentation
To validate your payment has been made and the amount is correct, you can use webhook instead of user action to trigger. It's common practice nowadays.
After you receive the webhook, you may trigger change of status of the order after your checking (amount, client_info, other checking).

how to write meteor migration script to insert one collection data to another collection?

i need to insert one collection data to another collection. how can i write migration script for this purpose. card payments and corporate customer payment are two collections.
corporate customer payment collection has below attributes customerID,outsTanding,date,amount,headOfficeId,insertDate
cards payment collection has below attributes
customerID,amount,card,packageId,cardId,classType,expireDate,headOfficeId,insertDate
i'm inserting cards payment collection following datas to corporate customer payment collection.
CustomerID -> card.customerID
outsTanding -> card.cartId
date -> card.insertDate
amount -> card.amount
headOfficeId ->card.headOfficeId
so how can i apply this change for old datas. how need i write meteor migration for up and down functions.
anyone who had this issue assist me.
thanks

How to Prevent/Manage Stripe Webhook Sending Invoice for $0 on Trial Signup?

I'm working on an app that comes with a 14 day trial for free.
To handle payments, I'm using Stripe and listening for webhooks so I can perform functions on the backend when events happen.
One thing I've noticed, though, is that Stripe is sending me invoice data with an amount charged of $0 for the trial period. So, if a customer signs up, they get an invoice from Stripe for $0 (I have my webhook setup to fire off an email for each invoice I receive).
This isn't terrible, but from a UX perspective, I'd like to avoid the shock of getting an immediate invoice when someone is expecting a trial (even if that invoice is for $0).
I've considered just checking the data Stripe sends over and filtering out $0 invoices, but if I offer a discount or something, this doesn't seem like the best way.
Any thoughts/notes on how to implement this better?
A couple options here:
When you create the customer/subscription, the API returns both the customer and the subscription data to you in its response. You can use data from either or both of these to filter intelligently. Of particular interest:
current_period_start: This will also be the timestamp of the invoice.
trial_end: Until this timestamp, any invoice including a subscription is for a trial.
customer: If you don't like the others, you can always query the customer record when processing a $0 invoice. Customers in their trial period have a status of trialing.
If you're sending the email on invoice.created events, only the initial subscription invoice is created as closed. All other subscription invoices are open when Stripe creates them. (This is so you can make adjustments before the invoice is processed.) An invoice that's both $0 and closed has a high probability of being a trial—100%, in fact, if you're not otherwise creating already-closed invoices.
Try to listen for charges events. The event charge.succeeded Only fired when user has ben charge successfully.

Categories

Resources