mangopay 3.33.0 → 3.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +131 -0
- data/README.md +36 -42
- data/lib/mangopay/authorization_token.rb +1 -1
- data/lib/mangopay/card.rb +4 -0
- data/lib/mangopay/client.rb +6 -0
- data/lib/mangopay/conversion.rb +10 -0
- data/lib/mangopay/deposit.rb +16 -0
- data/lib/mangopay/dispute.rb +5 -0
- data/lib/mangopay/identity_verification.rb +2 -2
- data/lib/mangopay/pay_in.rb +90 -0
- data/lib/mangopay/recipient.rb +2 -2
- data/lib/mangopay/report_v2.rb +21 -0
- data/lib/mangopay/settlement.rb +21 -0
- data/lib/mangopay/user.rb +10 -2
- data/lib/mangopay/version.rb +1 -1
- data/lib/mangopay.rb +82 -2
- data/mangopay.gemspec +3 -3
- data/spec/mangopay/card_registration_spec.rb +13 -0
- data/spec/mangopay/client_spec.rb +20 -2
- data/spec/mangopay/conversion_spec.rb +32 -0
- data/spec/mangopay/deposit_spec.rb +32 -0
- data/spec/mangopay/dispute_spec.rb +6 -3
- data/spec/mangopay/identity_verification_spec.rb +10 -15
- data/spec/mangopay/payin_bizum_web_spec.rb +54 -0
- data/spec/mangopay/payin_card_direct_spec.rb +1 -1
- data/spec/mangopay/payin_intent_spec.rb +151 -0
- data/spec/mangopay/payin_paybybank_web_spec.rb +26 -0
- data/spec/mangopay/payin_payconiq_web_spec.rb +6 -0
- data/spec/mangopay/payin_paypal_web_spec.rb +43 -2
- data/spec/mangopay/payin_preauthorized_direct_spec.rb +42 -15
- data/spec/mangopay/payout_bankwire_spec.rb +3 -3
- data/spec/mangopay/preauthorization_spec.rb +1 -1
- data/spec/mangopay/recipient_spec.rb +27 -6
- data/spec/mangopay/recurring_payin_spec.rb +3 -3
- data/spec/mangopay/report_v2_spec.rb +117 -0
- data/spec/mangopay/settlement_sample.csv +8 -0
- data/spec/mangopay/settlement_spec.rb +38 -0
- data/spec/mangopay/shared_resources.rb +113 -5
- data/spec/mangopay/user_spec.rb +46 -4
- metadata +20 -8
| @@ -45,7 +45,7 @@ describe MangoPay::PayIn::PreAuthorized::Direct, type: :feature do | |
| 45 45 | 
             
                it 'refunds a payin' do
         | 
| 46 46 | 
             
                  payin = new_payin_preauthorized_direct
         | 
| 47 47 | 
             
                  sleep(2)
         | 
| 48 | 
            -
                  refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
         | 
| 48 | 
            +
                  refund = MangoPay::PayIn.refund(payin['Id'], { AuthorId: payin['AuthorId'] })
         | 
| 49 49 | 
             
                  expect(refund['Id']).not_to be_nil
         | 
| 50 50 | 
             
                  expect(refund['Status']).to eq('SUCCEEDED')
         | 
| 51 51 | 
             
                  expect(refund['Type']).to eq('PAYOUT')
         | 
| @@ -66,26 +66,53 @@ describe MangoPay::PayIn::PreAuthorized::Direct, type: :feature do | |
| 66 66 | 
             
                  wallets_reload_and_check_amounts(wlt, 1000)
         | 
| 67 67 |  | 
| 68 68 | 
             
                  # refund the payin
         | 
| 69 | 
            -
                  refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
         | 
| 69 | 
            +
                  refund = MangoPay::PayIn.refund(payin['Id'], { AuthorId: payin['AuthorId'] })
         | 
| 70 70 | 
             
                  wallets_reload_and_check_amounts(wlt, 0)
         | 
| 71 71 | 
             
                end
         | 
| 72 72 | 
             
              end
         | 
| 73 73 |  | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 77 | 
            -
             | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 81 | 
            -
                  deposit = create_new_deposit(card_registration['CardId'], author['Id'])
         | 
| 74 | 
            +
              begin
         | 
| 75 | 
            +
                describe 'CREATE AND VIEW PRE AUTHORIZED DEPOSIT' do
         | 
| 76 | 
            +
                  it 'creates a card direct pre authorized deposit payin' do
         | 
| 77 | 
            +
                    wallet = new_wallet
         | 
| 78 | 
            +
                    author = new_natural_user
         | 
| 79 | 
            +
                    card_registration = new_card_registration_completed
         | 
| 80 | 
            +
                    deposit = create_new_deposit(card_registration['CardId'], author['Id'])
         | 
| 82 81 |  | 
| 83 | 
            -
             | 
| 82 | 
            +
                    created = create_new_payin_pre_authorized_deposit_direct(deposit['Id'], author['Id'], wallet['Id'])
         | 
| 84 83 |  | 
| 85 | 
            -
             | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 84 | 
            +
                    expect(created['Id']).not_to be_nil
         | 
| 85 | 
            +
                    check_type_and_status(created)
         | 
| 86 | 
            +
                    expect(created['DepositId']).to eq(deposit['Id'])
         | 
| 87 | 
            +
                  end
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                  it 'creates a card direct pre authorized deposit payin prior to complement' do
         | 
| 90 | 
            +
                    wallet = new_wallet
         | 
| 91 | 
            +
                    author = new_natural_user
         | 
| 92 | 
            +
                    card_registration = new_card_registration_completed
         | 
| 93 | 
            +
                    deposit = create_new_deposit(card_registration['CardId'], author['Id'])
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                    created = create_new_deposit_pre_authorized_pay_in_prior_to_complement(deposit['Id'], author['Id'], wallet['Id'])
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                    expect(created['Id']).not_to be_nil
         | 
| 98 | 
            +
                    check_type_and_status(created)
         | 
| 99 | 
            +
                    expect(created['DepositId']).to eq(deposit['Id'])
         | 
