Sabre Web service air cancellation and refund flow - php

I have done air ticket cancellation service. but I don't know how to refund the amount. If anyone know how to refund the balance amount. Please provide the flow of refund web-service. we used here PHP, and soap API.

Sabre has a webservice for an Automated Refunds (TKT_RefundRQ). However, the list of aircompanies supporting the Automated Refunds flow is very limited, you may find it here.
I guess in most cases you should read fare rules (cat. 16) to find out what penalties apply. You may use either StructureFareRulesRQ for structured or OTA_AirRulesLLSRQ for plain text fare rules.

Step 1:
Save your Ticket order into another table. You need to put the order value (Money) . into the table
step 2:
when somebody orders a ticket you have to Cut that ticket price and save a new price in your amount table
( Now for example You have a amount of 200$ in your amount table)
( You ordered a ticket , store that ticket ID )
(get ticket amount using Join query ) or ( You can store the amount in the order table )
Step3:
Get you amount from amount table and subtract with the order amount
Here you go... got whole idea?
Happy coding ...

Related

CS-Cart The transaction was not sent to the host because of a duplicate order id

I'm using Menoris payment processor on CS-Cart v 4.3.9, a while ago this error has become more frequent "Payment processor response: The transaction was not sent to the host because of a duplicate order id".
I don't understand why is it happening, so I don't know where to look, I have tried to trigger the error myself but couldn't.
Check you table cscart_orders and have a look at those IDs.
I dont think you've reched the maximum limit of mysql entries in cscart_order to be duplicate (16777215 - is the maximum value for the field with the integer type).
In my opinion the problem is where you send data, consider to ask them for that.
Check this too: http://forum.cs-cart.com/topic/45830-issue-with-order-id/
Please change the code and create an unique order id for each time a customer try to pay the order, something like
ex: 12345_1
where order_id = 12345 and 1 order_repaid value
you can check how 2checkout payment gateway is doing for example ;) app/payments/2checkout.php
...
$cart_order_id = ($order_info['repaid']) ? ($order_id .'_'. $order_info['repaid']) : $order_id;
...
if Monoris doesn't accept for order_id to be string than you will need to generate and unique order_id for each time customer try to buy and attach to order_id in this way on payment return you will be able to get the real order_id and compete the payment
*[duplicate order id] - issue is happening when a customer goes to Monoris payment page and customer click cancel or get back to website and after that he goes again to pay the order
Thanks all for your answers, i have managed to solve this by adding a time stamp next to the order id
'order_id' => $processor_data['processor_params']['order_prefix'] . $order_info['order_id'] .'_'. date("G:i:s"),

What is the best way to maintain relevance of figures?

We have 2 tables - Orders and Payment_Methods.
Orders have payment_method_id column where we have foreign key for Payment_Methods table. At all we have 2 payment methods (cash / online payment).
Every 4 hours we have money collection from the cash inbox.
In our business it is very important to have exact current cash inbox figures.
Here are 2 ways of building current state of cash inbox.
1) Set up a table / field in database where we will have current cash inbox value. We will change it with each order saving. But it is hard to say how many checks we should do because payment statuses and payment methods in any order could be changed.
2) We should every time sum all order totals (total column) and minus all collections.
I know that I've written this in a very primitive way but I hope that I've managed to describe you the main problem.

MySQL + PHP data/codescheme design multiple differentiations

I am trying to design a data structure where the class/table has multiple differentiation's withing it itself. I am not sure what to call this or if I use the right terminology.
Hopefully I can illustrate my problem with the following example:
There is a webshop and somebody buys something and goes to the check out. At the check out they can select their payment type. The customer selects cash and with what currency.
An other customer does the same but pays online with credit card.
Now I have the following mysql scheme for this situation:
**Order**
order_id
customer_id
is_paid
payment_type_id
**payment_type**
payment_type_id
payment_name
And a customer table with the usual information. But where do I save if was paid and if required information about how the customer is going to pay.
How would such a database look like and what would the queries look like?
I am not a fan of a little field within tables where the data could be anything depending on the type (or is that the way to go?) cause of querying problems.
Hopefully I am clear enough in what I am asking.
If you have a single payment for each order you want to have it attached to it, so the 'is_paid' is just fine there, as well as the payment type. In this case you want the currency there also. Cause it is independent of the payment type.
I only see problems if you want to know more info about the payment like when it was paid or if you consider a payment for more than one order at a time or even if a payment don't happen at the same time as the order and you want to separate the concepts.
To solve the 1st instead of is_paid you can have a datetime field that when it's NULL is not paid. For the 2nd and 3rd you would need some Payment entity also. For a richer model with some logic about the payment I would have something like:
**Order**
id
payment_id
...
(all sort of info about the order)
** Payment **
id
customer_id
payment_type (or payment_type_id)
payment_value
payment_currency
payment_date
...
(more info about the payment)
Depending on what you'll do with payment_type you can consider having only a value describing the type or an id for the table with more info about it as you already had.
However this will be an overkill if you just have Order 1..1 Payment, in that case just store payments info as you had, along the order.
This is subjective, but I usually have a payment type (cash, credit card, souls, etc.), a payment amount (100.00) and a payment currency (USD, CAD, MXN, etc.) fields in the order table, alternatively, and if you payment system supports it, you can add conversion factor.

Payment Gateway Implementation

I am integrating one of the payment gateway to my site in PHP, Before proceeding further, As I am new to this, I have some doubts (use cases/scenarios), So I need a solution to deal with these scenarios. I have listed them here
1) How to pass unique id to payment gateway, while It considers it as a Order No, But In real scenario Order NO/ID will be generated only on successful transaction. I thought of sending a random number to Payment gateway. On successful transaction i can store in Order table.
Table: Order
1) aID:(unique, Primary, AI)
2) RandomNo(unique)
3) Order Date
Is this a good Idea
2) Which ID to be shown to user As ORDER ID either the aID or RandomNO
3) Do I need to store the Response from the payment gateway in the DB, such as Payment ID(unique), Response Code, OrderNO & Amount. How it will be useful.
4) What are the possible scenarios that can occur after payment gateway integration, And How to deal them
1) How to pass unique id to payment gateway, while It considers it as a Order No, But In real scenario Order NO/ID will be generated only on successful transaction. I thought of sending a random number to Payment gateway. On successful transaction i can store in Order table.
ANS : First of all insert the order in database before redirecting to payment gateway and use the unique id of that insertion as order id.
2) Which ID to be shown to user As ORDER ID either the aID or RandomNO
ANS : The order id as mentioned above can be shown to the user.
3) Do I need to store the Response from the payment gateway in the DB, such as Payment ID(unique), Response Code, OrderNO & Amount. How it will be useful.
ANS : Yes! You must store response from payment gateway as you may need it in future in case of any dispute.
4) What are the possible scenarios that can occur after payment gateway integration, And How to deal them
ANS : I didn't get you in this question.

How to design a revenue table out of an ecommerce app?

I'm actually worried about designing the perfect tables to handle transactions and commissions. especially that we really don't want tables to be out of sync in any case.
Basically this is like ebay, where merchants sell to buyers and we get a commission out of each transaction.
The app is already built using Codeigniter, and it has:
Merchants(id,name,balance)
Transactions(id,merchant_id,buyer_id,amount,transaction_id)
Now what other tables to make if needed to make us able to fetch our revenue and the seller's revenue, and what's the best DB mechanism to process a refund?
And should we make another table of each deposit to the merchant's balance rather than +x the balance row.
Whenever you are dealing with any financial tasks, always store as much information about it as possible.
There are two ways of keeping all your tables in sync.
Database level - using options such as stored procedures and triggers
Application level - Use transactions (innoDB) and make sure that the transactions are atomic. (I would suggest to go with this)
Regarding the database design -
Add a column commission to Transactions that tracks your commission. Data for this can be either calculate beforehand when pricing the item or on the fly during the transaction.
The buyer pays product cost + commission, seller gets product cost and you get commission. If your commission is a variable (not a flat rate and changes from item to item), you could have a column in the Items table which stores it. Things should be trivial from now on. You just have to maintain a History table that keeps a list of transactions with respect to the user. It would look something like
AccountHistory(id, transaction_type, transaction_id, amount)
You could split AccountHistory into two - one for incoming money and one for outgoing money.
So everytime a transaction takes place the following happens
Entry into to Transactions table.
Entry into AccountHistory for buyer
Update buyer balance
Entry into AccountHistory for seller
Update seller balance
All this should be atomic.
For rollbacks, you could add a column transaction_type to distinguish rollbacks from normal transaction or you could maintain a separate table.
Having worked with a database where the design had financial transactions scattered around a bunch of different tables, I can tell you that it is much better to have all transactions in a single table. You should add transaction type to your transaction table (and a look up table for the transaction types).
Then each transaction can have a separate line for commission and seller product cost. Transaction that are undone later would get entered in as negative amounts. It is also helpful for these types of things to add a parent transaction field so that you can easily identify which transaction it was changing.
All data entry that forms part of a transaction should be in a stored proc and have transactions so that if one part of the insert fails, the entire thing is immediately rolled back. This is critical. It needs to be in a stored proc so that no one (except systems dbas) has direct access to tables that store financial records.
When you start to think of handling financial transactions the very worst thing you can do is design for the user interface alone. You need to design for the financial reporting you will need to have. You need to consult the people who will be auditing your finances to see what information they need and what internal controls they expect you to have in place to prevent internal as well as external fraud.

Categories