Zend_Db Enum Values - zend-framework

I find this solution
$metadata = $result->getTable()->info('metadata');
echo $metadata['Continent']['DATA_TYPE'];
Hi,
I want to get enum values in Zend_Db.
My Code:
$select = $this->select();
$result = $select->fetchAll();
print_r($result->getTable());
Output:
Example Object
(
[_name] => country
[query] => Zend_Db_Table_Select Object
(
[_info:protected] => Array
(
[schema] =>
[name] => country
[cols] => Array
(
[0] => Code
[1] => Continent
)
[primary] => Array
(
[1] => Code
)
[metadata] => Array
(
[Continent] => Array
(
[SCHEMA_NAME] =>
[TABLE_NAME] => country
[COLUMN_NAME] => Continent
[COLUMN_POSITION] => 3
[DATA_TYPE] => enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America')
[DEFAULT] => Asia
[NULLABLE] =>
[LENGTH] =>
[SCALE] =>
[PRECISION] =>
[UNSIGNED] =>
[PRIMARY] =>
[PRIMARY_POSITION] =>
[IDENTITY] =>
)
I see enum values in data_type but i don't get this values. How can get data_type?

I find this solution
$metadata = $result->getTable()->info('metadata');
echo $metadata['Continent']['DATA_TYPE'];

Related

Issue with first() attribute in Laravel 8

I tried to fetch the first element of my DB. When I wanted to bring it with first(), it showed me lots of data, and I couldn't access the data attributes.
Here is my simple Code .
Model Code:
$all_value_bulk=BulkEmail::where('status','processing')->where('processing_status',null)->first();
print_r($all_value_bulk);
Output::
App\Models\BulkEmail Object ( [table:protected] => bulk_email_verification [fillable:protected] => Array ( [0] => file_path [1] => user [2] => file_id [3] => status [4] => record [5] => unverified [6] => file_name ) [connection:protected] => mysql [primaryKey:protected] => id [keyType:protected] => int [incrementing] => 1 [with:protected] => Array ( ) [withCount:protected] => Array ( ) [preventsLazyLoading] => [perPage:protected] => 15 [exists] => 1 [wasRecentlyCreated] => [escapeWhenCastingToString:protected] => [attributes:protected] => Array ( [id] => 67 [file_path] => public/uploads/1654107283-test.csv [user] => 1 [file_id] => 74478 [record] => 6 [unverified] => 6 [created_at] => 2022-06-01 18:14:43 [updated_at] => 2022-06-01 19:16:29 [status] => processing [initial_invalid] => [file_ids] => [valid] => 2 [unknown] => 0 [invalid] => 2 [download_path] => https://client.myemailverifier.com/downloadreport/csv/74478 [download_status] => finished [ready_for_download] => 1 [finished_time] => 1654110989 [duplicate] => 1 [free_domain] => 4 [catch] => 1 [xls_file_path] => https://client.myemailverifier.com/downloadreport/xls/74478 [file_name] => test.csv [accept_all] => 0 [role_based] => 4 [processing_status] => ) [original:protected] => Array ( [id] => 67 [file_path] => public/uploads/1654107283-test.csv [user] => 1 [file_id] => 74478 [record] => 6 [unverified] => 6 [created_at] => 2022-06-01 18:14:43 [updated_at] => 2022-06-01 19:16:29 [status] => processing [initial_invalid] => [file_ids] => [valid] => 2 [unknown] => 0 [invalid] => 2 [download_path] => https://client.myemailverifier.com/downloadreport/csv/74478 [download_status] => finished [ready_for_download] => 1 [finished_time] => 1654110989 [duplicate] => 1 [free_domain] => 4 [catch] => 1 [xls_file_path] => https://client.myemailverifier.com/downloadreport/xls/74478 [file_name] => test.csv [accept_all] => 0 [role_based] => 4 [processing_status] => ) [changes:protected] => Array ( ) [casts:protected] => Array ( ) [classCastCache:protected] => Array ( ) [attributeCastCache:protected] => Array ( ) [dates:protected] => Array ( ) [dateFormat:protected] => [appends:protected] => Array ( ) [dispatchesEvents:protected] => Array ( ) [observables:protected] => Array ( ) [relations:protected] => Array ( ) [touches:protected] => Array ( ) [timestamps] => 1 [hidden:protected] => Array ( ) [visible:protected] => Array ( ) [guarded:protected] => Array ( [0] => * ) )
You can use dd() than you show first element
$all_value_bulk=BulkEmail::where('status','processing')->where('processing_status',null)->first();
dd($all_value_bulk);
Otherwise you use var_dump result Not easily readable, is it? The trick here is to View Source in browser, in case of Chrome/Windows it’s CTRL+U:
It returns array in object
You can try
$id_val = $all_value_bulk[0]->id;
This worked for me very well

write mongodb driver query with php fetch records from embedded array

Filter item from records array it should only return two items because records.score = 100 having only two items instead this it return me all the records. Can you please help on this thanks.
I have multiple records wherein I would like to fetch only filter records. where I am doing mistake please guide and suggest.
stdClass Object
(
[_id] => e5s65d5e5s65d5s65d44f12
[records] => Array
(
[0] => stdClass Object
(
[date] => MongoDB\BSON\UTCDateTime Object
(
[milliseconds] => 1609923848000
)
[score] => 100
[country] => US
[state] => Connecticut
[city] => Berlin
)
[1] => stdClass Object
(
[date] => MongoDB\BSON\UTCDateTime Object
(
[milliseconds] => 1609923501000
)
[score] => 100
[country] => US
[state] => California
[city] => Barstow
)
[2] => stdClass Object
(
[date] => MongoDB\BSON\UTCDateTime Object
(
[milliseconds] => 1609923157000
)
[score] => 145
[country] => US
[state] => Alabama
[city] => Alexander City
)
[3] => stdClass Object
(
[date] => MongoDB\BSON\UTCDateTime Object
(
[milliseconds] => 1609923108000
)
[score] => 150
[country] => US
[state] => Alaska
[city] => Anchorage
)
)
)
$mng = new MongoDB\Driver\Manager("mongoatlas/");
$filter = ['records.score' => '100'];
$query = new MongoDB\Driver\Query($filter, ['sort' => ['records.date' => 1], 'limit' => 6]);
$rows = $mng->executeQuery("db.table", $query);
expected result should be only two item whose state is Connecticut, California because their score are 100
Try this one
$command = new MongoDB\Driver\Command([
'aggregate' => 'collection',
'pipeline' => [
['$unwind' => '$records'],
['$match' => ['records.score' => '100']],
['$sort' => ['records.date' => 1]],
['$limit' => 6]
],
'cursor' => new stdClass,
]);
$cursor = $mng->executeCommand('database', $command);

PayPal REST completePurchase fee information

How can I get the fees from PayPal?
When I complete the purchase I can do $data = $response->getData(), and I get this information:
Array (
[id] => PAYID-LYUDPFA8E292123AP955374L
[intent] => sale
[state] => approved
[cart] => 3CN05415NR550735F
[payer] => Array (
[payment_method] => paypal
[status] => VERIFIED
[payer_info] => Array (
[email] => accounting-buyer#mobipium.com
[first_name] => test
[last_name] => buyer
[payer_id] => GTHZDZWYCELWU
[shipping_address] => Array (
[recipient_name] => test buyer
[line1] => 1 Main St
[city] => San Jose
[state] => CA
[postal_code] => 95131
[country_code] => US
)
[country_code] => US
)
)
[transactions] => Array (
[0] => Array (
[amount] => Array (
[total] => 1500.00
[currency] => EUR
[details] => Array (
[subtotal] => 1500.00
[shipping] => 0.00
[insurance] => 0.00
[handling_fee] => 0.00
[shipping_discount] => 0.00
)
)
[payee] => Array (
[merchant_id] => PCQDHVBJUD4WN
[email] => accounting-facilitator#mobipium.com
)
[description] => 5e2837933fdc3
[invoice_number] => 5e2837933fdc3
[item_list] => Array (
[shipping_address] => Array (
[recipient_name] => test buyer
[line1] => 1 Main St
[city] => San Jose
[state] => CA
[postal_code] => 95131
[country_code] => US
)
)
[related_resources] => Array (
[0] => Array (
[sale] => Array (
[id] => 9XL29023PP3022045
[state] => pending
[amount] => Array (
[total] => 1500.00
[currency] => EUR
[details] => Array (
[subtotal] => 1500.00
[shipping] => 0.00
[insurance] => 0.00
[handling_fee] => 0.00
[shipping_discount] => 0.00
)
)
[payment_mode] => INSTANT_TRANSFER
[reason_code] => RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION
[protection_eligibility] => ELIGIBLE
[protection_eligibility_type] => ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE
[receivable_amount] => Array (
[value] => 1500.00
[currency] => EUR
)
[exchange_rate] => 0.8627555079
[parent_payment] => PAYID-LYUDPFA8E292123AP955374L
[create_time] => 2020-01-22T11:53:12Z
[update_time] => 2020-01-22T11:53:12Z
[links] => Array (
[0] => Array (
[href] => https://api.sandbox.paypal.com/v1/payments/sale/9XL29023PP3022045
[rel] => self
[method] => GET
)
[1] => Array (
[href] => https://api.sandbox.paypal.com/v1/payments/sale/9XL29023PP3022045/refund
[rel] => refund
[method] => POST
)
[2] => Array (
[href] => https://api.sandbox.paypal.com/v1/payments/payment/PAYID-LYUDPFA8E292123AP955374L
[rel] => parent_payment
[method] => GET
)
)
)
)
)
)
)
[create_time] => 2020-01-22T11:52:52Z
[update_time] => 2020-01-22T11:53:12Z
[links] => Array (
[0] => Array (
[href] => https://api.sandbox.paypal.com/v1/payments/payment/PAYID-LYUDPFA8E292123AP955374L
[rel] => self
[method] => GET
)
)
)
I only can see the handling_fee field but when i access my facilitator account
https://gyazo.com/fc55e97066ee755efee7867a3c42e913
I can see the estimated field, how can i get this field?
I already do a integration with paypal and I can get that field from
$response['data']['transactions'][0]['related_resources'][0]['sale']['transaction_fee']['value'];
But this field sale doesn't have the transaction_fee field.
Payments in state=>approved must be executed in order to be in state=> completed.
Once a payment is completed or at least pending, its sale object , available at https://api.sandbox.paypal.com/v1/payments/sale/9XL29023PP3022045 in your example , should have details on financials. This is the identifier that has actual accounting value, and which will be persisted for years in the paypal.com account.
The payment object, id PAYID-LYUDPFA8E292123AP955374L in your example, is only used during the payment approval and execution process. It only needs to be kept around ~1 month for debug purposes, as it has no accounting value and will not be referenceable in paypal.com

ERROR: The total invoiced amount for xxxxxx#gmail.com does not match the amount in the pay for delayed chain payment

Error:
The total invoiced amount for xxxxxx#gmail.com does not match the amount in the pay for delayed chain payment.
I am not getting correct response for setPaymentOptions as here I am passing equal amount for both payrequst and invoice data but unable to compare their price. Is this because of currency code as here we pass currency code for payRequest receiver and for invoice data? We don't have any parameter as such for passing currency code. Can anyone help me out for this please?
PayPal\Types\AP\SetPaymentOptionsResponse Object
(
[responseEnvelope] => PayPal\Types\Common\ResponseEnvelope Object
(
[timestamp] => 2016-08-25T00:11:21.138-07:00
[ack] => Failure
[correlationId] => 8cc5bbe5cde59
[build] => 24003818
)
[error] => Array
(
[0] => PayPal\Types\Common\ErrorData Object
(
[errorId] => 580023
[domain] => PLATFORM
[subdomain] => Application
[severity] => Error
[category] => Application
[message] => The total invoiced amount for xxxxxx#gmail.com does not match the amount in the pay request
[exceptionId] =>
[parameter] => Array
(
[0] => PayPal\Types\Common\ErrorParameter Object
(
[name] =>
[value] => invoiceData
)
[1] => PayPal\Types\Common\ErrorParameter Object
(
[name] =>
[value] => xxxxxx#gmail.com
)
)
)
)
)
Parameters I am passing for PayRequest and InvoiceDatas:
PayPal\Types\AP\PayRequest Object
(
[requestEnvelope] => PayPal\Types\Common\RequestEnvelope Object
(
[detailLevel] =>
[errorLanguage] => en_US
)
[clientDetails] =>
[actionType] => PAY_PRIMARY
[cancelUrl] => http://localhost.xyz.com/paymentError?cancel=true
[currencyCode] => USD
[feesPayer] =>
[ipnNotificationUrl] => http://replaceIpnUrl.com
[memo] =>
[pin] =>
[preapprovalKey] =>
[receiverList] => PayPal\Types\AP\ReceiverList Object
(
[receiver] => Array
(
[0] => PayPal\Types\AP\Receiver Object
(
[amount] => 2.00
[email] => ABC-facilitator#gmail.com
[phone] =>
[primary] => false
[invoiceId] =>
[paymentType] =>
[paymentSubType] =>
[accountId] =>
)
[1] => PayPal\Types\AP\Receiver Object
(
[amount] => 8.00
[email] => xxxxxxx#gmail.com
[phone] =>
[primary] => true
[invoiceId] =>
[paymentType] =>
[paymentSubType] =>
[accountId] =>
)
)
)
[reverseAllParallelPaymentsOnError] =>
[senderEmail] =>
[returnUrl] => http://localhost.xyz.com/expressCallback
[trackingId] =>
[fundingConstraint] =>
[sender] =>
[payKeyDuration] =>
)
PayPal\Types\AP\ReceiverOptions Object
(
[description] =>
[customId] =>
[invoiceData] => PayPal\Types\AP\InvoiceData Object
(
[item] => Array
(
[0] => PayPal\Types\AP\InvoiceItem Object
(
[name] => Brand
[identifier] => 1
[price] => 8.00
[itemPrice] => 8.00
[itemCount] => 32
)
)
[totalTax] => 2
[totalShipping] => 27
)
[receiver] => PayPal\Types\AP\ReceiverIdentifier Object
(
[email] => xxxxxx#gmail.com
[phone] =>
[accountId] =>
)
[referrerCode] =>
)
Here 2 things are to be corrected related to price/amount to get rid of the error.
1: In the InvoiceItem object
[name] => Brand
[identifier] => 1
[price] => 256 //THIS IS EQUAL TO itemPrice * itemCount
[itemPrice] => 8.00
[itemCount] => 32
enter code here
2: In the Reciever object
xxxxxxx#gmail.com being the primary receiver should always have the amount equal to the total order amount (item + tax + discount + shipping), irrespective of if the secondary receiver is available or not. So it should be corrected to:
[amount] => 285.00 //256 + 2 + 27
[email] => xxxxxxx#gmail.com
[phone] =>
[primary] => true
[invoiceId] =>
[paymentType] =>
[paymentSubType] =>
[accountId] =>
And this Receiver object of secondary receiver specifies that out of total 285.00, 2.00 will be credited to the secondary receiver:
[amount] => 2.00 //2.00 will be credited to ABC out of 285.00
[email] => ABC-facilitator#gmail.com
[phone] =>
[primary] => false
[invoiceId] =>
[paymentType] =>
[paymentSubType] =>
[accountId] =>
Correct these and do let me know if you are still facing issue with amount mismatch.

woocommerce rest api v1 date filters

I am using WooCommerce rest api v1 in which I am trying to fetch all customers created in the month of June 2016. Here is the code I am using :-
$customers = $woocommerce->get('customers', array( 'filter[date_created_min]' => '2016-06-01', 'filter[date_created_max]' => '2016-06-30' ) ) ;
Unfortunately it is returning all the records and is ignoring the filter. Below is example of 1 of the record it has returned in the array :-
Array
(
[id] => 3
[date_created] => 2016-08-08T15:26:49
[date_modified] => 2016-08-10T22:17:44
[email] => manager#manager.com
[first_name] => Shop
[last_name] => Manager
[username] => Manager
[last_order] => Array
(
[id] =>
[date] =>
)
[orders_count] => 0
[total_spent] => 0.00
[avatar_url] => http://2.gravatar.com/avatar/?s=96
[billing] => Array
(
[first_name] => shop
[last_name] => manager
[company] => test company 1
[address_1] => test
[address_2] =>
[city] => test
[state] => PB
[postcode] => 1111
[country] => test
[email] => shop#manager.com
[phone] => 123456
)
[shipping] => Array
(
[first_name] => shop
[last_name] => manager
[company] => test company 1
[address_1] => test
[address_2] =>
[city] => test
[state] => PB
[postcode] => 11111
[country] => test
)
Please help me know the correct date filter. I have already tried the 'created_at_min' / 'created_at_max' but it is not working. Thanks in advance!