mage2pro / core Goto Github PK
View Code? Open in Web Editor NEWMage2.PRO core package
Home Page: https://upwork.com/fl/mage2pro
License: MIT License
Mage2.PRO core package
Home Page: https://upwork.com/fl/mage2pro
License: MIT License
Hi,
I'm currently testing the stripe payment extension and it depends on the core extension.
We are heavily using the rest api and since installing the module (by composer), a new attribute called "df" is needed to be set. This attribute is added in /vendor/mage2pro/core/Customer/Setup/UpgradeSchema.php
And yes, it's not required per definition/configuration, but on fetching a customer by the call
GET index.php/rest/all/V1/customers/<id>
then the custom_attributes of the response having an item with value=NULL, attribute_code="df".
So, on saving the same data by calling
PUT index.php/rest/all/V1/customers/<id>
an exception is thrown:
Error occurred during \"custom_attributes\" processing. Value is not set for attribute code \"df\"
So this breaks at this point. The normal behavior is: If a custom_attribute is not set, this will not be shown in the custom_attributes.
As a workaround it is possible to delete the item or set the value to an empty string, but it's a workaround and not the default behavior.
Response of the GET call formatted as array and returned with var_dump:
array(14) { ["id"]=> int(2) ["group_id"]=> int(1) ["created_at"]=> string(19) "2017-05-09 23:25:16" ["updated_at"]=> string(19) "2017-06-16 19:16:18" ["created_in"]=> string(11) "Österreich" ["email"]=> string(22) "[email protected]" ["firstname"]=> string(4) "Kumm" ["lastname"]=> string(4) "Scho" ["middlename"]=> string(4) "Paul" ["store_id"]=> int(1) ["website_id"]=> int(1) ["addresses"]=> array(0) { } ["disable_auto_group_change"]=> int(0) ["custom_attributes"]=> array(1) { [0]=> array(2) { ["attribute_code"]=> string(2) "df" ["value"]=> NULL } } }
To get this tailored:
On calling the PUT and removing the item with attribute_code="df" the next GET will return custom_attributes containing the previous deleted item again. This is added somewhere on the fly you will better know as I do.
My test is using guzzlehttp/guzzle and zendframework/zend-json as composer dependency. The custom_attribute "fundi_id" is use to see the normal behavior, this is the corresponding id of the erp system of my customer:
<?php include 'vendor/autoload.php'; $baseProtocolAndDomain = "http://example.com/"; $baseUrl = "index.php/rest/all/V1/"; $baseUrl = $baseProtocolAndDomain . $baseUrl; $client = new GuzzleHttp\Client(); $token = NULL; if (! $token) { $response = $client->post($baseUrl . 'integration/admin/token/', [ "json" => [ "username" => "username", "password" => "password" ] ]); $token = Zend\Json\Json::decode($response->getBody()); } $params['headers']["Authorization"] = 'Bearer' . ' ' . $token; $response = $client->get($baseUrl . 'customers/2', $params); // this response does have the attribute set var_dump(Zend\Json\Json::decode($response->getBody())); $customer = Zend\Json\Json::decode($response->getBody(), Zend\Json\Json::TYPE_ARRAY); $fundiIdSet = FALSE; foreach($customer['custom_attributes'] as $id => $att) { if ($att['attribute_code'] == 'df' && $att['value'] === NULL) { // works, that's the current workaround unset($customer['custom_attributes'][$id]); // would also work: //$att['value'] = ''; } if ($att['attribute_code'] == 'fundi_id') { $fundiIdSet = TRUE; } } if (! $fundiIdSet) { $customer['custom_attributes'][] = ["attribute_code" => 'fundi_id', "value" => 'test123']; } $customer["middlename"] = 'Paul'; $params['json'] = ['customer' => $customer]; $response = $client->put($baseUrl . 'customers/2', $params); // this response does not have the custom attribute set var_dump(Zend\Json\Json::decode($response->getBody())); $response = $client->get($baseUrl . 'customers/2', $params); // and this response does have the custom attribute set again var_dump(Zend\Json\Json::decode($response->getBody()));
Greetings from Berlin to Moscow!
Alex
Nobody of my clients has reported it, but I noticed a similar issue here: Inchoo/magento2-Inchoo_Stripe#15 (comment)
I need it for mage2pro/alphacommercehub#29 (Update the current order in Magento on a SuccessURL
/ CancelURL
customer return).
6011111111111117
and 6011000990139424
are the official Stripe test bank cards of the Discover brand: https://stripe.com/docs/testing#cards
The 6011000990139424
card is correctly detected as a Discover's one:
The 6011111111111117
card is not correctly detected as a Discover's one:
Currently, it works as a workaround for the particular mage2pro/moip
module:
https://github.com/mage2pro/core/blob/3.2.30/Checkout/view/frontend/web/payment.js#L65-L73
I need to do something with it.
I need to investigate it.
I have the following code there:
if (@class_exists('\PHPUnit\Framework\TestCase')) {
/** @noinspection PhpMultipleClassesDeclarationsInOneFile */
abstract class TestCaseBase extends \PHPUnit\Framework\TestCase {}
}
else {
/** @noinspection PhpMultipleClassesDeclarationsInOneFile */
abstract class TestCaseBase extends \PHPUnit_Framework_TestCase {
https://github.com/mage2pro/core/blob/2.12.21/Core/TestCaseBase.php#L10-L16
Check in Magento 2.0.2.
https://mage2.pro/t/4957
The problem line is: https://github.com/mage2pro/core/blob/3.3.11/Intl/view/base/web/main.js#L4
The Magento_Ui/js/lib/knockout/template/renderer
script is absent in Magento 2.0.x: https://github.com/magento/magento2/blob/2.0.16/app/code/Magento/Ui/view/base/web/js/lib/knockout/template/renderer.js
It was introduced in Magento 2.1.0:
https://github.com/magento/magento2/blob/2.1.0/app/code/Magento/Ui/view/base/web/js/lib/knockout/template/renderer.js
This script has a different name in Magento 2.0.x: Magento_Ui/js/lib/ko/template/renderer:
The character set that is used does not allow for diacritics. In brief, it only allows uppercase ASCII characters.
The restriction ultimately comes from the historical way in which banking cards encode data onto the magnetic stripe (as defined in ISO 7811). The data is encoded in a 7 bits per character format known as ITU-T.50
The cardholder name is encoded with up to 26 characters, each within the range from hex 20-5F. You can see the table for this here: http://www.zytrax.com/tech/ia5.html
https://stackoverflow.com/a/2005287
I have a similar issue in 6.5 years ago: https://magento-forum.ru/topic/499/#entry3082
Now I render the first options column, then the second column.
I should render the options by rows: first row, second row, etc.
So the priority payment options will be shown topmost, not leftmost.
https://github.com/mage2pro/core/blob/2.12.17/Payment/view/frontend/web/template/withOptions/list.html
Methods declared without any explicit visibility keyword are defined as public.
http://php.net/manual/en/language.oop5.visibility.php#language.oop5.visiblity-methods
No, properties order in objects is not guaranteed in JavaScript.
Definition of an Object from ECMAScript Third Edition (pdf):
4.3.3 Object
An object is a member of the type Object. It is an unordered collection of properties each of which contains a primitive value, object, or function. A function stored in a property of an object is called a method.
https://stackoverflow.com/a/5525820
https://github.com/mage2pro/core/blob/3.2.21/Payment/ConfigProvider.php#L193-L222
I have the following code there:
catch (\Exception $e) {df_log($e); throw df_le($e);}
https://github.com/mage2pro/core/blob/2.12.20/Config/Backend.php#L64
df_le
is not a class, it is a function:
function df_le(E $e) {return $e instanceof LE ? $e : new LE(__(df_ets($e)), $e);}
https://github.com/mage2pro/core/blob/2.12.20/Qa/lib/exception.php#L53-L58
*****************2******************
Caller: mb_strlen
Callee: Df\Sentry\Breadcrumbs\ErrorHandler::handleError
*****************3******************
File: vendor/mage2pro/core/Core/lib/text.php
Line: 173
Caller: df_chop
Callee: mb_strlen
Context:
function df_chop($s, $max = null) {return !$max || (mb_strlen($s = df_trim($s)) <= $max) ? $s :
df_trim_right(mb_substr($s, 0, $max - 1)) . '…'
;}
*****************4******************
File: vendor/mage2pro/core/Payment/Charge.php
Line: 90
Caller: Df\Payment\Charge::text
Callee: df_chop
Context:
final protected function text($s, $max = null) {return df_chop(df_var($s, $this->vars()), $max);}
*****************5******************
File: vendor/mage2pro/alphacommercehub/Charge.php
Line: 249
Caller: Dfe\AlphaCommerceHub\Charge::pCharge
Callee: Df\Payment\Charge::text
Context:
*/
,'OrderDetails' => $this->pOrderItems()
// 2017-11-01 «A social or tax id for the customer». String(20), optional.
,'SocialID' => $this->customerVAT()
// 2017-11-02 «The State/Province element of the customers shipping address». String(50), optional.
,'State' => $this->text($s->dsd(), 50)
// 2017-11-01 «The first line of the customers street address». String(100), optional.
,'Street1' => $this->text($sa->getStreet(1), 100)
// 2017-11-01 «The second line of the customers street address». String(100), optional.
,'Street2' => $this->text($sa->getStreet(2), 100)
/**
* 2017-11-02
* Note 1.
* «Allows the merchant to define a different URL the response should be sent to
* from the default configured URL, for example for mobile support».
* String, optional.
*****************6******************
File: vendor/mage2pro/core/PaypalClone/Charge.php
Line: 235
Caller: Df\PaypalClone\Charge::p
Callee: Dfe\AlphaCommerceHub\Charge::pCharge
Context:
$s = $i->s(); /** @var Settings $s */
$p = df_clean_keys([
$i->k_Amount() => $s->test() ? $i->testAmountF() : $i->amountF()
,$i->k_Currency() => $i->currencyC()
,$i->k_Email() => $i->customerEmail()
,$i->k_MerchantId() => $s->merchantID()
,$i->k_RequestId() => $id
]) + $i->pCharge(); /** @var array(string => mixed) $p */
/**
* 2017-09-25
* The Yandex.Kassa charge requests do not use a signature:
* @see \Dfe\YandexKassa\Charge::k_Signature()
* https://tech.yandex.com/money/doc/payment-solution/payment-form/payment-form-http-docpage
*/
return [$id, $p + ((!$kS = $i->k_Signature()) ? [] : [$kS => Signer::signRequest($i, $p)])];
}
*****************7******************
File: vendor/mage2pro/core/PaypalClone/Init/Action.php
Line: 46
Caller: Df\PaypalClone\Init\Action::Df\PaypalClone\Init\{closure}
Callee: Df\PaypalClone\Charge::p
Context:
/**
* 2017-03-21
* @used-by redirectParams()
* @used-by transId()
* @return array(string, array(string => mixed))
*/
private function charge() {return dfc($this, function() {return Charge::p($this->m());});}
}
*****************8******************
File: vendor/mage2pro/core/Core/lib/cache.php
Line: 211
Caller: dfc
Callee: Df\PaypalClone\Init\Action::Df\PaypalClone\Init\{closure}
Context:
/** @var string $k */
$k = $b['class'] . '::' . $b['function']
. (!$a ? null : dfa_hash($a))
. ($unique ? null : spl_object_hash($m))
;
// 2017-01-12
// https://3v4l.org/0shto
return property_exists($o, $k) ? $o->$k : $o->$k = $m(...$a);
}
*****************9******************
File: vendor/mage2pro/core/PaypalClone/Init/Action.php
Line: 46
Caller: Df\PaypalClone\Init\Action::charge
Callee: dfc
Context:
private function charge() {return dfc($this, function() {return Charge::p($this->m());});}
*****************10*****************
File: vendor/mage2pro/core/PaypalClone/Init/Action.php
Line: 28
Caller: Df\PaypalClone\Init\Action::redirectParams
Callee: Df\PaypalClone\Init\Action::charge
Context:
final protected function redirectParams() {return df_last($this->charge());}
*****************11*****************
File: vendor/mage2pro/core/Payment/Init/Action.php
Line: 26
Caller: Df\Payment\Init\Action::Df\Payment\Init\{closure}
Callee: Df\PaypalClone\Init\Action::redirectParams
Context:
* 2017-03-21
* @used-by \Df\Payment\Method::getConfigPaymentAction()
* @return string|null
*/
final function action() {return $this->_m->action(function() {
$m = $this->_m; /** @var M $m */
$this->preorder();
$p = $this->redirectParams(); /** @var array(string => mixed) $p */
if ($url = dfp_url_api($m, $this->redirectUrl())) { /** @var string|null $url */
PO::setRedirectData($m, $url, $p, $this->forceGet());
// 2016-12-20
if ($this->s()->log()) {
dfp_report($m, ['Redirect Params' => $p, 'Redirect URL' => $url], 'request');
}
// 2016-05-06
// Postpone sending an order confirmation email to the customer,
*****************12*****************
Caller: call_user_func
Callee: Df\Payment\Init\Action::Df\Payment\Init\{closure}
*****************13*****************
File: vendor/mage2pro/core/Payment/Method.php
Line: 141
Caller: Df\Payment\Method::action
Callee: call_user_func
Context:
if (!$this->ii(self::WEBHOOK_CASE)) {
dfp_sentry_tags($this);
/** @var string $actionS */
df_sentry_tags($this, ['Payment Action' => $actionS = df_caller_f()]);
try {
$this->s()->init();
// 2017-01-10 Такой код корректен, проверял: https://3v4l.org/Efj63
$result = call_user_func($f instanceof \Closure ? $f : [$this, $f]);
/**
* 2017-01-31
* В настоящее время опция «Log the API requests and responses?»
* присутствует у модулей allPay и SecurePay:
* 1) allPay: https://github.com/mage2pro/allpay/blob/1.1.25/etc/adminhtml/system.xml?ts=4#L413-L426
* 2) SecurePay: https://github.com/mage2pro/securepay/blob/1.1.17/etc/adminhtml/system.xml?ts=4#L156-L169
* У остальных моих платёжных модулей этой опции пока нет,
* там функциональность логирования пока включена намертво.
*****************14*****************
File: vendor/mage2pro/core/Payment/Init/Action.php
Line: 80
Caller: Df\Payment\Init\Action::action
Callee: Df\Payment\Method::action
Context:
* это единственный транзакция без специального назначения,
* и поэтому мы можем безопасно его использовать
* для сохранения информации о нашем запросе к платёжной системе.
*/
$m->ii()->addTransaction(T::TYPE_PAYMENT);
}
return $url || $id ? null : $this->preconfigured();
}, false);}
*****************15*****************
File: vendor/mage2pro/core/Payment/Method.php
Line: 939
Caller: Df\Payment\Method::getConfigPaymentAction
Callee: Df\Payment\Init\Action::action
Context:
function getConfigPaymentAction() {return InitAction::singleton($this)->action();}
Similar to #15
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.