charge tax if shipping address or billing is in California - prestashop-1.6

We want to charge tax if shipping or billing address is in California.
So to summarize, tax should be charged if:
Shipping address is California
Billing address is California
Do NOT charge tax if shipping and billing address both are outside of California.
Currently in the admin under tax setting I can choose either billing or shipping [drop down].
Please help me to modify the logic

Okay ! So finally I found answer to my own question and below what I did. This can be helpful
I Classes Cart.php under the function getSummaryDetails()
after this code
`$base_total_tax_inc = $this->getOrderTotal(true);
$base_total_tax_exc = $this->getOrderTotal(false);`
I have added $my_product_total = $this->getProductOrderTotal(true);
Where the function getProductOrderTotal() which I have written in order to get the total product price in the cart. After this, I have added
`
if($invoice->id_state==5 AND $delivery->id_state!=5){
$total_tax = ($my_product_total*8)/100;
$base_total_tax_inc=$base_total_tax_inc+$total_tax;
}
else{ $total_tax = $base_total_tax_inc - $base_total_tax_exc;}
`
5 is the id for California.
Notice AND $delivery->id_state!=5 in my IF condition. This I do because the delivery address is already set in the system(From Back admin) to TRUE.

Related

How to receive the verify data from bank in Core

I'm using this code to receive the verify data from bank API (Persian bank)
saleReferenceId = long.Parse(queryString["SaleReferenceId"].ToString());
saleOrderId = long.Parse(queryString["SaleOrderId"].ToString());
resultCode_bpPayRequest = queryString["ResCode"].ToString();
But After the user has paid the amount the SaleRefrenceId and other fields are empty. I wanna know how to receive these fields from bank API?
I used to receive it in asp.net.mvc by
Request.param["saleReferenceId"]
But know, I don't know how to take it in ASP.netcore
Plz help me with

How we can create employee pay cheques using qbfc?

I am using below code snippet to create cheques for employees using qbfc :
ICheckAdd chkAddQuery = requestMsgSet.AppendCheckAddRq();
chkAddQuery.AccountRef.FullName.SetValue("1001 - Bank (Test Account)");
chkAddQuery.IsToBePrinted.SetValue(true);
chkAddQuery.TxnDate.SetValue(DateTime.Now);
chkAddQuery.PayeeEntityRef.FullName.SetValue("Test Employee");
IExpenseLineAdd expAdd = chkAddQuery.ExpenseLineAddList.Append();
expAdd.AccountRef.FullName.SetValue("1001 - Bank (Test Account)");
expAdd.Amount.SetValue(1500.00);
But somehow these are coming under Non-Payroll transactions and not under Pay Cheques in quickbooks, so need help in how we can can create employee pay cheques in quickbooks ?
After following up with William on Intuit Developer Network i found that qbfc cannot be used to generate employee pay checks
https://help.developer.intuit.com/s/question/0D50f00004sugPACAY/how-we-can-create-employee-pay-cheques-using-qbfc

using Apple Pay for subscription with first month free

I'm working on an app that uses Apple Pay as a choice in payment method. Normal payment works fine. We have a product involving a subscription, and this works okay as well. We get the apple pay payment info, and then charge the user monthly server-side, using the merchant provider.
We are running into a problem where we have a subscription promo with the first month free. Apple Pay does not seem to support a $0.00 purchase, which would be the first month's cost. Normally we'd receive their credit card details, not charge the first month, but automatically charge monthly after that.
Specifically Apply Pay's PaymentRequest's paymentSummaryItems can't accept a an item with a $0.00 cost, and the total must add up to more than $0.00. Apple pay docs state:
Set the grand total amount to the sum of all the other items in the array. This amount must be greater than zero.
The initWithPaymentRequest call otherwise returns nil, and the modal presentation crashes the app. Error handling could avoid, but it doesn't help get the payment info as needed.
What is the best way to get payment info for a free trial month subscription, if apple pay doesn't accept $0.00 payment?
PKPaymentRequest *paymentRequest = [Stripe paymentRequestWithMerchantIdentifier:APPLE_MERCHANT_ID];
paymentRequest.requiredShippingAddressFields = PKAddressFieldEmail | PKAddressFieldName;
NSDecimalNumber *amount = [Util decimalNumberFromCostStr:cartModel.totals.grandtotalFormattedString];
paymentRequest.paymentSummaryItems = #[
[PKPaymentSummaryItem summaryItemWithLabel:cartModel.totals.grandtotalFormattedString amount:amount],
[PKPaymentSummaryItem summaryItemWithLabel:#"Company Name" amount:amount]
];
if ([Stripe canSubmitPaymentRequest:paymentRequest]) {
PKPaymentAuthorizationViewController *paymentController;
paymentController = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:paymentRequest];
paymentController.delegate = self;
paymentController.modalPresentationStyle = UIModalPresentationFormSheet;
[[Util topMostController] presentViewController:paymentController animated:YES completion:nil];
} else {
[Util alertWithTitle:nil message:#"Cannot submit payment request" delegate:nil];
}

Stripe - check if a customer exists

In the stripe documentation they have this:
customer = Stripe::Customer.create(email: params[:stripeEmail], card: params[:stripeToken])
charge = Stripe::Charge.create(customer: customer.id, amount: price, description: '123', currency: 'usd')
But I think it's wrong as for each payment we have to check if a customer exists first, I just tried it with a test account and it turned out there were created a number of different customers with the same email but different ids.
How do I check if a customer already exists?
There is no check on Stripe's end to ensure uniqueness of customers (email, card, name, etc,) and this is something you have to do on your end.
Usually, when you create a customer with a specific email address you need to associate the customer id you got back from the API with the email address. Then next time, you check whether this email address is already in your system and either create a new customer or re-use the customer id from the previous time.
You may check if the customer exists or not by calling GET /customers with the email as a form-urlencoded parameter. You will get 200 OK response but the returned data[] will be empty if this customer email is not there.
https://stripe.com/docs/api/customers/list
I think a simple "exists" test is essential to avoid unwanted exceptions being generated.
If your customer is new then they won't have a stripe ID, which is fine. However you might get a situation where you are using an existing customer with an existing stripe ID, but have performed some sort of dormant clean-up Stripe side. In which case its good practice to test the supplied stripeID to see if its still valid.
For example I store the stripeID with the customer profile. When I make a payment I check to see if the stripeID field in the profile exists. If it does I fire off a API request to my backend to check its existence.
Something like this (.net backend example).
[HttpGet]
public ActionResult<bool> CheckCustomer(string id)
{
var service = new CustomerService();
Customer cust;
try
{
service.Get(id);
}
catch
{
return Ok(false);
}
if (cust.Deleted ?? false)
{
return Ok(false);
}
return Ok(true);
}
I don't need the result, just it not throwing an exception is good enough. However, when you delete customers in Stripe live it keeps a copy of the ID stub and sets the delete property to true, so you need to check for that too.
The front end then can either use the stripeId for the payment or create a new stripe customer first then take the payment.
You can search for the customer by email address...
public async Task<Customer> GetCustomerByEmail(string oneEmail)
{
var service = new CustomerService();
try
{
StripeList<Customer> customerList = await service.ListAsync(new CustomerListOptions() { Email=oneEmail },null);
Debug.WriteLine(customerList.ToList().Count);
return customerList.ToList().FirstOrDefault();
}
catch
{
return null;
}
}

Update credit card expiry month and year nsoftware quickbooks

I am using nSoftware to interact with QuickBooks. My requirement is to update customer's credit card expiry month and year only. Code used for this is
nsoftware.InQB.Customer cust = new nsoftware.InQB.Customer();
cust.GetByName("test");
cust.CreditCard.ExpMonth = customer.CreditCardItem.CardExpMonth;
cust.CreditCard.ExpYear = customer.CreditCardItem.CardExpYear;
cust.Update();
Problem is GetByName method returns customer object which has credit card number like "xxxxxxxxxxxxxx1234". Updating customer object updates actual credit card number with xxx....1234. My requirement is to update only expiry month and year.
Dev Environment:- ASP.Net 4.0, C#
Modifying the credit card fields and calling the Update method will cause all of the card fields to be sent to QuickBooks, including the "xxxxxxxxxxxx1234" card number. In this case, specifying a new QBCard object can be done to make sure that only the credit card fields that you explicitly intend to update are sent to QuickBooks.
So, something like this should do the trick:
nsoftware.InQB.Customer cust = new nsoftware.InQB.Customer();
cust.GetByName("test");
QBCard card = new QBCard();
card.ExpMonth = customer.CreditCardItem.CardExpMonth;
card.ExpYear = customer.CreditCardItem.CardExpYear;
cust.CreditCard = card;
cust.Update();
Please let me know if this works for you.

Resources