Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add config instance #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

daliuchen
Copy link

Hello! This is an excellent project which has greatly facilitated my development. However, in my business scenario, I need to use multiple configurations. Hence, this pull request.

config was a class-level variable, which caused only one instance of config to be used when using this gem package. However, In my business, I need to use multiple configurations. This code is no longer available.

Idea:
Change all previous module-level operations to class level and create a global client during initialization. Define the method signatures on the module as before and call using the global client. This makes it compatible with the previous code as much as possible. The downside is that previously at module level we had global variables, now they are defined within each
respective client

Here are explanations for the additional clients:
WechatPay::Config=>Replaces the previous WechatPay.app_id=xxx WechatPay::Client=>Replaces the previous WechatPayHelper and is mainly responsible for interacting with WeChat. WechatPay::Direct::Direct=>Replaces the previous WechatPay::Direct module WechatPay::Ecommerce::Ecommerce=>Replaces the previous WechatPay::Ecommerce module WechatPay::Sign=>Replaces previously Wechatpay::Sigɲ module

In the previous code, `config` was a class-level variable, which caused only one instance of `config` to be used
when using this gem package. However, In my business, I need to use multiple configurations. This code is no longer available.

 Idea:
Change all previous module-level operations to class level and create a global client during initialization.
Define the method signatures on the module as before and call using the global client.
This makes it compatible with the previous code as much as possible. The downside
is that previously at module level we had global variables, now they are defined within each
 respective client

Here are explanations for the additional clients:
WechatPay::Config=>Replaces the previous WechatPay.app_id=xxx
WechatPay::Client=>Replaces the previous WechatPayHelper and is mainly responsible for interacting with WeChat.
WechatPay::Direct::Direct=>Replaces the previous WechatPay::Direct module
WechatPay::Ecommerce::Ecommerce=>Replaces the previous WechatPay::Ecommerce module
WechatPay::Sign=>Replaces previously Wechatpay::Sigɲ module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant