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

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?

Related

Integreate Node js With Stripe

I have a website which is multivendor, I am using stripe payment gateway for our website, and I have to charge the customer and transfer 5% of the amount of the total product price to the admin and transfer remaining amount to the vendor account. But I am not sure how to use stripe to do that, Below is the example of what I want actually,
I have a product worth $5, I have to charge customer credit card with $5 and transfer 5% means $0.25 to admin account & 4.75 into vendor account, So how can I do that.
Can anyone help me to solve the issue, please?
Thanks.
You can use Stripe connect for this.
Below are the steps to achieve this in Stripe.
Vendor onboarding process
In this process, the vendor has to connect his Stripe account to Platform account which is you. In this process, you will get Stripe account Id of vendor and you will get required permission to do a checkout on behalf of a user
Now choose the checkout process which suits your needs
(Direct charges, Destination charges, Separate charges and transfers). From your requirement, it seems to direct charges so that vendor will responsible for all transaction charges and you will get application fee on each transaction
Now you can create charges By specifying application fee and connected account's Id.
You can refer here for more details
Here is code snippet in ruby you will use to charge
Stripe.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"
charge = Stripe::Charge.create({
:amount => 1000,
:currency => "usd",
:source => "tok_visa",
:application_fee => 123,
}, :stripe_account => "{CONNECTED_STRIPE_ACCOUNT_ID}")
Here are few more resources from where you can learn this
https://simpleprogrammer.com/stripe-connect-ultimate-guide/
https://medium.com/#noodlio/stripe-connect-tutorial-how-to-start-accepting-payments-on-behalf-of-your-users-while-charging-a-5bfc1b5e4294

How to know if Paypal transaction was successful using the API?

I try to integrate PayPal into my checkout process. Here is what I did:
I managed to use the Paypal API Node SDK to create payments with PayPal.payment.create.
and then redirecting the user to the payment URL I get in the response to links[1].href which is something like this: "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-00N000849T505604G".
On that page I sing in with my sandbox user and pay the transaction, I get redirected to my custom success page I declared when creating the payment.
On my Success Page, I want now to check if the transaction really was successful to update my database, so I call my backend, that calls a GET to the transaction to the links[0].href which is something like https://api.sandbox.paypal.com/v1/payments/payment/PAY-1VL72645VS000000XLLARPMI to check for the status.
Unfortunately, the state property of the response is always created.
What am I doing wrong? How can I check it? I was using these docs as a reference.
Generally, I’m a bit overwhelmed by the number of docs and not sure which one is correct and could not find any concise tutorial :S
Thanks for your help!
State property of the response is created is the current one.
The state property's possible values created, approved, failed.
created. The transaction was successfully created.
approved. The customer approved the transaction.
failed. The transaction request failed.
but approved. should be The buyer( not customer) approved the transaction.
You can get this from Payment.php file in line #376 of PayPal-PHP-SDK project.
https://github.com/paypal/PayPal-PHP-SDK/blob/master/lib/PayPal/Api/Payment.php
At first State property will created but it will be approved when The buyer approved the transaction using Update payment then you can check List payments /Show payment details then you will found payment is now approved.
For Update payment
https://developer.paypal.com/docs/api/payments/#payment_update
and Show payment details https://developer.paypal.com/docs/api/payments/#payment_get

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).

Orders / Transactions / Charge Square Connect

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

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