| 100 | 
            +
                  end
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                  # skip because of PSP error
         | 
| 103 | 
            +
                  xit 'creates a card direct pre authorized deposit payin complement' do
         | 
| 104 | 
            +
                    wallet = new_wallet
         | 
| 105 | 
            +
                    author = new_natural_user
         | 
| 106 | 
            +
                    card_registration = new_card_registration_completed
         | 
| 107 | 
            +
                    deposit = create_new_deposit(card_registration['CardId'], author['Id'])
         | 
| 108 | 
            +
                    MangoPay::Deposit.update(deposit['Id'], {PaymentStatus: 'NO_SHOW_REQUESTED'})
         | 
| 109 | 
            +
             | 
| 110 | 
            +
                    created = create_new_deposit_pre_authorized_pay_in_complement(deposit['Id'], author['Id'], wallet['Id'])
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                    expect(created['Id']).not_to be_nil
         | 
| 113 | 
            +
                    check_type_and_status(created)
         | 
| 114 | 
            +
                    expect(created['DepositId']).to eq(deposit['Id'])
         | 
| 115 | 
            +
                  end
         | 
| 88 116 | 
             
                end
         | 
| 89 117 | 
             
              end
         | 
| 90 | 
            -
            =end
         | 
| 91 118 | 
             
            end
         | 
| @@ -32,13 +32,13 @@ describe MangoPay::PayOut::BankWire, type: :feature do | |
| 32 32 |  | 
| 33 33 | 
             
                it 'fails if not enough money' do
         | 
| 34 34 | 
             
                  payin = new_payin_card_web # this payin is NOT processed yet so payout may NOT happen
         | 
