anouarabdsslm/laravel-paypalpayment

need explain in amount calculation

greatsami opened this issue · 5 comments

Please can yon explain to me how you calculate amount in function paywithCreditCard()

//Payment Amount
		$amount = Paypalpayment::amount();
		$amount->setCurrency("USD")
			// the total is $17.8 = (16 + 0.6) * 1 ( of quantity) + 1.2 ( of Shipping).
			   ->setTotal("20")
		       ->setDetails($details);

what is 16, 06, quantity of what, and 1.2?

Thanks

@greatsami the total = sub_total + shipping + taxes so for the example i have with the package we have this :

sub total = (item_1_price * quantity)  + (item_2_price * quantity) + ... (item_n_price * quantity)
//EXample in the doc
sub total = (2*5) + (7.5*1) = $17.5 

total = sub total + shipping + taxes

total = 17.5 + 1.2 + 1.3  = $20

Let me know if the help you to understand how the amount get calculated .

@anouarabdsslm thank you for reply
now, it is clear.

There are some conflicts with me in documentation:
1 - there are taxes in twice items (0.2, and 0.3), not calculated with subtotal, why?
2 - Also there are shipping and tax in $details, where is it calculation?
3 - what is $17.8, and (16 + 0.6)? in commented line.

thank you for explanation :)

the first item tax is set to 0.3 and quantity set to 1 so total tax for that item will still 0.3 for the second one tax is set to 0.2 and we have quantity set to 5 which means total taxes for that item is 1 and from that the total tax will be 0.3+1=1.3 for the data in document line are not correct i forget to fix it after i have changed the items prices.

if that explain the blurry part for, you can close this issue.

Yes, now it is cleared, thank you :)