identifying and blocking suspicious attempts - concurrency

i am about to start work on a group-buying site. it works like this: a phone costs 100USD, but if 50 people buy it together , u get a price of 70USD.
so the website launches this offer, waits for 50 people to deposit money . once the threshold is reached, everyone is sent a coupon and that person can go and get his phone.
the problem.. there will be few offers which will be time-limited. for example, total of 100 mobile phones available only. the first 100 users can only buy it. the offer starts on 5th janissary at 11am.
now, how we can detect any suspicious attempts. like a person writing a script and buying all the 100 units.
i dont think IP based limits is a good enough criteria as REAL BUYERS may access the website using the same IP.
environment is LAMP.

why should you care , the more you sell the more you make money :) if the transaction is made you can enforce that user can't buy with same payment method and credentials twice. And as you said user must deposit money before he can make the purchase. You can ask user credit card data before the sale is opened, that is rather good limit as scammer must use 50 different credit cards

Related

How to build events aggregation service for high load system with DynamoDB

I'm working on an Ad-tech system which serves millions of users.
Basically users (non anonymous users) can see different Ads that are being created by the marketing team.
Our marketing team want to be able to set some Frequency caps on those Ads (among other targeting rules they already have)
For example:
"We should not show this ad for a user if he already seen/click this ad more than X times in the last Y days"
Also ads can be grouped to campaigns, so rules like that are also possibile:
"We should not show this for a user if he viewed more than X times ads in this campaign in the last Y days".
Also our marketing might wanna know how many people viewed/click a specific add in the last Y days.
We have roughly 200K RPM and our responses should be very fast.
The smallest unit of time for our queries is one day and it will not change.
Few questions and thoughts:
Is DynamoDB a good fit?
I thought about creating a table for each event type (Click/View/Close..)
What is the best way to configure the primary key?
I thought about settings the primary key as the user id and the sort key as a combination of the ad id and the current day {dd/mm/yyyy}
I thought about use "ADD" operation to increase the counter when a user click/view/.. an Ad in a specific date. are they expensive operations? do I have an alternative?
What is the best way I can use to also be able to query per ad and campaigns as well (for example: "all users views for all ads in campaign" or "get all ad views in the last 40 days) ) ?
What other considerations should I take in mind?
Thanks a lot

Understanding the amount of GCP billing

I work at an advertising agency.
I would like to know the amount of GCP invoiced as accurately as possible before the invoice arrives, and I would like to know where I can check that on the Partner Sales Console.
I know I can check the tabs in the dashboard, but there was a discrepancy with the amount on the invoice, and I would like to know if there is a way to get a more accurate picture.

Partial Captures on Order payment in Spree

I am using Spree and I have modified it as per client requirement. I am stuck at one modification, I need an expert opinion.
Case that Spree provides by default
Spree provides default payments of auto-capture on/off on order and full payment is captured
Modifications that I want
with auto-capture mode = off
Verify that user has a certain amount in its account that can be less than total amount of order.
Make a partial payment capture of that and store remaining amount somewhere.
When order gets completed after shipment etc or some other action was done, capture the remaining amount.
My Questions
How should I modify Spree to achieve these tasks?
If I make a transaction of $5 with auto-capture = off, Is it possible to capture $10 when transacting that $5 authorization? If it is not possible, then do I have to update this $5 transaction's amount with $10 using OAuth Token. If yes, then how?
Extra Info
I want gateway independent solution by using Spree Payments classes so that I don't have to configure this for each Gateway I integrate. Right now I have 7-8 gateways including Stripe and Paypal.
Case creation for my problem, just an example
Total Order Payment = $50.
First of all I want to verify that user has $10 in his/her account?
If user has $10 then make a transaction with auto capture mode = off and in someway keep remaining amount i.e $50 - $10 in record somewhere.
Now I capture $10 and after 2 days shipment gets completed. Now I want to capture that remaining $40 and order gets completed.
Your question must be answered in the context of each individual Payment Gateway as each one operates with different rules.
You have asked too many questions to provide a specific answer but generally speaking CNP (Card-Not-Present) transactions do not let you capture above the authorized amount, but it depends on your industry and the deal you have with your merchant and payment processor.
2- If I make a transaction of $5 with auto-capture = off, Is it possible to capture $10 when transacting that $5 authorization? If it is not possible, then do I have to update this $5 transaction's amount with $10 using OAuth Token. If yes, then how?
Generally you do not "update" a prior transaction to a different amount (although as I said above, in other industries it is sometimes possible to capture at an amount higher than the authorized amount). You should be authorizing the total amount you may want to capture, an then make multiple capture calls to your payment gateway as the goods ship or services are delivered (by CC industry rules, you are generally not allowed to capture until you have delivered the service.)
I don't know of any Payment gateways that use "Oauth tokens" for communication, that is generally an authentication-based, not API based, technology.
-> I want gateway independent solution by using Spree Payments classes so that I don't have to configure this for each Gateway I integrate. Right now I have 7-8 gateways including Stripe and Paypal.
Sounds like a huge disaster. Get rid of them, the time debugging each gateway alone makes this an absolutely insane idea.
Total Order Payment = $50.
1) First of all I want to verify that user has $10 in his/her account?
Generally you can't "peak" into someone's private bank account and see how much money they have-- this is a feature you invented. What you can do is authorize the total amount you might want to charge in the future.
2) If user has $10 then make a transaction with auto capture mode = off and in someway keep remaining amount i.e $50 - $10 in record somewhere.
3) Now I capture $10 and after 2 days shipment gets completed. Now I want to capture that remaining $40 and order gets completed.
What you need is one authorization with multiple captures. Call your Payment processor representative and have a conversation about this with them and see what rules govern your merchant and processor accounts.

Partially apply a CreditMemo on NetSuite API

im working on an integration between our company systems and NetSuite using PHP. Before the newest release of the NetSuite platform we were able to partially apply an existing credit memo to an specific pending invoice, but since their last release a couple of weeks ago every time we try to apply the credit to an specific invoice through our middle PHP system, it also applies all the other pending invoices in the account.
Let me specify a little more:
We have customer accounts, every account can have any number of open invoices. Lets say we have 3 invoices in the account 1. The first is for $20, the second for $30 and the last for $25. Then we create a credit memo associated to the account 1 for $75.
Then a week later we want to kill the first invoice of the account 1, the one with the $20 value. Then we command the credit memo to kill that invoice through our system. That would mean the first invoice is cancelled, we used $20 from the $75 we had in the credit and we still have $55 without use. Right?
Well, now for some reason the credit kills all the 3 invoices the account 1 had pending, even though we specify that only the first one should be applied. That consumes all the $75 of the credit memo, which of course messes up our accounting and prevents us from using it later in other invoices as we need it.
Just a few more points:
We are uploading our credit memos with property "autoapply" set on false.
When we want to apply an invoice we set its "apply" property as true and the ones from the other invoices as false, then we make an update request for the credit memo with that info. Thats how we always did it but now for some reason it doesnt works.
Sorry if its a little long, but i wanted to be really specific. If you have had a similar problem or have any insight on the matter i would greatly appreciate any help you can give. Thanks.
One suggestion you can try as I have experienced this as well. I had an issue where the user whose log in I was using for the integration entered a new credit memo, checked the box to auto apply and from then on every CM I imported through web services auto applied and did not respect the Auto Apply setting I submitted.
Log in as the user that you are authenticating with for the integration. Open a new credit memo and see if the Auto Apply check box is checked by default. This is a "sticky" setting in NetSuite. Enter a new CM As the user with the box unchecked and then delete it if you like. When I did this it stopped checking the box automatically and my CM import worked as expected again.

Amazon FPS - aggregate multiple payments?

This has to do w/ Amazon's Flexible Payment service:
In order to try to save transactions costs I would like to aggregate all of my customers' payments & then settle them in a single pay request at the end of the day. Is this possible?
For instance, in the same day, Bob buys something for $25, Susan buys something for $30, Tim buys something for $15. Instead of sending a pay request for EACH person immediately after they buy, I want to send a SINGLE pay request at the end of the day.
The examples Amazon gives for Aggregated Payments only lists multiple payments from the SAME user, not different users.
This isn't possible, because the fees cover the processing of customers credit and debit cards, so they need to be applied to the balance of each customer.
You could still use aggregate payments to send a pay request at the end of the day for each user (in case they buy something else), but each credit card needs to be charged and you can't combine those charges.