Skip to content

Commit

Permalink
Litle: support paypage registrations
Browse files Browse the repository at this point in the history
Allow to pass a paypageRegistrationId in the store() call, instead of a
credit card.

Testing Done: tested the integration with the Kill Bill Litle plugin
(see http://kill-bill.org).

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>

Closes activemerchant#740.
  • Loading branch information
Pierre-Alexandre Meyer authored and chengz committed Dec 7, 2013
1 parent 1e1d119 commit b02f6e9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Fat Zebra: More consistent handling of tokens [adrianmacneil]
* Add Platron integration [alexwl]
* Litle: Support wiredump_device [pierre]
* Litle: support paypage registrations [pierre]

== Version 1.35.1 (July 22, 2013)

Expand Down
14 changes: 10 additions & 4 deletions lib/active_merchant/billing/gateways/litle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ def credit(money, identification_or_token, options = {})
build_response(:credit, @litle.credit(to_pass))
end

def store(creditcard, options = {})
to_pass = create_token_hash(creditcard, options)
def store(creditcard_or_paypage_registration_id, options = {})
to_pass = create_token_hash(creditcard_or_paypage_registration_id, options)
build_response(:registerToken, @litle.register_token_request(to_pass), %w(000 801 802))
end

Expand Down Expand Up @@ -294,9 +294,15 @@ def create_capture_hash(money, authorization, options)
hash
end

def create_token_hash(creditcard, options)
def create_token_hash(creditcard_or_paypage_registration_id, options)
hash = create_hash(0, options)
hash['accountNumber'] = creditcard.number

if creditcard_or_paypage_registration_id.is_a?(String)
hash['paypageRegistrationId'] = creditcard_or_paypage_registration_id
else
hash['accountNumber'] = creditcard_or_paypage_registration_id.number
end

hash
end

Expand Down
11 changes: 11 additions & 0 deletions test/unit/gateways/litle_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,17 @@ def test_store_fail_schema
assert_equal 'Error validating xml data against the schema', responseFrom.message
end

def test_store_via_paypage
storeResponseObj = {'response' => '801', 'message' => 'Account number was successfully registered', 'litleToken'=>'1111222233334444', 'litleTxnId'=>nil}
retObj = {'response'=>'0','registerTokenResponse'=>storeResponseObj}
LitleOnline::Communications.expects(:http_post => retObj.to_xml(:root => 'litleOnlineResponse'))
paypage_registration_id = 'eVY1SUYrSTFndWo0U3p0L2RaWjR1blhMVEh2L0pJTWl5bm1LS3QyUDVWOFRpczRYYS9qbndzLzVEb0M5N3RTcQ=='

responseFrom = @gateway.store(paypage_registration_id,{})
assert_equal true, responseFrom.success?
assert_equal '1111222233334444', responseFrom.params['litleOnlineResponse']['registerTokenResponse']['litleToken']
end

def test_in_production_with_test_param_sends_request_to_test_server
begin
ActiveMerchant::Billing::Base.mode = :production
Expand Down

0 comments on commit b02f6e9

Please sign in to comment.