3v4l.org

run code in 300+ PHP versions simultaneously
<?php const CheckOutPurchaseState = array( 0 => "New", // The partner site just negotiated a session but the Check-Out form hasn't been shown in a browser yet. 1 => "BeingProcessed", // The customer is going through the Check-Out wizard. 2 => "Completed", //The Check-Out has been successfully completed. 3 => "Error", // The Check-Out session has been canceled either by the user or due to an error. 4 => "WaitingForSignicat", // A redirect to Signicat website has been made and the customer hasn’t get redirected back to the original page yet. It purchases gets stuck it this state, a possible cause is that the page of the partner site that hosts the Check-Out form doesn't handle redirects correctly. 5 => "SessionTimedOut", // The session timed out or wasn’t even created for a long time after the purchase has been initialized. 6 => "WaitingForCardPayments", // A redirect to card payment provider has been made and the customer hasn't been redirected back to the original page yet. Same as with WaitingForSignicat state, if purchases gets stuck in this state, the host page might not be able to render itself repeatedly. 7 => "WaitingForBankId", //Waiting for response from BankId application. 8 => "Cancelled", //When merchant calls CancelPayment method and order is canceled. 9 => "WaitingForFinnishDirectPayment" //The customer has been redirected to a Finnish bank for a direct payment. ); function getPurchaseStateValue($purchaseStateName) { echo $purchaseStateName; echo print_r( CheckOutPurchaseState, true); if(in_array($purchaseStateName, CheckOutPurchaseState)) { return array_search($purchaseStateName,CheckOutPurchaseState); } else { //return the New state as default return array_search('New', CheckOutPurchaseState); } } echo getPurchaseStateValue('Complete');

preferences:
47.75 ms | 402 KiB | 5 Q