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

Fix BankFactory().auto_create() error. #57

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

Saman-Zand-H
Copy link
Contributor

I was trying to use auto_create() with zibal, using sample-payment, when i noticed it raises an exception, which then took me to check_gateway(), which then again took me to _get_gateway_callback_url(). After plyaing a little with it, i realized it isn't sending the absolute url as callbackUrl to the bank, which then in return raises an error. So, in order to have the absolute url we're gonna need to have the request while creating the bank.

@ali-zahedi
Copy link
Owner

@Saman-Zand-H
سلام سامان عزیز.

ممنون از گزارش و اینکه مورد رو پیگیری کردی و پریدی توی عمقش.

۱- الان تا جایی که من متوجه شدم مشکل اینه که اگر فقط به زیبال یو آر ال بازگشت رو به صورت کامل ندیم زیبال پرداخت رو رد می کنه. یا به عبارتی /call-back-url مورد قبولش نیست و باید حتما با فرمتی مثل https://example.com/call-back-url باشه. درسته؟ چطور بقیه بانک ها به یوآرال مورد نظر بر میگشتند؟

۲- این تغییرات اخیر اتفاق افتاده؟ چون قبلا بدون مشکل با زیبال کار میکرده و موردی ریپورت نشده بود تا جایی که خاطرم هست و زیبال رو حتی تا جایی که یادم هست خودم هم امتحان کردم.

۳- با فرض اینکه همه موارد بالا وارد باشه، اضافه کردن یه پارامتر به این متد ها به این صورت میتونه کسانی که دارن از این پکیج در حال حاضر استفاده میکنن رو کلا با دردسر روبرو کنه. و باید حتما یک سناریو دپریکیت متود براش نوشته بشه.

۴- بنظرم اگر بتونی از هنگام رفتن به بانک از متغیر های موجود دامپ بگیری برای مثلا زیبال و آی دی پی ( یا هر درگاه دیگه ای که بهش دسترسی داری) میتونه اطلاعات خوبی بهمون بده.( فرض بر اینه که اینجا از اتو کانکت استفاده نشده)

azbankgateways/views/banks.py - go_to_bank_gateway method - context variable

یا از داخل خود کلاس بانک مد نظر - قسمت متد ارسال داده.

پی نوشت: من بعد از پاسخت نیاز به کمی زمان دارم تا موارد بالا رو بررسی کنم.

@Saman-Zand-H
Copy link
Contributor Author

using a debugger, after using sample_payment_view with the initial values provided, namely
amount: 1000, mobile_number: '+989112223344'

we face a raised exception:
BankGatewayRejectPayment('callbackUrl is not valid'),

then following the relation:
auto_create() -> check_gateway(amount) -> _prepare_check_gateway(amount) -> set_client_callback(callback_url)
here we observe this:
callback_url="/" setting _client_callback_url=callback_url becuase at the end of _prepare_check_gateway, this is called self.set_client_callback_url("/"),

then going to pay() -> get_pay_data(), returns:
data={ "amount": 10000, "merchant": "zibal", "callbackUrl": "/bankgateways/callback/", "orderId": "<order id> },

then sending to the bank through _send_data returns json:
response={ "message": "callbackUrl is not valid", "result": 106 }

and then rejecting the payment totaly and raising the exception. This is the path leading to the exception. Notice that since I'm trying sample-payment, go_to_bank_gateway never gets hit. Also this is the case with trying to execute auto_create() in the shell.
The thing is, in _get_gateway_callback_url, the definition says if there's a request set beforehand, build_uri, else, just return the result of this reverse reverse(settings.CALLBACK_NAMESPACE), which then returns /bankgateways/callback/.
Thank you so much.

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.

None yet

2 participants