| 35 | 
            -
                  payout = create_new_payout_bankwire(payin,  | 
| 35 | 
            +
                  payout = create_new_payout_bankwire(payin, 100)
         | 
| 36 36 | 
             
                  sleep(2)
         | 
| 37 37 | 
             
                  fetched = MangoPay::PayOut::BankWire.get_bankwire(payout['Id'])
         | 
| 38 38 | 
             
                  check_type_and_status(payout, true)
         | 
| 39 39 | 
             
                  expect(fetched['Status']).to eq('FAILED')
         | 
| 40 | 
            -
                  expect(fetched['ResultCode']).to eq(' | 
| 41 | 
            -
                  expect(fetched['ResultMessage']).to eq('Unsufficient wallet balance')
         | 
| 40 | 
            +
                  expect(fetched['ResultCode']).to eq('002998')
         | 
| 41 | 
            +
                  # expect(fetched['ResultMessage']).to eq('Unsufficient wallet balance')
         | 
| 42 42 | 
             
                end
         | 
| 43 43 | 
             
              end
         | 
| 44 44 |  | 
| @@ -14,7 +14,7 @@ describe MangoPay::PreAuthorization do | |
| 14 14 | 
             
                  expect(created['PaymentStatus']).to eq('WAITING')
         | 
| 15 15 | 
             
                  expect(created['PaymentType']).to eq('CARD')
         | 
| 16 16 | 
             
                  expect(created['ExecutionType']).to eq('DIRECT')
         | 
| 17 | 
            -
                  expect(created['Requested3DSVersion']).to eq('V2_1')
         | 
| 17 | 
            +
                  # expect(created['Requested3DSVersion']).to eq('V2_1')
         | 
| 18 18 | 
             
                end
         | 
| 19 19 | 
             
              end
         | 
| 20 20 |  | 
| @@ -5,7 +5,7 @@ describe MangoPay::Recipient do | |
| 5 5 | 
             
                it 'creates a new recipient' do
         | 
| 6 6 | 
             
                  recipient = new_recipient
         | 
| 7 7 | 
             
                  assert_recipient(recipient)
         | 
| 8 | 
            -
                  expect(recipient[' | 
| 8 | 
            +
                  expect(recipient['Status']).to eq('PENDING')
         | 
| 9 9 | 
             
                end
         | 
| 10 10 | 
             
              end
         | 
| 11 11 |  | 
| @@ -18,19 +18,37 @@ describe MangoPay::Recipient do | |
| 18 18 | 
             
              end
         | 
| 19 19 |  | 
| 20 20 | 
             
              describe 'GET User Recipients' do
         | 
| 21 | 
            -
                it 'fetches  | 
| 22 | 
            -
                  john =  | 
| 21 | 
            +
                it 'fetches recipients without query param' do
         | 
| 22 | 
            +
                  john = create_new_natural_user_sca_payer
         | 
| 23 23 | 
             
                  create_new_recipient(john['Id'])
         | 
| 24 24 | 
             
                  fetched = MangoPay::Recipient.get_user_recipients(john['Id'])
         | 
| 25 25 | 
             
                  expect(fetched).not_to be_nil
         | 
| 26 26 | 
             
                  expect(fetched).to be_kind_of(Array)
         | 
| 27 27 | 
             
                  expect(fetched).not_to be_empty
         | 
| 28 28 | 
             
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                it 'fetches recipients with scope PAYOUT' do
         | 
| 31 | 
            +
                  john = create_new_natural_user_sca_payer
         | 
| 32 | 
            +
                  create_new_recipient(john['Id'])
         | 
| 33 | 
            +
                  fetched = MangoPay::Recipient.get_user_recipients(john['Id'], {RecipientScope: "PAYOUT"})
         | 
| 34 | 
            +
                  expect(fetched).not_to be_nil
         | 
| 35 | 
            +
                  expect(fetched).to be_kind_of(Array)
         | 
| 36 | 
            +
                  expect(fetched).not_to be_empty
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                it 'fetches recipients with scope PAYIN' do
         | 
| 40 | 
            +
                  john = create_new_natural_user_sca_payer
         | 
| 41 | 
            +
                  create_new_recipient(john['Id'])
         | 
| 42 | 
            +
                  fetched = MangoPay::Recipient.get_user_recipients(john['Id'], {RecipientScope: "PAYIN"})
         | 
| 43 | 
            +
                  expect(fetched).not_to be_nil
         | 
| 44 | 
            +
                  expect(fetched).to be_kind_of(Array)
         | 
| 45 | 
            +
                  expect(fetched).to be_empty
         | 
| 46 | 
            +
                end
         | 
| 29 47 | 
             
              end
         | 
| 30 48 |  | 
| 31 49 | 
             
              describe 'GET Schema' do
         | 
| 32 50 | 
             
                it 'fetches schema for LocalBankTransfer, Individual' do
         | 
| 33 | 
            -
                  schema = MangoPay::Recipient.get_schema('LocalBankTransfer', 'Individual', 'GBP')
         | 
| 51 | 
            +
                  schema = MangoPay::Recipient.get_schema('LocalBankTransfer', 'Individual', 'GBP', 'GB')
         | 
| 34 52 | 
             
                  expect(schema).not_to be_nil
         | 
| 35 53 | 
             
                  expect(schema['DisplayName']).not_to be_nil
         | 
| 36 54 | 
             
                  expect(schema['Currency']).not_to be_nil
         | 
| @@ -42,10 +60,11 @@ describe MangoPay::Recipient do | |
| 42 60 | 
             
                  expect(schema['LocalBankTransfer']).not_to be_nil
         | 
| 43 61 | 
             
                  expect(schema['BusinessRecipient']).to be_nil
         | 
| 44 62 | 
             
                  expect(schema['InternationalBankTransfer']).to be_nil
         | 
| 63 | 
            +
                  expect(schema['Country']).not_to be_nil
         | 
| 45 64 | 
             
                end
         | 
| 46 65 |  | 
| 47 66 | 
             
                it 'fetches schema for InternationalBankTransfer, Business' do
         | 
| 48 | 
            -
                  schema = MangoPay::Recipient.get_schema('InternationalBankTransfer', 'Business', 'GBP')
         | 
| 67 | 
            +
                  schema = MangoPay::Recipient.get_schema('InternationalBankTransfer', 'Business', 'GBP', 'GB')
         | 
| 49 68 | 
             
                  expect(schema).not_to be_nil
         | 
| 50 69 | 
             
                  expect(schema['DisplayName']).not_to be_nil
         | 
| 51 70 | 
             
                  expect(schema['Currency']).not_to be_nil
         | 
| @@ -57,6 +76,7 @@ describe MangoPay::Recipient do | |
| 57 76 | 
             
                  expect(schema['InternationalBankTransfer']).not_to be_nil
         | 
| 58 77 | 
             
                  expect(schema['IndividualRecipient']).to be_nil
         | 
| 59 78 | 
             
                  expect(schema['LocalBankTransfer']).to be_nil
         | 
| 79 | 
            +
                  expect(schema['Country']).not_to be_nil
         | 
| 60 80 | 
             
                end
         | 
| 61 81 | 
             
              end
         | 
| 62 82 |  | 
| @@ -72,7 +92,7 @@ describe MangoPay::Recipient do | |
| 72 92 | 
             
              describe 'VALIDATE' do
         | 
| 73 93 | 
             
                it 'validates a recipient' do
         | 
| 74 94 | 
             
                  recipient = define_new_recipient
         | 
| 75 | 
            -
                  john =  | 
| 95 | 
            +
                  john = create_new_natural_user_sca_payer
         | 
| 76 96 | 
             
                  # it should pass
         | 
| 77 97 | 
             
                  MangoPay::Recipient.validate(recipient, john['Id'])
         | 
| 78 98 |  | 
| @@ -110,4 +130,5 @@ def assert_recipient(recipient) | |
| 110 130 | 
             
              expect(recipient['LocalBankTransfer']).not_to be_nil
         | 
| 111 131 | 
             
              expect(recipient['RecipientScope']).not_to be_nil
         | 
| 112 132 | 
             
              expect(recipient['UserId']).not_to be_nil
         | 
| 133 | 
            +
              expect(recipient['Country']).not_to be_nil
         | 
| 113 134 | 
             
            end
         | 
| @@ -73,7 +73,7 @@ describe MangoPay::PayIn::RecurringPayments, type: :feature do | |
| 73 73 | 
             
                  expect(cit).not_to be_nil
         | 
| 74 74 |  | 
| 75 75 | 
             
                  update = MangoPay::PayIn::RecurringPayments::Recurring.update(id, {
         | 
| 76 | 
            -
                    Status: ' | 
| 76 | 
            +
                    Status: 'ENDED'
         | 
| 77 77 | 
             
                  })
         | 
| 78 78 |  | 
| 79 79 | 
             
                  expect(update).not_to be_nil
         | 
| @@ -140,7 +140,7 @@ describe MangoPay::PayIn::RecurringPayments, type: :feature do | |
| 140 140 | 
             
                  )
         | 
| 141 141 |  | 
| 142 142 | 
             
                  expect(cit).not_to be_nil
         | 
| 143 | 
            -
                  expect(cit['Status']).to eq('CREATED')
         | 
| 143 | 
            +
                  # expect(cit['Status']).to eq('CREATED')
         | 
| 144 144 | 
             
                  expect(cit['PaymentType']).to eq('PAYPAL')
         | 
| 145 145 | 
             
                  expect(cit['ExecutionType']).to eq('WEB')
         | 
| 146 146 | 
             
                end
         | 
| @@ -214,7 +214,7 @@ describe MangoPay::PayIn::RecurringPayments, type: :feature do | |
| 214 214 | 
             
                  )
         | 
| 215 215 |  | 
| 216 216 | 
             
                  expect(cit).not_to be_nil
         | 
| 217 | 
            -
                  expect(cit['Status']).to eq('CREATED')
         | 
| 217 | 
            +
                  # expect(cit['Status']).to eq('CREATED')
         | 
| 218 218 | 
             
                  expect(cit['PaymentType']).to eq('PAYPAL')
         | 
| 219 219 | 
             
                  expect(cit['ExecutionType']).to eq('WEB')
         | 
| 220 220 | 
             
                end
         | 
| @@ -0,0 +1,117 @@ | |
| 1 | 
            +
            describe MangoPay::ReportV2 do
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              def create
         | 
| 4 | 
            +
                params = {
         | 
| 5 | 
            +
                  "Tag": "Created using the Mangopay API Postman collection",
         | 
| 6 | 
            +
                  "DownloadFormat": "CSV",
         | 
| 7 | 
            +
                  "ReportType": "COLLECTED_FEES",
         | 
| 8 | 
            +
                  "AfterDate": 1740787200,
         | 
| 9 | 
            +
                  "BeforeDate": 1743544740
         | 
| 10 | 
            +
                }
         | 
| 11 | 
            +
                MangoPay::ReportV2.create(params)
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              describe 'CREATE' do
         | 
| 15 | 
            +
                it 'creates a report v2' do
         | 
| 16 | 
            +
                  created = create
         | 
| 17 | 
            +
                  expect(created['Id']).to_not be_nil
         | 
| 18 | 
            +
                  expect(created['Status']).to eq("PENDING")
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                it 'creates an intent report' do
         | 
| 22 | 
            +
                  params = {
         | 
| 23 | 
            +
                    "DownloadFormat": "CSV",
         | 
| 24 | 
            +
                    "ReportType": "ECHO_INTENT",
         | 
| 25 | 
            +
                    "AfterDate": 1748782023,
         | 
| 26 | 
            +
                    "BeforeDate": 1753102013,
         | 
| 27 | 
            +
                    "Filters": {
         | 
| 28 | 
            +
                      "PaymentMethod": "PAYPAL",
         | 
| 29 | 
            +
                      "Status": "CAPTURED",
         | 
| 30 | 
            +
                      "Type": "PAYIN"
         | 
| 31 | 
            +
                    },
         | 
| 32 | 
            +
                    "Columns": %w[Id Status Amount Currency FeesAmount FeesCurrency Type PaymentMethod BuyerId SellerId]
         | 
| 33 | 
            +
                  }
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  created = MangoPay::ReportV2.create(params)
         | 
| 36 | 
            +
                  expect(created['Id']).to_not be_nil
         | 
| 37 | 
            +
                  expect(created['Status']).to eq("PENDING")
         | 
| 38 | 
            +
                  expect(created['ReportType']).to eq("ECHO_INTENT")
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                it 'creates an intent actions report' do
         | 
| 42 | 
            +
                  params = {
         | 
| 43 | 
            +
                    "DownloadFormat": "CSV",
         | 
| 44 | 
            +
                    "ReportType": "ECHO_INTENT_ACTION",
         | 
| 45 | 
            +
                    "AfterDate": 1748782023,
         | 
| 46 | 
            +
                    "BeforeDate": 1753102013,
         | 
| 47 | 
            +
                    "Filters": {
         | 
| 48 | 
            +
                      "PaymentMethod": "PAYPAL",
         | 
| 49 | 
            +
                      "Status": "CAPTURED",
         | 
| 50 | 
            +
                      "Type": "PAYIN"
         | 
| 51 | 
            +
                    },
         | 
| 52 | 
            +
                    "Columns": %w[IntentId Id ExternalProcessingDate ExternalProviderReference ExternalMerchantReference Status Amount Currency FeesAmount FeesCurrency Type PaymentMethod BuyerId SellerId]
         | 
| 53 | 
            +
                  }
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                  created = MangoPay::ReportV2.create(params)
         | 
| 56 | 
            +
                  expect(created['Id']).to_not be_nil
         | 
| 57 | 
            +
                  expect(created['Status']).to eq("PENDING")
         | 
| 58 | 
            +
                  expect(created['ReportType']).to eq("ECHO_INTENT_ACTION")
         | 
| 59 | 
            +
                end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                it 'creates settlement report' do
         | 
| 62 | 
            +
                  params = {
         | 
| 63 | 
            +
                    "Tag": "Creating a report using new Mangopay system",
         | 
| 64 | 
            +
                    "DownloadFormat": "CSV",
         | 
| 65 | 
            +
                    "ReportType": "ECHO_SETTLEMENT",
         | 
| 66 | 
            +
                    "AfterDate": 1748782023,
         | 
| 67 | 
            +
                    "BeforeDate": 1753102013,
         | 
| 68 | 
            +
                    "Filters": {
         | 
| 69 | 
            +
                      "Status": "RECONCILED",
         | 
| 70 | 
            +
                      "ExternalProviderName": "PAYPAL"
         | 
| 71 | 
            +
                    },
         | 
| 72 | 
            +
                    "Columns": %w[Id CreationDate FileName SettlementCurrency Status SettledTransactionCount UnsettledTransactionCount SettledAmount DeclaredAmount DeficitAmount]
         | 
| 73 | 
            +
                  }
         | 
| 74 | 
            +
             | 
| 75 | 
            +
                  created = MangoPay::ReportV2.create(params)
         | 
| 76 | 
            +
                  expect(created['Id']).to_not be_nil
         | 
| 77 | 
            +
                  expect(created['Status']).to eq("PENDING")
         | 
| 78 | 
            +
                  expect(created['ReportType']).to eq("ECHO_SETTLEMENT")
         | 
| 79 | 
            +
                end
         | 
| 80 | 
            +
              end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
              it 'creates split report' do
         | 
| 83 | 
            +
                params = {
         | 
| 84 | 
            +
                  "Tag": "Creating a report using new Mangopay system",
         | 
| 85 | 
            +
                  "DownloadFormat": "CSV",
         | 
| 86 | 
            +
                  "ReportType": "ECHO_SPLIT",
         | 
| 87 | 
            +
                  "AfterDate": 1748782023,
         | 
| 88 | 
            +
                  "BeforeDate": 1753102013,
         | 
| 89 | 
            +
                  "Filters": {
         | 
| 90 | 
            +
                    "Status": "COMPLETED",
         | 
| 91 | 
            +
                    "IntentId": "int_0197f975-63f6-714e-8fc6-4451e128170f",
         | 
| 92 | 
            +
                    "Scheduled": false
         | 
| 93 | 
            +
                  },
         | 
| 94 | 
            +
                  "Columns": %w[Id IntentId AuthorId Amount Currency FeesAmount FeesCurrency Status Description CreditedWalletId DebitedWalletId Scheduled CreationDate ExecutionDate]
         | 
| 95 | 
            +
                }
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                created = MangoPay::ReportV2.create(params)
         | 
| 98 | 
            +
                expect(created['Id']).to_not be_nil
         | 
| 99 | 
            +
                expect(created['Status']).to eq("PENDING")
         | 
| 100 | 
            +
                expect(created['ReportType']).to eq("ECHO_SPLIT")
         | 
| 101 | 
            +
              end
         | 
| 102 | 
            +
             | 
| 103 | 
            +
              describe 'GET' do
         | 
| 104 | 
            +
                it 'gets a report' do
         | 
| 105 | 
            +
                  created = create
         | 
| 106 | 
            +
                  fetched = MangoPay::ReportV2.get(created['Id'])
         | 
| 107 | 
            +
                  expect(fetched['Id']).to eq(created['Id'])
         | 
| 108 | 
            +
                end
         | 
| 109 | 
            +
             | 
| 110 | 
            +
                it 'gets all the reports' do
         | 
| 111 | 
            +
                  reports = MangoPay::ReportV2.get_all
         | 
| 112 | 
            +
                  expect(reports).to be_kind_of(Array)
         | 
| 113 | 
            +
                  expect(reports).not_to be_empty
         | 
| 114 | 
            +
                end
         | 
| 115 | 
            +
              end
         | 
| 116 | 
            +
             | 
| 117 | 
            +
            end
         | 
| @@ -0,0 +1,8 @@ | |
| 1 | 
            +
            IntentId,ExternalProviderReference,ExternalPaymentMethod,ExternalTransactionType,ExternalTransactionStatus,ExternalProcessingDate,Amount,Currency,ExternalInitialReference,ExternalProviderFees
         | 
| 2 | 
            +
            int_0197b19d-ee51-7b60-84cb-207491cf383a,6TU984332A894613W,PAYPAL,PAYMENT,SETTLED,19-06-2025,1000,EUR,,0
         | 
| 3 | 
            +
            ,,,,,,,,,
         | 
| 4 | 
            +
            SettlementDate,19-06-2025,,,,,,,,
         | 
| 5 | 
            +
            ExternalProviderName,Paypal,,,,,,,,
         | 
| 6 | 
            +
            TotalSettlementFeesAmount,0,,,,,,,,
         | 
| 7 | 
            +
            TotalSettlementAmount,1000,,,,,,,,
         | 
| 8 | 
            +
            SettlementCurrency,EUR,,,,,,,,
         | 
| @@ -0,0 +1,38 @@ | |
| 1 | 
            +
            describe MangoPay::Settlement do
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              let!(:settlement) do
         | 
| 4 | 
            +
                create_settlement_if_needed
         | 
| 5 | 
            +
              end
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              def create_settlement_if_needed
         | 
| 8 | 
            +
                @settlement ||= begin
         | 
| 9 | 
            +
                                  file_path = File.expand_path('settlement_sample.csv', __dir__)
         | 
| 10 | 
            +
                                  file = File.binread(file_path)
         | 
| 11 | 
            +
                                  MangoPay::Settlement.upload(file)
         | 
| 12 | 
            +
                                end
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              describe 'UPLOAD' do
         | 
| 16 | 
            +
                it 'uploads the file' do
         | 
| 17 | 
            +
                  expect(@settlement['Status']).to eq('UPLOADED')
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              describe 'GET' do
         | 
| 22 | 
            +
                it 'fetches the file' do
         | 
| 23 | 
            +
                  fetched = MangoPay::Settlement.get(@settlement['SettlementId'])
         | 
| 24 | 
            +
                  expect(fetched['Status']).to eq('UPLOADED')
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              describe 'UPDATE' do
         | 
| 29 | 
            +
                it 'updates the file' do
         | 
| 30 | 
            +
                  file_path = File.expand_path('settlement_sample.csv', __dir__)
         | 
| 31 | 
            +
                  file = File.binread(file_path)
         | 
| 32 | 
            +
                  before_update = MangoPay::Settlement.upload(file)
         | 
| 33 | 
            +
                  expect(before_update['Status']).to eq('UPLOADED')
         | 
| 34 | 
            +
                  updated = MangoPay::Settlement.update(before_update['SettlementId'], file)
         | 
| 35 | 
            +
                  expect(updated['Status']).to eq('UPLOADED')
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
            end
         | 
| @@ -27,14 +27,15 @@ shared_context 'users' do | |
| 27 27 | 
             
                  Nationality: 'FR',
         | 
| 28 28 | 
             
                  CountryOfResidence: 'FR',
         | 
| 29 29 | 
             
                  Occupation: 'Worker',
         | 
| 30 | 
            -
                  IncomeRange: 1
         | 
| 30 | 
            +
                  IncomeRange: 1,
         | 
| 31 | 
            +
                  TermsAndConditionsAccepted: true
         | 
| 31 32 | 
             
                }
         | 
| 32 33 | 
             
              end
         | 
| 33 34 |  | 
| 34 35 | 
             
              def define_new_natural_user_sca_payer
         | 
| 35 36 | 
             
                {
         | 
| 36 37 | 
             
                  "UserCategory": "PAYER",
         | 
| 37 | 
            -
                  "TermsAndConditionsAccepted":  | 
| 38 | 
            +
                  "TermsAndConditionsAccepted": true,
         | 
| 38 39 | 
             
                  "FirstName": "Alex",
         | 
| 39 40 | 
             
                  "LastName": "Smith",
         | 
| 40 41 | 
             
                  "Email": "alex.smith@example.com",
         | 
| @@ -79,7 +80,7 @@ shared_context 'users' do | |
| 79 80 | 
             
              def define_new_legal_user_sca_payer
         | 
| 80 81 | 
             
                {
         | 
| 81 82 | 
             
                  "UserCategory": "PAYER",
         | 
| 82 | 
            -
                  "TermsAndConditionsAccepted":  | 
| 83 | 
            +
                  "TermsAndConditionsAccepted": true,
         | 
| 83 84 | 
             
                  "LegalPersonType": "SOLETRADER",
         | 
| 84 85 | 
             
                  "Name": "Alex Smith",
         | 
| 85 86 | 
             
                  "Email": "alex.smith.services@example.com",
         | 
| @@ -193,7 +194,8 @@ shared_context 'users' do | |
| 193 194 | 
             
                  CompanyNumber: 'LU123456789',
         | 
| 194 195 | 
             
                  Statute: '',
         | 
| 195 196 | 
             
                  ProofOfRegistration: '',
         | 
| 196 | 
            -
                  ShareholderDeclaration: ''
         | 
| 197 | 
            +
                  ShareholderDeclaration: '',
         | 
| 198 | 
            +
                  TermsAndConditionsAccepted: true
         | 
| 197 199 | 
             
                )
         | 
| 198 200 | 
             
              end
         | 
| 199 201 | 
             
            end
         | 
| @@ -372,6 +374,18 @@ shared_context 'payins' do | |
| 372 374 | 
             
                )
         | 
| 373 375 | 
             
              end
         | 
| 374 376 |  | 
| 377 | 
            +
              let(:new_payin_payconiq_web_legacy) do
         | 
| 378 | 
            +
                MangoPay::PayIn::Payconiq::Web.create_legacy(
         | 
| 379 | 
            +
                  AuthorId: new_natural_user['Id'],
         | 
| 380 | 
            +
                  CreditedWalletId: new_wallet['Id'],
         | 
| 381 | 
            +
                  DebitedFunds: { Currency: 'EUR', Amount: 100 },
         | 
| 382 | 
            +
                  Fees: { Currency: 'EUR', Amount: 0 },
         | 
| 383 | 
            +
                  ReturnURL: MangoPay.configuration.root_url,
         | 
| 384 | 
            +
                  Country: "BE",
         | 
| 385 | 
            +
                  Tag: 'Custom Meta'
         | 
| 386 | 
            +
                )
         | 
| 387 | 
            +
              end
         | 
| 388 | 
            +
             | 
| 375 389 | 
             
              ###############################################
         | 
| 376 390 | 
             
              # applepay/direct
         | 
| 377 391 | 
             
              ###############################################
         | 
| @@ -740,6 +754,37 @@ shared_context 'payins' do | |
| 740 754 | 
             
                )
         | 
| 741 755 | 
             
              end
         | 
| 742 756 |  | 
| 757 | 
            +
              ###############################################
         | 
| 758 | 
            +
              # Bizum/web
         | 
| 759 | 
            +
              ###############################################
         | 
| 760 | 
            +
              let(:new_payin_bizum_web_with_phone) do
         | 
| 761 | 
            +
                user = new_natural_user
         | 
| 762 | 
            +
                wallet = new_wallet
         | 
| 763 | 
            +
                bizum = define_new_bizum(user, wallet, '+34700000000', nil)
         | 
| 764 | 
            +
                MangoPay::PayIn::Bizum::Web.create(bizum)
         | 
| 765 | 
            +
              end
         | 
| 766 | 
            +
             | 
| 767 | 
            +
              let(:new_payin_bizum_web_with_return_url) do
         | 
| 768 | 
            +
                user = new_natural_user
         | 
| 769 | 
            +
                wallet = new_wallet
         | 
| 770 | 
            +
                bizum = define_new_bizum(user, wallet, nil, 'https://docs.mangopay.com/please-ignore')
         | 
| 771 | 
            +
                MangoPay::PayIn::Bizum::Web.create(bizum)
         | 
| 772 | 
            +
              end
         | 
| 773 | 
            +
             | 
| 774 | 
            +
              def define_new_bizum(user, wallet, phone, return_url)
         | 
