From 789cac11b7a239aa506b400f64750da77c94fcda Mon Sep 17 00:00:00 2001 From: Ram Prakash Singh <45222925+ramth05@users.noreply.github.com> Date: Tue, 8 Sep 2020 13:26:08 +0530 Subject: [PATCH] added optinal fields check (#198) --- Controller/Payment/Order.php | 31 +++++++------------------------ composer.json | 2 +- etc/module.xml | 2 +- 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/Controller/Payment/Order.php b/Controller/Payment/Order.php index c6629c8a..d19ac624 100644 --- a/Controller/Payment/Order.php +++ b/Controller/Payment/Order.php @@ -172,31 +172,14 @@ public function execute() { $billing_address = json_decode($_POST['billing_address'], 1); - $this->getQuote()->getBillingAddress() - ->setFirstname($billing_address['firstname']) - ->setLastname($billing_address['lastname']) - ->setCountryId($billing_address['countryId']) - ->setPostcode($billing_address['postcode']) - ->setCity($billing_address['city']) - ->setTelephone($billing_address['telephone']) - ->setStreet($billing_address['street']) - ->setRegionId($billing_address['regionId']) - ->setRegionCode($billing_address['regionCode']) - ->setRegion($billing_address['region']) - ->setSaveInAddressBook($billing_address['saveInAddressBook']); - - if(isset($billing_address['company']) and - (empty($billing_address['company']) === false)) + foreach ($billing_address as $field => $field_value) { - $this->getQuote()->getBillingAddress() - ->setCompany($billing_address['company']); - } - - if(isset($billing_address['middlename']) and - (empty($billing_address['middlename']) === false)) - { - $this->getQuote()->getBillingAddress() - ->setCompany($billing_address['middlename']); + if(isset($billing_address[$field]) and + (empty($billing_address[$field]) === false)) + { + $set_field = "set".ucfirst($field); + $this->getQuote()->getBillingAddress()->$set_field($field_value); + } } $this->getQuote()->save(); diff --git a/composer.json b/composer.json index 54023de2..067f7a58 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "razorpay/magento", "description": "Razorpay Magento 2.0 plugin for accepting payments.", - "version": "3.1.2", + "version": "3.1.3", "require": { "php": "~5.5.0|~5.6.0|^7.0", "razorpay/razorpay": "2.*" diff --git a/etc/module.xml b/etc/module.xml index e8d4ecd4..bb2145bb 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - +