0

I am working with a paypal checkout in php after successful postback from paypal I am getting all transaction details using print_r($_REQUEST, 1); with this piece of line it is saving full bunch of array data like below

Array
(
[route] => payment/pp_standard/callback
[mc_gross] => 130.00
[invoice] => 42 - sala uddin
[protection_eligibility] => Eligible
[item_number1] => Product 14
[mc_fee] => 5.37
[txn_id] => 8BX904469F430674P
)

I need to get only [txn_id] How can I get only [txn_id] from above

Mithu
  • 665
  • 1
  • 8
  • 38
  • 1
    `$_REQUEST` is an array. `$_REQUEST["txn_id"]` is what you are looking for. – Cid Nov 20 '19 at 10:38
  • 1
    Actually `$_REQUEST['txn_id']` makes more sense... – arkascha Nov 20 '19 at 10:41
  • 1
    [Don't use $_REQUEST](https://stackoverflow.com/questions/2142497/whats-wrong-with-using-request) to be on safer side. – nice_dev Nov 20 '19 at 10:43
  • @arkascha what do you mean ? – Cid Nov 20 '19 at 10:43
  • @Cid A question of style (readability) and performance. Though indeed it is minimal here :-) – arkascha Nov 20 '19 at 10:46
  • How is the performance increased ? Because a double quote weights twice a single quote :p ? – Cid Nov 20 '19 at 10:48
  • Thanks its working with $_REQUEST['txn_id'] – Mithu Nov 20 '19 at 11:13
  • 1
    @Cid it is likely negligible speed wise for Mithus app but best practice is to use a single quote since double-quote further looks to interpret variables inside the double-quotes. see [php quotes](https://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php) – Jairus Jan 07 '20 at 14:50
  • 1
    @Cid @vivek_23 is correct, you should use `$_POST['txn_id']`, as someone could inject data in the URL. – Jairus Jan 07 '20 at 14:54

0 Answers0