ruby-on-rails - 如何解决因不正确的Iban或Bic导致的Mangopay错误

标签 ruby-on-rails error-handling payment mangopay

嗨,我在Rails应用程序上安装了Mangopay付款解决方案。
即使我在用正则表达式更新其个人资料时检查了用户的Iban和Bic,有时我将数据发送到Mangopay时也会收到错误消息(我猜是因为即使iban和bic格式正确,mangopay还是发现他们没有实际存在):
“一个或几个必需的参数丢失或不正确。错误的资源ID也会引发这种错误。IBAN:IBAN或BIC无效”

我将这些信息发送到Mangopay的代码如下:

  def create_mangopay_bank_account
    bank_account = MangoPay::BankAccount.create(current_user.mangopay_natural_user_id, mangopay_user_bank_attributes)
    current_user.bank_account_id = bank_account["Id"]
    current_user.save
  end

如何解决此错误?我尝试了类似的东西:
 def create_mangopay_bank_account
    if MangoPay::BankAccount.create(current_user.mangopay_natural_user_id, mangopay_user_bank_attributes)
      bank_account = MangoPay::BankAccount.create(current_user.mangopay_natural_user_id, mangopay_user_bank_attributes)
      current_user.bank_account_id = bank_account["Id"]
      current_user.save
    else
      redirect_to user_path
  end

但这不起作用...

最佳答案

找到了解决方案:

 def create_mangopay_bank_account

      bank_account = MangoPay::BankAccount.create(current_user.mangopay_natural_user_id, mangopay_user_bank_attributes)
      current_user.bank_account_id = bank_account["Id"]
      current_user.save
      rescue MangoPay::ResponseError => e
        redirect_to root_path
        flash[:alert] = "L'Iban ou le Bic que vous avez fourni n'est pas valide. Veuillez vérifier les informations fournies. Si le problème persiste n'hésitez pas à contacter l'équipe TennisMatch."

   end

call 救援可以处理来自mangopay的错误

关于ruby-on-rails - 如何解决因不正确的Iban或Bic导致的Mangopay错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30535543/

相关文章:

ruby-on-rails - 为 nil :NilClass using nested_form_for 获取未定义的方法 `values_at'

powershell - 如何处理PowerShell中的Azure存储TableOperation错误?

php - 使用prestashop在mysql中显示订单摘要的引用

ruby-on-rails - rails : similar classes

ruby-on-rails - 在 Hotwire/Rails 应用程序中,如何强制表单助手仅接受文本/html?

exception - 类的成员函数之间的异常处理

node.js - 在Node.js上响应客户端的正确方法?

payment - 我如何处理定期计费?

php - Paypal 个人对个人支付与 PHP 集成

ruby-on-rails - 为自定义操作定义 Controller 似乎不起作用 Rails Admin