Re: Replace punctuation in an associative array

The Doctor <[email protected]> Tue, 7 Mar 2023 22:53:23 -0000 (UTC)
Newsgroups comp.lang.php
Organization NetKnow News
Message-ID <[email protected]>
J.O. Aho <[email protected]> wrote:
: On 3/7/23 17:43, The Doctor wrote:
: > The Doctor <[email protected]> wrote:
: > : J.O. Aho <[email protected]> wrote:
: > : : On 3/5/23 01:52, The Doctor wrote:
: > : : > In article <[email protected]>,
: > : : > J.O. Aho <[email protected]> wrote:
: > : : >> On 3/5/23 00:58, The Doctor wrote:
: > : : >>> J.O. Aho <[email protected]> wrote:
: > : : >>
: > : : >>> : https://pastebin.com/bF6bZseu
: > : : >>> : Keep in mind nothin is a 100% solution for your issue as I haven't
: > : : >>> : bothered really go into the API that is used but just a bit based on
: > : : >>> : your posts in this group.
: > : : >>>
: > : : >>> : And please, what ever you do, don't go with the str_replace, it's not
: > : : >>> : the solution to your issue, it will just make things a lot harder to
: > : : >>> : maintain.
: > : : >>>
: > : : >>>
: > : : >>> Actually the class approach works better.
: > : : >>
: > : : >> That's good, just tweak it to fit your user case, just don't forget
: > : : >> validate the input data.
: > : : >>
: > : : >>
: > : : >>> Too bad Google does not pick that up
: > : : >>> in their searches for JSON>
: > : : >>
: > : : >> Much depends on the requirements and what the json is used for, say
: > : : >> sending data between angular and php, then the coder is usually in
: > : : >> control of both front end and backend and can use what ever json format
: > : : >> they want, but it's different when you have to follow an API, but
: > : : >> usually you can get support from the API owner and payment services tend
: > : : >> to also do a verification round before letting you to use production
: > : : >> grade transactions.
: > : : >>
: > : : >
: > : : > A good article can be written about this.
: > 
: > : : Great, post the link when you have written it ;)
: > 
: > : : It's about time, to write a good example that make sense without bad
: > : : coding and then host and promote the page, not everyone is prepared to
: > : : do that.
: > 
: > : : Sadly we see a lot of cheap cut the corner stuff out on the net, much
: > : : for people have sample with simple structures so arrays works ok, but
: > : : that is much based on the quality of the education they had. For example
: > : : there is a country that spits out 2 million CS each year, many of them
: > : : have a skills level not much than general high school students
: > : : programing knowledge level. Should also note that there are really good
: > : : programmers from that country too.
: > 
: > : : The main thing is that you get forward on your project.
: > 
: > 
: > : Wait until you see the nightmare in bureaucracy.
: > 
: > Other nightmare, I might have to write a preview page.

: I would make a function that can update an existing item in the orders 
: cart, similar to the one AddItem, with the tweak that if the quantity is 
: 0 then it removes the item. Lets call the function for UpdateItem.

: In the overview page you do as before, create the order object, 
: serialize it and store in the session.

: On the overview page you have to have some ajax calls, so that you can 
: increase and decrease the quantity of items and of course delete. In the 
: ajax call you need to send the project_code and also the new quantity.

:  The php script will unserailize the order from session, do the 
: changes, serialize the order and store it in session before sending 
: response with the new order->txn_total, order->cart->subtotal, and 
: order->cart->tax->amount

: You will then use javascript on the overview page to remove items and 
: also update the values.

: When the customer want to proceed, you just go to the next page and you 
: unserialize the order and use it as you did before to send it to the 
: payment service.

: With help of Ajax, you can make things quite neat and maybe even avoid 
: many unnecessary load of "full php pages". Use some framework if 
: possible, I would give you just one advice, avoid angular, as you need 
: to keep on updating it quite frequently.

: - - - - -

: if we have the order object we had in the examples earlier in the thread 
: then you just serialize it with: $serialized_order = serialize($order);
: and the string would look like:

: O:5:"order":20:{s:16:"order_tax_rate";d:0.13;s:16:"order_subtotal";d:400;s:16:"order_taxtotal";d:52;s:8:"store_id";N;s:9:"api_token";N;s:11:"checkout_id";N;s:9:"txn_total";s:6:"452.00";s:11:"environment";N;s:6:"action";N;s:5:"token";a:2:{i:0;O:5:"token":2:{s:8:"data_key";s:4:"1234";s:9:"issuer_id";s:16:"645sddfvdrt4tefd";}i:1;O:5:"token":2:{s:8:"data_key";s:4:"5678";s:9:"issuer_id";s:16:"645sddfvdrt4tefd";}}s:7:"ask_cvv";N;s:8:"order_no";N;s:7:"cust_id";N;s:18:"dynamic_descriptor";N;s:8:"language";N;s:5:"recur";O:5:"recur":6:{s:8:"bill_now";N;s:12:"recur_amount";N;s:10:"start_date";N;s:10:"recur_unit";N;s:12:"recur_period";N;s:16:"number_of_recurs";N;}s:4:"cart";O:4:"cart":3:{s:5:"items";a:3:{i:0;O:4:"item":5:{s:3:"url";s:29:"https://example.net/item?id=1";s:11:"description";s:6:"item 
: 1";s:12:"product_code";s:1:"1";s:9:"unit_cost";s:3:"100";s:8:"quantity";s:1:"1";}i:1;O:4:"item":5:{s:3:"url";s:29:"https://example.net/item?id=2";s:11:"description";s:6:"item 
: 2";s:12:"product_code";s:1:"2";s:9:"unit_cost";s:3:"200";s:8:"quantity";s:1:"1";}i:2;O:4:"item":5:{s:3:"url";s:41:"https://custom.url.exmple.net/olditems/33";s:11:"description";s:6:"item 
: 3";s:12:"product_code";s:1:"3";s:9:"unit_cost";s:2:"50";s:8:"quantity";s:1:"2";}}s:8:"subtotal";s:6:"400.00";s:3:"tax";O:3:"tax":3:{s:6:"amount";s:5:"52.00";s:11:"description";s:3:"Tax";s:4:"rate";s:5:"13.00";}}s:15:"contact_details";O:14:"contactdetails":4:{s:10:"first_name";N;s:9:"last_name";N;s:5:"email";N;s:5:"phone";N;}s:16:"shipping_details";O:7:"address":6:{s:9:"address_1";N;s:9:"address_2";N;s:4:"city";N;s:8:"province";N;s:7:"country";N;s:11:"postal_code";N;}s:15:"billing_details";O:7:"address":6:{s:9:"address_1";N;s:9:"address_2";N;s:4:"city";N;s:8:"province";N;s:7:"country";N;s:11:"postal_code";N;}}

: when you need it again as an object you just run:
: $order = unserialize($_SESSION['serialized_order']);

: as the customer won't be able to modify the serialized data, you don't 
: need to think about validating the incoming data, it's a completely 
: different history if the serialized data had been posted.

Will take time to look at this suggestion.

Javascript and I barely get along.

-- 
Member - Liberal International This is [email protected] Ici [email protected]
Yahweh, King & country!Never Satan President Republic!Beware AntiChrist rising!
Look at Psalms 14 and 53 on Atheism https://www.empire.kred/ROOTNK?t=94a1f39b 
Fools presume to know all; the wise know they do not. -unknown Beware https://mindspring.com