Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9011805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:50:18+00:00 2026-06-16T02:50:18+00:00

Background Developing an app using Paymill’s subscription billing feature. Making use of the Ruby

  • 0

Background

  • Developing an app using Paymill’s subscription billing feature.
  • Making use of the Ruby wrapper, I have created a PaymentProvider class and spec as below.

Question

How do I make a test payment fail? (e.g. card is declined, or card expired in future subscription payments)

Stripe would let me do this using special card numbers but there doesn’t appear to be any such documentation (in English) for Paymill.


payment_provider.rb

class PaymentProvider
  Paymill.api_key = ENV['PAYMILL_PRIVATE_KEY']

  def self.start_new_subscription(email, description, token)
    offer = Paymill::Offer.find(ENV['PAYMILL_OFFER_ID'])
    client = Paymill::Client.create(email: email, description: description)
    payment = Paymill::Payment.create(token: token, client: client.id)
    subscription = Paymill::Subscription.create(client: client.id, offer: offer.id, payment: payment.id)
    subscription.id
  end
end

payment_provider_spec.rb

require 'spec_helper'

describe PaymentProvider do

  describe "#start_new_subscription" do
    it "returns a subscription id, starting 'sub_' when successful" do
      email = "mike@mike.com"
      description = "me"
      token = get_payment_token
      subscription_id = PaymentProvider.start_new_subscription(email, description, token)
      expect(subscription_id[0,4]).to eq('sub_')
    end
  end

  def get_payment_token
    # Simulate the JavaScript bridge we would use in production
    params = {
      'transaction.mode'        => 'CONNECTOR_TEST',
      'channel.id'              => ENV['PAYMILL_PUBLIC_KEY'],
      'jsonPFunction'           => 'any_string',
      'account.number'          => '5500000000000004',
      'account.expiry.month'    => 3.years.from_now.month,
      'account.expiry.year'     => 3.years.from_now.year,
      'account.verification'    => '111'
      #'presentation.amount3D'   => BigDecimal('10.00'),
      #'presentation.currency3D' => 'GBP'
    }
    http = Net::HTTP.new('test-token.paymill.de', 443)
    http.use_ssl = true
    response = http.get url_query_string(params)
    response.body.scan(/tok_\w*\b/).first # Use a regex to pull the token from the (not-quite-JSON) response
  end

  def url_query_string(hash)
    "/?" << URI.escape(hash.collect{|k,v| "#{k}=#{v}"}.join('&'))
  end

end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:50:19+00:00Added an answer on June 16, 2026 at 2:50 am

    As of today, there are no special credit card numbers to simulate those problems. However, due to demands from the community, this is currently in the backlog for being implemented. I’d suggest to send an email to the support, to show interest on this feature. The more requests, the faster the feature will be implemented.

    EDIT: PAYMILL now offers a special MasterCard number, which will fail if a certain combination of expiration month and year is used. For instance, the card 5105105105105100 will fail due to RESPONSE_BACKEND_BLACKLISTED if the expiration date is sent as 02/2020.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing app using the jquerymobile framework. I have to set the background
I'm trying to add an in-background alarm clock feature to an app I'm developing.
I am developing a registration web app using Struts2 and need some guidance. Background:
Background: We are developing an in house use only cocoa app to help us
Background I'm developing a django app for a vacation rental site. It will have
I am developing a small app in which I want a background service to
Background: I am developing a largish project using at Atmel AVR atmega2560. This project
First, some background: I'm developing a web application using Python. All of my (text)
I'm developing an HTML5 app for Android, iPhone and Windows phone and I'm using
Background This is only my second PyQt4 project. Developing a Windows app that has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.