<commit_before>require 'base'

LOGS_PREFIX = "#{LOGS_DIR}/payment_#{START_TIME}"

PLUGIN = ENV['PLUGIN'] || '__EXTERNAL_PAYMENT__'

if ENV['SKIP_GW']
  PLUGIN_PROPERTIES = 'pluginProperty=skip_gw=true'
else
  PLUGIN_PROPERTIES = ENV['PLUGIN_PROPERTIES'] || ''
end

# Usage example: NB_THREADS=10 DURATION=30 SKIP_GW=true PLUGIN=killbill-litle DEBUG=true ruby payment.rb
scenario = test do
  header COMMON_HEADERS

  threads count: NB_THREADS.to_i, rampup: 30, duration: DURATION.to_i, on_sample_error: 'startnextloop' do

    transaction 'Create an account and trigger a payment' do
      counter = '${__counter(false)}'

      #
      # Create account
      #

      first, last = "John #{counter}", "Bill"
      account = {
          name: "#{first} #{last}",
          email: "<EMAIL>",
          currency: 'USD'
      }
      post name: :'Create Account',
           url: KB_ACCOUNTS_URL,
           raw_body: account.to_json,
           headers: true do
        assert equals: 201, test_field: 'Assertion.response_code'
        extract name: 'account_id',
                regex: LOCATION_ID_REGEX,
                headers: true
      end

      exists 'account_id' do
        #
        # Add default payment method
        #

        payment_method_body_body = {
            pluginName: PLUGIN,
            pluginInfo: {
                properties: [
                    {key: 'email', value: account[:email]},
                    {key: 'description', value: START_TIME},
                    {key: 'ccFirstName', value: first},
                    {key: 'ccLastName', value: last},
                    {key: 'ccNumber', value: '4242424242424242'},
                    {key: 'ccExpirationYear', value: '2020'},
                    {key: 'ccExpirationMonth', value: '10'},
                ]<commit_msg>jmeter: add billing address (required by certain PSP)<commit_after>require 'base'

LOGS_PREFIX = "#{LOGS_DIR}/payment_#{START_TIME}"

PLUGIN = ENV['PLUGIN'] || '__EXTERNAL_PAYMENT__'

if ENV['SKIP_GW']
  PLUGIN_PROPERTIES = 'pluginProperty=skip_gw=true'
else
  PLUGIN_PROPERTIES = ENV['PLUGIN_PROPERTIES'] || ''
end

# Usage example: NB_THREADS=10 DURATION=30 SKIP_GW=true PLUGIN=killbill-litle DEBUG=true ruby payment.rb
scenario = test do
  header COMMON_HEADERS

  threads count: NB_THREADS.to_i, rampup: 30, duration: DURATION.to_i, on_sample_error: 'startnextloop' do

    transaction 'Create an account and trigger a payment' do
      counter = '${__counter(false)}'

      #
      # Create account
      #

      first, last = "John #{counter}", "Bill"
      account = {
          name: "#{first} #{last}",
          email: "<EMAIL>",
          currency: 'USD'
      }
      post name: :'Create Account',
           url: KB_ACCOUNTS_URL,
           raw_body: account.to_json,
           headers: true do
        assert equals: 201, test_field: 'Assertion.response_code'
        extract name: 'account_id',
                regex: LOCATION_ID_REGEX,
                headers: true
      end

      exists 'account_id' do
        #
        # Add default payment method
        #

        payment_method_body_body = {
            pluginName: PLUGIN,
            pluginInfo: {
                properties: [
                    {key: 'email', value: '<EMAIL>'},
                    {key: 'description', value: START_TIME},
                    {key: 'ccFirstName', value: first},
                    {key: 'ccLastName', value: last},
                    {key: 'address1', value: '5th street'},
                    {key: 'city', value: 'San Francisco'},
                    {key: 'zip', value: '94111'},
                    {key: 'state', value: 'CA'},
                    {key: 'country', value: 'US'},
                    {key: 'ccNumber', value: '4242424242424242'},
                    {key: 'ccExpirationYear', value: '2020'},
                    {key: 'ccExpirationMonth', value: '10'},
                ]
{'fraction_non_alphanumeric': 0.12164579606440072, 'fraction_numerical': 0.01763352926143624, 'mean_word_length': 2.0294117647058822, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '128588', 'n_tokens_mistral': 1287, 'n_tokens_neox': 1180, 'n_words': 287}