php - How to send item information to paypal? -
i trying send item information paypal using json formatted array in php, haven't been able find resources figure out how this.
here current json array being passed paypal curl in php:
$dataarray = array( "intent" => "sale", "redirect_urls" => array( "return_url" => $url_success, "cancel_url" => $url_cancel ), "payer" => array( "payment_method" => "paypal" ) ); $dataarray['transactions'][0] = array( 'amount' => array( 'total' => round($sale->gettotal(), 2, php_round_half_up), 'currency' => $sale->getcurrency(), 'details' => array( 'subtotal' => round($sale->getsubtotal(), 2, php_round_half_up), 'tax' => round($sale->gettax(), 2, php_round_half_up) ) ), 'description' => "test payment" ); the above working, order summary blank on paypal. found following code add information on individual items.
// prepare individual items $dataarray['transactions'][0]['item_list']['items'][] = array( 'quantity' => '1', 'name' => 'womens large', 'price' => '0.01', 'currency' => 'usd', 'sku' => '31wf' ); $dataarray['transactions'][0]['item_list']['items'][] = array( 'quantity' => '1', 'name' => 'womens medium', 'price' => '0.01', 'currency' => 'usd', 'sku' => '31wfw' ); this code not working. supposedly working person posted it. i'm not sure why both items appear adding same item same location in array, copy , pasted site, array name changed, i'm sure had. i've been trying find site found on, can't remember how got there. site found on did not specify parts of array required. i'm sure $dataarray['transactions'] required, don't know rest of identifiers : ([0]['item_list']['items'][]). can give me example of how send info multiple items? thank you!
ok, apparently had correct after all. turns out problem price fields each item didn't add subtotal of whole transaction. had random values in there test it. apparently requires values match.
Comments
Post a Comment