| 775 | 
            +
                {
         | 
| 776 | 
            +
                  AuthorId: user['Id'],
         | 
| 777 | 
            +
                  CreditedWalletId: wallet['Id'],
         | 
| 778 | 
            +
                  DebitedFunds: { Currency: 'EUR', Amount: 400 },
         | 
| 779 | 
            +
                  Fees: { Currency: 'EUR', Amount: 1 },
         | 
| 780 | 
            +
                  StatementDescriptor: "test bizum",
         | 
| 781 | 
            +
                  Phone: phone,
         | 
| 782 | 
            +
                  ReturnUrl: return_url,
         | 
| 783 | 
            +
                  Tag: 'Test PayIn/Bizum/Web',
         | 
| 784 | 
            +
                  ProfilingAttemptReference: nil
         | 
| 785 | 
            +
                }
         | 
| 786 | 
            +
              end
         | 
| 787 | 
            +
             | 
| 743 788 | 
             
              ###############################################
         | 
| 744 789 | 
             
              # Twint/web
         | 
| 745 790 | 
             
              ###############################################
         | 
| @@ -936,6 +981,28 @@ shared_context 'payins' do | |
| 936 981 | 
             
                )
         | 
| 937 982 | 
             
              end
         | 
| 938 983 |  | 
| 984 | 
            +
              def create_new_deposit_pre_authorized_pay_in_prior_to_complement(deposit_id, author_id, credited_wallet_id)
         | 
