Skip to content

Commit

Permalink
added optinal fields check (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramth05 authored Sep 8, 2020
1 parent 63ce9ba commit 789cac1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 26 deletions.
31 changes: 7 additions & 24 deletions Controller/Payment/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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.*"
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Razorpay_Magento" setup_version="3.1.2">
<module name="Razorpay_Magento" setup_version="3.1.3">
<sequence>
<module name="Magento_Sales" />
<module name="Magento_Payment" />
Expand Down

0 comments on commit 789cac1

Please sign in to comment.