Good morning everyone,
I have a question and a problem to solve. I'm setting up a transparent checkout, and it works by the way. Currently I put products in the cart, I add the subtotals, to make a total result and it's perfect, and when I set up the pager's checkout array, I give an id, description and default amount, with the calculated total, and the payment is done. My question and problem is: how can I put my products in the pagseguro array, having sample cart session loop, informing description, id, quantity and value, follow the example:
"[email protected]\
&token=57BE455F4EC148E5A54D9BB91C5AC12C\
&paymentMode=default\
&paymentMethod=creditCard\
&[email protected]\
¤cy=BRL\
&extraAmount=1.00\
&itemId1=0001\ // essa linha precisa ser o loop
&itemDescription1=Produto PagSeguroI\ // essa linha precisa ser o loop
&itemAmount1=99999.99\ //essa linha precisa ser o loop
&itemQuantity1=1\ //essa linha precisa ser o loop
&itemId1=0002\
&itemDescription1=Produto PagSeguroII\
&itemAmount1=99999.98\
&itemQuantity1=2\
¬ificationURL=https://sualoja.com.br/notifica.html\
&reference=REF1234\
&senderName=Jose Comprador\
&senderCPF=11475714734\
&senderAreaCode=99\
&senderPhone=99999999\
&[email protected]\
&senderHash=52578d5d3336ec7a43ff1dae4794d0c5625feddcc8fbc0e80bcb0cb46c9947d4\
&shippingAddressStreet=Av. PagSeguro\
&shippingAddressNumber=9999\
&shippingAddressComplement=99o andar\
&shippingAddressDistrict=Jardim Internet\
&shippingAddressPostalCode=99999999\
&shippingAddressCity=Cidade Exemplo\
&shippingAddressState=SP\
&shippingAddressCountry=ATA\
&shippingType=1\
&shippingCost=21.50\
&creditCardToken=1e358d39e26448dc8a28d0f1815f08c5\
&installmentQuantity=1\
&installmentValue=300021.45\
&noInterestInstallmentQuantity=2\
&creditCardHolderName=Jose Comprador\
&creditCardHolderCPF=11475714734\
&creditCardHolderBirthDate=01/01/1900\
&creditCardHolderAreaCode=99\
&creditCardHolderPhone=99999999\
&billingAddressStreet=Av. PagSeguro\
&billingAddressNumber=9999\
&billingAddressComplement=99o andar\
&billingAddressDistrict=Jardim Internet\
&billingAddressPostalCode=99999999\
&billingAddressCity=Cidade Exemplo\
&billingAddressState=SP\
&billingAddressCountry=ATA".
Or would I have to put all this info inside the loop, and have to put the xml assembly, would I have the status return, duplicated multiple times depending on how many items?
Tenho esse código que faz uma compra transparente do Pagseguro.
$ params = array (
'email' = > $ PAGSEGURO_EMAIL,
'token' = > $ PAGSEGURO_TOKEN,
'creditCardToken' = > $ creditCardToken,
'senderHash' = > $ senderHash,
'receiverEmail' = > $ PAGSEGURO_EMAIL,
'paymentMode' = > default
'paymentMethod' = > creditcard
'currency' = > 'BRL',
// 'extraAmount' = > '1.00',
'itemId1' => '0001',
'itemDescription1' => 'PHP Test',
'itemAmount1' => $numero,
'itemQuantity1' => 1,
'itemId2' => '0002',
'itemDescription2' => 'PHP Test2',
'itemAmount2' => $numero,
'itemQuantity2' => 1,
'reference' => 'REF1234',
'senderName' => $senderName,
'senderCPF' => $senderCPF,
'senderAreaCode' => 83,
'senderPhone' => $senderPhone,
'senderEmail' => $senderEmail,
'shippingAddressStreet' => $shippingAddressStreet,
'shippingAddressNumber' => $shippingAddressNumber,
'shippingAddressDistrict' => $shippingAddressDistrict,
'shippingAddressPostalCode' => $shippingAddressPostalCode,
'shippingAddressCity' => $shippingAddressCity,
'shippingAddressState' => $shippingAddressState,
'shippingAddressCountry' => 'BRA',
'shippingType' => 1,
'shippingCost' => $shippingCost,
'installmentQuantity' => 1,
'installmentValue' => $installmentValue,
'creditCardHolderName' => 'Chuck Norris',
'creditCardHolderCPF' => '54793120652',
'creditCardHolderBirthDate' => '01/01/1990',
'creditCardHolderAreaCode' => 83,
'creditCardHolderPhone' => '999999999',
'billingAddressStreet' => 'Address',
'billingAddressNumber' => '1234',
'billingAddressDistrict' => 'Bairro',
'billingAddressPostalCode' => '58075000',
'billingAddressCity' => 'João Pessoa',
'billingAddressState' => 'PB',
'billingAddressCountry' => 'BRA'
);
How do I get PHP to dynamically grab items from the cart and put it inside the $ params [] array? Why can not all cart products be shipped?
This part takes the products to be generated inside the array by PHP:
'itemId1' => '0001',
'itemDescription1' => 'PHP Test',
'itemAmount1' => $numero,
'itemQuantity1' => 1,
'itemId2' => '0002',
'itemDescription2' => 'PHP Test2',
'itemAmount2' => $numero,
'itemQuantity2' => 1,
Would it look like this?
$ params = array (
'email' => $PAGSEGURO_EMAIL,
'token' => $PAGSEGURO_TOKEN,
'creditCardToken' => $creditCardToken,
'senderHash' => $senderHash,
'receiverEmail' => $PAGSEGURO_EMAIL,
'paymentMode' => 'default',
'paymentMethod' => 'creditCard',
'currency' => 'BRL',
// 'extraAmount' => '1.00',
'reference' => 'REF1234',
'senderName' => $senderName,
'senderCPF' => $senderCPF,
'senderAreaCode' => 83,
'senderPhone' => $senderPhone,
'senderEmail' => $senderEmail,
'shippingAddressStreet' => $shippingAddressStreet,
'shippingAddressNumber' => $shippingAddressNumber,
'shippingAddressDistrict' => $shippingAddressDistrict,
'shippingAddressPostalCode' => $shippingAddressPostalCode,
'shippingAddressCity' => $shippingAddressCity,
'shippingAddressState' => $shippingAddressState,
'shippingAddressCountry' => 'BRA',
'shippingType' => 1,
'shippingCost' => '1.00',
'installmentQuantity' => 1,
'installmentValue' => '3.00',
'creditCardHolderName' => 'Chuck Norris',
'creditCardHolderCPF' => '54793120652',
'creditCardHolderBirthDate' => '01/01/1990',
'creditCardHolderAreaCode' => 83,
'creditCardHolderPhone' => '999999999',
'billingAddressStreet' => 'Address',
'billingAddressNumber' => '1234',
'billingAddressDistrict' => 'Bairro',
'billingAddressPostalCode' => '58075000',
'billingAddressCity' => 'João Pessoa',
'billingAddressState' => 'PB',
'billingAddressCountry' => 'BRA'
);
$ filter = preg_grep ('/ ^ itemId ([0-9] {1,}) /', array_keys ($ params)); $ result = array (); for ($ i = 0; $ i