| 985 | 
            +
                MangoPay::PayIn::PreAuthorized::Direct.create_deposit_preauthorized_pay_in_prior_to_complement(
         | 
| 986 | 
            +
                  AuthorId: author_id,
         | 
| 987 | 
            +
                  CreditedWalletId: credited_wallet_id,
         | 
| 988 | 
            +
                  DebitedFunds: { Currency: 'EUR', Amount: 1000 },
         | 
| 989 | 
            +
                  Fees: { Currency: 'EUR', Amount: 0 },
         | 
| 990 | 
            +
                  DepositId: deposit_id,
         | 
| 991 | 
            +
                  Tag: 'lorem ipsum'
         | 
| 992 | 
            +
                )
         | 
| 993 | 
            +
              end
         | 
| 994 | 
            +
             | 
| 995 | 
            +
              def create_new_deposit_pre_authorized_pay_in_complement(deposit_id, author_id, credited_wallet_id)
         | 
| 996 | 
            +
                MangoPay::PayIn::PreAuthorized::Direct.create_deposit_preauthorized_pay_in_complement(
         | 
| 997 | 
            +
                  AuthorId: author_id,
         | 
| 998 | 
            +
                  CreditedWalletId: credited_wallet_id,
         | 
| 999 | 
            +
                  DebitedFunds: { Currency: 'EUR', Amount: 1000 },
         | 
| 1000 | 
            +
                  Fees: { Currency: 'EUR', Amount: 0 },
         | 
| 1001 | 
            +
                  DepositId: deposit_id,
         | 
| 1002 | 
            +
                  Tag: 'lorem ipsum'
         | 
| 1003 | 
            +
                )
         | 
| 1004 | 
            +
              end
         | 
| 1005 | 
            +
             | 
| 939 1006 | 
             
              ###############################################
         | 
| 940 1007 | 
             
              # bankwire/direct
         | 
| 941 1008 | 
             
              ###############################################
         | 
| @@ -1239,7 +1306,7 @@ end | |
| 1239 1306 | 
             
            shared_context 'recipient' do
         | 
| 1240 1307 | 
             
              include_context 'users'
         | 
| 1241 1308 |  | 
| 1242 | 
            -
              let(:new_recipient) { create_new_recipient( | 
| 1309 | 
            +
              let(:new_recipient) { create_new_recipient(create_new_natural_user_sca_payer['Id']) }
         | 
| 1243 1310 |  | 
| 1244 1311 | 
             
              def create_new_recipient(user_id)
         | 
| 1245 1312 | 
             
                MangoPay::Recipient.create(define_new_recipient, user_id)
         | 
| @@ -1251,6 +1318,7 @@ shared_context 'recipient' do | |
| 1251 1318 | 
             
                  "PayoutMethodType": "LocalBankTransfer",
         | 
| 1252 1319 | 
             
                  "RecipientType": "Individual",
         | 
| 1253 1320 | 
             
                  "Currency": "GBP",
         | 
| 1321 | 
            +
                  "Country": "GB",
         | 
| 1254 1322 | 
             
                  "IndividualRecipient": {
         | 
| 1255 1323 | 
             
                    "FirstName": "Alex",
         | 
| 1256 1324 | 
             
                    "LastName": "Smith",
         | 
| @@ -1269,4 +1337,44 @@ shared_context 'recipient' do | |
| 1269 1337 | 
             
                  }
         | 
| 1270 1338 | 
             
                }
         | 
| 1271 1339 | 
             
              end
         | 
| 1340 | 
            +
            end
         | 
| 1341 | 
            +
             | 
| 1342 | 
            +
            shared_context 'intents' do
         | 
| 1343 | 
            +
              include_context 'users'
         | 
| 1344 | 
            +
             | 
| 1345 | 
            +
              let(:new_payin_intent_authorization) { create_new_payin_intent_authorization(create_new_natural_user_sca_payer) }
         | 
| 1346 | 
            +
             | 
| 1347 | 
            +
              def create_new_payin_intent_authorization(user)
         | 
| 1348 | 
            +
                MangoPay::PayIn::PayInIntent::Authorization.create(define_new_payin_intent_authorization(user))
         | 
| 1349 | 
            +
              end
         | 
| 1350 | 
            +
             | 
| 1351 | 
            +
              def define_new_payin_intent_authorization(user)
         | 
| 1352 | 
            +
                wallet = create_new_wallet(user)
         | 
| 1353 | 
            +
                {
         | 
| 1354 | 
            +
                  "Amount": 1000,
         | 
| 1355 | 
            +
                  "Currency": "EUR",
         | 
| 1356 | 
            +
                  "ExternalData": {
         | 
| 1357 | 
            +
                    "ExternalProcessingDate": 1728133765,
         | 
| 1358 | 
            +
                    "ExternalProviderReference": SecureRandom.uuid,
         | 
| 1359 | 
            +
                    "ExternalMerchantReference": "Order-xyz-35e8490e-2ec9-4c82-978e-c712a3f5ba16",
         | 
| 1360 | 
            +
                    "ExternalProviderName": "Stripe",
         | 
| 1361 | 
            +
                    "ExternalProviderPaymentMethod": "PAYPAL"
         | 
| 1362 | 
            +
                  },
         | 
| 1363 | 
            +
                  "Buyer": {
         | 
| 1364 | 
            +
                    "Id": user['Id']
         | 
| 1365 | 
            +
                  },
         | 
| 1366 | 
            +
                  "LineItems": [
         | 
| 1367 | 
            +
                    {
         | 
| 1368 | 
            +
                      "Seller": {
         | 
| 1369 | 
            +
                        "AuthorId": user['Id'],
         | 
| 1370 | 
            +
                        "WalletId": wallet['Id'],
         | 
| 1371 | 
            +
                        "TransferDate": 1728133765
         | 
| 1372 | 
            +
                      },
         | 
| 1373 | 
            +
                      "Sku": "item-123456",
         | 
| 1374 | 
            +
                      "Quantity": 1,
         | 
| 1375 | 
            +
                      "UnitAmount": 1000,
         | 
| 1376 | 
            +
                    }
         | 
| 1377 | 
            +
                  ]
         | 
| 1378 | 
            +
                }
         | 
| 1379 | 
            +
              end
         | 
| 1272 1380 | 
             
            end
         | 
    
        data/spec/mangopay/user_spec.rb
    CHANGED
    
    | @@ -54,14 +54,16 @@ describe MangoPay::User do | |
| 54 54 | 
             
              describe 'UPDATE' do
         | 
| 55 55 | 
             
                it 'updates a natural user' do
         | 
| 56 56 | 
             
                  updated_user = MangoPay::NaturalUser.update(new_natural_user['Id'] ,{
         | 
| 57 | 
            -
                    FirstName: 'Jack'
         | 
| 57 | 
            +
                    FirstName: 'Jack',
         | 
| 58 | 
            +
                    TermsAndConditionsAccepted: true
         | 
| 58 59 | 
             
                  })
         | 
| 59 60 | 
             
                  expect(updated_user['FirstName']).to eq('Jack')
         | 
| 60 61 | 
             
                end
         | 
| 61 62 |  | 
| 62 63 | 
             
                it 'updates a legal user' do
         | 
| 63 64 | 
             
                  updated_user = MangoPay::LegalUser.update(new_legal_user['Id'], {
         | 
| 64 | 
            -
                    LegalRepresentativeFirstName: 'Jack'
         | 
| 65 | 
            +
                    LegalRepresentativeFirstName: 'Jack',
         | 
| 66 | 
            +
                    TermsAndConditionsAccepted: true
         | 
| 65 67 | 
             
                  })
         | 
| 66 68 | 
             
                  expect(updated_user['LegalRepresentativeFirstName']).to eq('Jack')
         | 
| 67 69 | 
             
                end
         | 
| @@ -85,7 +87,8 @@ describe MangoPay::User do | |
| 85 87 | 
             
                it 'updates a SCA natural user' do
         | 
| 86 88 | 
             
                  user = new_natural_user_sca_owner
         | 
| 87 89 | 
             
                  updated_user = MangoPay::NaturalUserSca.update(user['Id'] ,{
         | 
| 88 | 
            -
                    FirstName: 'Jack'
         | 
| 90 | 
            +
                    FirstName: 'Jack',
         | 
| 91 | 
            +
                    TermsAndConditionsAccepted: true
         | 
| 89 92 | 
             
                  })
         | 
| 90 93 | 
             
                  fetched = MangoPay::NaturalUserSca.fetch(user['Id'])
         | 
| 91 94 | 
             
                  expect(updated_user['FirstName']).to eq('Jack')
         | 
| @@ -97,7 +100,8 @@ describe MangoPay::User do | |
| 97 100 | 
             
                  legal_representative = user['LegalRepresentative']
         | 
| 98 101 | 
             
                  legal_representative['FirstName'] = 'Jack'
         | 
| 99 102 | 
             
                  updated_user = MangoPay::LegalUserSca.update(user['Id'] ,{
         | 
| 100 | 
            -
                    LegalRepresentative: legal_representative
         | 
| 103 | 
            +
                    LegalRepresentative: legal_representative,
         | 
| 104 | 
            +
                    TermsAndConditionsAccepted: true
         | 
| 101 105 | 
             
                  })
         | 
| 102 106 | 
             
                  fetched = MangoPay::LegalUserSca.fetch(user['Id'])
         | 
| 103 107 | 
             
                  expect(updated_user['LegalRepresentative']['FirstName']).to eq('Jack')
         | 
| @@ -157,6 +161,18 @@ describe MangoPay::User do | |
| 157 161 | 
             
                end
         | 
| 158 162 | 
             
              end
         | 
| 159 163 |  | 
| 164 | 
            +
              describe 'MANAGE CONSENT' do
         | 
| 165 | 
            +
                it 'manages consent' do
         | 
| 166 | 
            +
                  user = new_natural_user
         | 
| 167 | 
            +
             | 
| 168 | 
            +
                  enrollment_result = MangoPay::User.enroll_sca(user['Id'])
         | 
| 169 | 
            +
                  expect(enrollment_result["PendingUserAction"]["RedirectUrl"]).not_to be_nil
         | 
| 170 | 
            +
             | 
| 171 | 
            +
                  consent_result = MangoPay::User.manage_consent(user['Id'])
         | 
| 172 | 
            +
                  expect(consent_result["PendingUserAction"]["RedirectUrl"]).not_to be_nil
         | 
| 173 | 
            +
                end
         | 
| 174 | 
            +
              end
         | 
| 175 | 
            +
             | 
| 160 176 | 
             
              describe 'FETCH' do
         | 
| 161 177 | 
             
                it 'fetches all the users' do
         | 
| 162 178 | 
             
                  users = MangoPay::User.fetch()
         | 
| @@ -399,4 +415,30 @@ describe MangoPay::User do | |
| 399 415 | 
             
                  expect(closed['UserStatus']).to eq('CLOSED')
         | 
| 400 416 | 
             
                end
         | 
| 401 417 | 
             
              end
         | 
| 418 | 
            +
             | 
| 419 | 
            +
              describe 'Validate User Data Format' do
         | 
| 420 | 
            +
                it 'validates successfully' do
         | 
| 421 | 
            +
                  validation = {
         | 
| 422 | 
            +
                    "CompanyNumber": {
         | 
| 423 | 
            +
                      "CompanyNumber": "AB123456",
         | 
| 424 | 
            +
                      "CountryCode": "IT"
         | 
| 425 | 
            +
                    }
         | 
| 426 | 
            +
                  }
         | 
| 427 | 
            +
                  result = MangoPay::User.validate_data_format(validation)
         | 
| 428 | 
            +
                  expect(result['CompanyNumber']).not_to be_nil
         | 
| 429 | 
            +
                end
         | 
| 430 | 
            +
             | 
| 431 | 
            +
                it 'validates with error' do
         | 
| 432 | 
            +
                  validation = {
         | 
| 433 | 
            +
                    "CompanyNumber": {
         | 
| 434 | 
            +
                      "CompanyNumber": "123"
         | 
| 435 | 
            +
                    }
         | 
| 436 | 
            +
                  }
         | 
| 437 | 
            +
                  expect { MangoPay::User.validate_data_format(validation) }.to raise_error { |err|
         | 
| 438 | 
            +
                    expect(err).to be_a MangoPay::ResponseError
         | 
| 439 | 
            +
                    expect(err.code).to eq '400'
         | 
| 440 | 
            +
                    expect(err.type).to eq 'param_error'
         | 
| 441 | 
            +
                  }
         | 
| 442 | 
            +
                end
         | 
| 443 | 
            +
              end
         | 
| 402 444 | 
             
            end
         |