2012-12-20 14 views
8

पृष्ठभूमिपेममिल: परीक्षण करते समय मैं एक असफल भुगतान का अनुकरण कैसे करूं?

  • Paymill's subscription billing सुविधा का उपयोग करके ऐप्लिकेशन का विकास करना।
  • Ruby wrapper का उपयोग करना, मैंने PaymentProvider वर्ग और स्पेक नीचे बनाया है।

प्रश्न

मैं कैसे एक परीक्षण भुगतान असफल कर सकता हूँ? Paymill के लिए (जैसे कार्ड अस्वीकृत हो गया, या कार्ड भविष्य सदस्यता भुगतान में समाप्त हो गई)

Stripe would let me do this using special card numbers लेकिन वहाँ किसी भी तरह के प्रलेखन (अंग्रेजी में) होने के लिए प्रकट नहीं होता है


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 = "[email protected]" 
     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 

उत्तर

4

आज के रूप में, वहाँ कोई विशेष क्रेडिट कार्ड नंबर उन समस्याओं अनुकरण करने के लिए कर रहे हैं। हालांकि, समुदाय की मांगों के कारण, यह वर्तमान में लागू होने के लिए बैकलॉग में है। मैं इस सुविधा पर ब्याज दिखाने के लिए, समर्थन के लिए एक ईमेल भेजने का सुझाव दूंगा। अधिक अनुरोध, तेज़ी से सुविधा लागू की जाएगी।

संपादित करें: पेमल अब एक विशेष मास्टरकार्ड नंबर प्रदान करता है, जो विफल हो जाएगा यदि समाप्ति महीने और वर्ष का एक निश्चित संयोजन उपयोग किया जाता है। उदाहरण के लिए, यदि दिनांक दिनांक 02/2020 के रूप में भेजा जाता है तो कार्ड 5105105105105100 RESPONSE_BACKEND_BLACKLISTED के कारण विफल हो जाएगा।

+0

समाप्ति तिथियों और त्रुटि कोड के संयोजनों की पूरी सूची यहां मिल सकती है: https://developers.paymill.com/guides/reference/testing#how-do-i-test-credit-card- विशिष्ट- आतंक -codes- – LeEnno

0

आप क्या कर सकते हैं सत्यापन मान के लिए एक संख्या के बजाय स्ट्रिंग का उपयोग करना है।

'account.verification' => 'abc' 

निष्फल भुगतान भी जब CONNECTOR_TEST मोड का उपयोग कर में मेरी जानकारी के परिणाम के रूप में हो जाएगा ताकि।

संबंधित मुद्दे