Giter VIP home page Giter VIP logo

core's People

Contributors

aaronsilber avatar dmitrii-fediuk avatar jaivikpatel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

core's Issues

A consecutive call of the «GET» and «PUT» REST API methods for the same customer leads to the «Error occurred during "custom_attributes" processing. Value is not set for attribute code "df"» failure

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

Magento 2.0.x: «Script error for: Magento_Ui/js/lib/knockout/template/renderer»

The ineligible characters should be automatically replaced by the corresponding eligible ones while prefilling the cardholder's name (if «Prefill the cardholder's name from the billing address?» option is enabled)

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

JavaScript does not guarantee the properties order in objects, so \Df\Payment\ConfigProvider::configOptions() should specify the payment options orderings exactly in a separate property, or pass the options to the client side as an array instead of an object

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

«Warning: mb_strlen() expects parameter 1 to be string, array given in vendor/mage2pro/core/Core/lib/text.php on line 173»

02

*****************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();}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.