Closed hardevine closed 5 years ago
I think you can change the merchant credentials on the fly using Config Facade.
I would just do this before returning Payment::process($orderData)
\Config::set('payment.ccavenue.merchantId','CURRENT_MERCHANT_ID');
This will change the merchant id only for that instance like this you can switch between all other merchant details.
I think this should do the trick... let me know. 👍
how about
class CCAvenueCompany1 extends CCAvenueGateway implements PaymentGatewayInterface
{
public function __construct() {
$this->workingKey = Config::get('payment.ccavenue.company1.workingKey');
$this->accessCode = Config::get('payment.ccavenue.company1.accessCode');
// and so on
}
}
then in controller
$gw = new Payment(new CCAvenueCompany1());
// now you're good to go
$gw->prepare($parameters);
Did u try what i suggested ? Why is that not good. Laravel by itself provides a easy way to change the configuration on the runtime depending on certain requirement. Not using that would defy its purpose altogether.
And what you are suggesting doesn't look right CCAvenue is the payment gateway i don't see the logic behind initialising multiple instances while u can just change the configuration and deal with it.
needed a way to keep it at one place and also little code to get the instance, but as you have pointed its essentially change of configs not a different gateway, will be trying with config, yeah it worked with config, though.
Closing this as this question was answered with a working solution. Thanks.
we have multiple merchants accounts on single site, how can i make separate instance with different merchants id,credentials etc. ?