General information
- SDK/Library version: 1.14.0
- Environment: Both Sandbox and Production
- Language, language version, and OS: PHP 7.2 on Ubuntu 16.10
Issue description
I have set the total to $1, but after paid, it always costs $85 ("shipping":"5","tax":"10","subtotal":"70" ), here's the codes:
$product = 'Hello, World!';
$description = 'Hello, World!';
$currency = 'USD';
$price = 1;
$shipping = 0;
$tax = 0;
$paypal = $this->paypal;
$subtotal = $price * 1;
$total = $subtotal + $shipping + $tax;
$payer = new Payer();
$payer->setPaymentMethod( 'paypal' );
$details = new Details();
$details->setShipping( $shipping )
->setSubtotal( $subtotal )
->setTax( $tax );
$amount = new Amount();
$amount->setCurrency( $currency )
->setTotal( $total )
->setDetails( $details );
$transaction = new Transaction();
$transaction->setAmount( $amount )
->setDescription( $description )
->setInvoiceNumber( uniqid() );
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl( 'https://domain.com/payment-result' )
->setCancelUrl( 'https://domain.com/payment-cancelled' );
$payment = new Payment();
$payment->setIntent( 'sale' )
->setPayer( $payer )
->setRedirectUrls( $redirectUrls )
->setTransactions( [$transaction] );
$request = clone $payment;
try {
$payment->create( $apiContext );
} catch (PayPalConnectionException $e) {
die( $e->getData() );
}
$approvalUrl = $payment->getApprovalLink();
add_header( location: $approvalUrl );
return $payment;
And this is log
[03-04-2020 08:55:54] PayPal\Core\PayPalHttpConnection : INFO: POST https://api.sandbox.paypal.com/v1/payments/payment
[03-04-2020 08:55:55] PayPal\Core\PayPalHttpConnection : DEBUG: Request Headers : POST /v1/payments/payment HTTP/1.1, Host: api.sandbox.paypal.com, Accept: */*, Content-Type: application/json, User-Agent: PayPalSDK/PayPal-PHP-SDK 1.14.0 (platform-ver=7.3.14-1~deb10u1; bit=64; os=Linux_4.10.2-041002-lowlatency; machine=x86_64; crypto-lib-ver=1.1.1d; curl=7.64.0), Authorization: Bearer A21AAFio3Upr9iBH7e-VWazpFCpeYubfFHqbQEbp7QEFfGe354A02bdv3wlBlZOGdXUeSeke5XrRVTrOSPl0xpcFsuqayPzng, Content-Length: 361, ,
[03-04-2020 08:55:55] PayPal\Core\PayPalHttpConnection : DEBUG: Request Data : {"intent":"sale","payer":{"payment_method":"paypal"},"redirect_urls":{"return_url":"https://demo.lovage.io/epp/payment-result","cancel_url":"https://demo.lovage.io/epp/payment-cancelled"},"transactions":[{"amount":{"currency":"USD","total":"1","details":{"shipping":"0","subtotal":"1","tax":"0"}},"description":"Hello world!","invoice_number":"5e86fa1aa46e7"}]}
--------------------------------------------------------------------------------------------------------------------------------
[03-04-2020 08:55:55] PayPal\Core\PayPalHttpConnection : INFO: Response Status : 201
[03-04-2020 08:55:55] PayPal\Core\PayPalHttpConnection : DEBUG: Response Headers : Cache-Control: max-age=0, no-cache, no-store, must-revalidate, Content-Language: *, Content-Length: 765, Content-Type: application/json, Date: Fri, 03 Apr 2020 08:55:55 GMT, Paypal-Debug-Id: 3531a093df75a,
[03-04-2020 08:55:55] PayPal\Core\PayPalHttpConnection : DEBUG: Response Data : {"id":"PAYID-L2DPUGY3T8910505S347164J","intent":"sale","state":"created","payer":{"payment_method":"paypal"},"transactions":[{"amount":{"total":"1.00","currency":"USD","details":{"subtotal":"1.00","tax":"0.00","shipping":"0.00"}},"description":"Hello world!","invoice_number":"5e86fa1aa46e7","related_resources":[]}],"create_time":"2020-04-03T08:55:54Z","links":[{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L2DPUGY3T8910505S347164J","rel":"self","method":"GET"},{"href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-44U11063WJ8096549","rel":"approval_url","method":"REDIRECT"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L2DPUGY3T8910505S347164J/execute","rel":"execute","method":"POST"}]}
================================================================================================================================
[03-04-2020 08:56:36] PayPal\Core\PayPalHttpConnection : INFO: GET https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L2DPUGY3T8910505S347164J
[03-04-2020 08:56:36] PayPal\Core\PayPalHttpConnection : DEBUG: Request Headers : GET /v1/payments/payment/PAYID-L2DPUGY3T8910505S347164J HTTP/1.1, Host: api.sandbox.paypal.com, Accept: */*, Content-Type: application/json, User-Agent: PayPalSDK/PayPal-PHP-SDK 1.14.0 (platform-ver=7.3.14-1~deb10u1; bit=64; os=Linux_4.10.2-041002-lowlatency; machine=x86_64; crypto-lib-ver=1.1.1d; curl=7.64.0), Authorization: Bearer A21AAFio3Upr9iBH7e-VWazpFCpeYubfFHqbQEbp7QEFfGe354A02bdv3wlBlZOGdXUeSeke5XrRVTrOSPl0xpcFsuqayPzng, ,
[03-04-2020 08:56:36] PayPal\Core\PayPalHttpConnection : DEBUG: No Request Payload
--------------------------------------------------------------------------------------------------------------------------------
[03-04-2020 08:56:36] PayPal\Core\PayPalHttpConnection : INFO: Response Status : 200
[03-04-2020 08:56:36] PayPal\Core\PayPalHttpConnection : DEBUG: Response Headers : Cache-Control: max-age=0, no-cache, no-store, must-revalidate, Content-Length: 1585, Content-Type: application/json;charset=UTF-8, Date: Fri, 03 Apr 2020 08:56:36 GMT, Paypal-Debug-Id: 3feac4379943e,
[03-04-2020 08:56:36] PayPal\Core\PayPalHttpConnection : DEBUG: Response Data : {"id":"PAYID-L2DPUGY3T8910505S347164J","intent":"sale","state":"created","cart":"44U11063WJ8096549","payer":{"payment_method":"paypal","status":"VERIFIED","payer_info":{"email":"[email protected]","first_name":"test","last_name":"buyer","payer_id":"FYADYGXGPWBGQ","shipping_address":{"recipient_name":"buyer test","line1":"NO 1 Nan Jin Road","city":"Shanghai","state":"Shanghai","postal_code":"200000","country_code":"C2"},"country_code":"C2"}},"transactions":[{"amount":{"total":"1.00","currency":"USD","details":{"subtotal":"1.00","tax":"0.00","shipping":"0.00"}},"payee":{"merchant_id":"KX6UB59E846NC","email":"[email protected]"},"description":"Hello world!","invoice_number":"5e86fa1aa46e7","item_list":{"shipping_address":{"recipient_name":"buyer test","line1":"NO 1 Nan Jin Road","city":"Shanghai","state":"Shanghai","postal_code":"200000","country_code":"C2"}},"related_resources":[]}],"redirect_urls":{"return_url":"https://demo.lovage.io/epp/payment-result?paymentId=PAYID-L2DPUGY3T8910505S347164J","cancel_url":"https://demo.lovage.io/epp/payment-cancelled"},"create_time":"2020-04-03T08:55:54Z","update_time":"2020-04-03T08:56:36Z","links":[{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L2DPUGY3T8910505S347164J","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L2DPUGY3T8910505S347164J/execute","rel":"execute","method":"POST"},{"href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-44U11063WJ8096549","rel":"approval_url","method":"REDIRECT"}]}
================================================================================================================================
[03-04-2020 08:56:36] PayPal\Core\PayPalHttpConnection : INFO: POST https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L2DPUGY3T8910505S347164J/execute
[03-04-2020 08:56:40] PayPal\Core\PayPalHttpConnection : DEBUG: Request Headers : POST /v1/payments/payment/PAYID-L2DPUGY3T8910505S347164J/execute HTTP/1.1, Host: api.sandbox.paypal.com, Accept: */*, Content-Type: application/json, User-Agent: PayPalSDK/PayPal-PHP-SDK 1.14.0 (platform-ver=7.3.14-1~deb10u1; bit=64; os=Linux_4.10.2-041002-lowlatency; machine=x86_64; crypto-lib-ver=1.1.1d; curl=7.64.0), Authorization: Bearer A21AAFio3Upr9iBH7e-VWazpFCpeYubfFHqbQEbp7QEFfGe354A02bdv3wlBlZOGdXUeSeke5XrRVTrOSPl0xpcFsuqayPzng, Content-Length: 142, ,
[03-04-2020 08:56:40] PayPal\Core\PayPalHttpConnection : DEBUG: Request Data : {"payer_id":"FYADYGXGPWBGQ","transactions":[{"amount":{"currency":"USD","total":"85","details":{"shipping":"5","tax":"10","subtotal":"70"}}}]}
--------------------------------------------------------------------------------------------------------------------------------
[03-04-2020 08:56:40] PayPal\Core\PayPalHttpConnection : INFO: Response Status : 200
[03-04-2020 08:56:40] PayPal\Core\PayPalHttpConnection : DEBUG: Response Headers : Cache-Control: max-age=0, no-cache, no-store, must-revalidate, Content-Length: 2094, Content-Type: application/json;charset=UTF-8, Date: Fri, 03 Apr 2020 08:56:40 GMT, Paypal-Debug-Id: 6e5ebc5f1a79b,
[03-04-2020 08:56:40] PayPal\Core\PayPalHttpConnection : DEBUG: Response Data : {"id":"PAYID-L2DPUGY3T8910505S347164J","intent":"sale","state":"approved","cart":"44U11063WJ8096549","payer":{"payment_method":"paypal","status":"VERIFIED","payer_info":{"email":"[email protected]","first_name":"test","last_name":"buyer","payer_id":"FYADYGXGPWBGQ","shipping_address":{"recipient_name":"buyer test","line1":"NO 1 Nan Jin Road","city":"Shanghai","state":"Shanghai","postal_code":"200000","country_code":"C2"},"country_code":"C2"}},"transactions":[{"amount":{"total":"85.00","currency":"USD","details":{"subtotal":"70.00","tax":"10.00","shipping":"5.00","insurance":"0.00","handling_fee":"0.00","shipping_discount":"0.00"}},"payee":{"merchant_id":"KX6UB59E846NC","email":"[email protected]"},"description":"Hello world!","invoice_number":"5e86fa1aa46e7","item_list":{"shipping_address":{"recipient_name":"buyer test","line1":"NO 1 Nan Jin Road","city":"Shanghai","state":"Shanghai","postal_code":"200000","country_code":"C2"}},"related_resources":[{"sale":{"id":"7LV16321SK655952D","state":"pending","amount":{"total":"85.00","currency":"USD","details":{"subtotal":"70.00","tax":"10.00","shipping":"5.00","insurance":"0.00","handling_fee":"0.00","shipping_discount":"0.00"}},"payment_mode":"INSTANT_TRANSFER","reason_code":"PAYMENT_REVIEW","protection_eligibility":"INELIGIBLE","transaction_fee":{"value":"3.19","currency":"USD"},"parent_payment":"PAYID-L2DPUGY3T8910505S347164J","create_time":"2020-04-03T08:56:39Z","update_time":"2020-04-03T08:56:39Z","links":[{"href":"https://api.sandbox.paypal.com/v1/payments/sale/7LV16321SK655952D","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/payments/sale/7LV16321SK655952D/refund","rel":"refund","method":"POST"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L2DPUGY3T8910505S347164J","rel":"parent_payment","method":"GET"}]}}]}],"failed_transactions":[],"create_time":"2020-04-03T08:55:54Z","update_time":"2020-04-03T08:56:39Z","links":[{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L2DPUGY3T8910505S347164J","rel":"self","method":"GET"}]}
I have found everywhere, but not sure where the shipping fee, tax is come from.