shared_examples 'payment_flow_spec' do before(:each) do create_payment end after(:each) do @plugin.stop_plugin end it 'should be able to purchase' do Killbill::Orbital::OrbitalResponse.all.size.should == 1 Killbill::Orbital::OrbitalTransaction.all.size.should == 0 payment_response = @plugin.purchase_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[0].id, @pm.kb_payment_method_id, @amount, @currency, @properties, @call_context) payment_response.status.should eq(:PROCESSED), payment_response.gateway_error payment_response.amount.should == @amount payment_response.transaction_type.should == :PURCHASE find_value_from_properties(payment_response.properties, 'processorResponse').should == '100' responses = Killbill::Orbital::OrbitalResponse.all responses.size.should == 2 responses[0].api_call.should == 'add_payment_method' responses[0].message.should == 'Profile Request Processed' responses[1].api_call.should == 'purchase' responses[1].message.should == 'Approved' transactions = Killbill::Orbital::OrbitalTransaction.all transactions.size.should == 1 transactions[0].api_call.should == 'purchase' end it 'should be able to charge and refund' do payment_response = @plugin.purchase_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[0].id, @pm.kb_payment_method_id, @amount, @currency, @properties, @call_context) payment_response.status.should eq(:PROCESSED), payment_response.gateway_error payment_response.amount.should == @amount payment_response.transaction_type.should == :PURCHASE find_value_from_properties(payment_response.properties, 'processorResponse').should == '100' # Try a full refund refund_response = @plugin.refund_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[1].id, @pm.kb_payment_method_id, @amount, @currency, @properties, @call_context) refund_response.status.should eq(:PROCESSED), refund_response.gateway_error refund_response.amount.should == @amount refund_response.transaction_type.should == :REFUND end it 'should be able to auth, capture and refund' do payment_response = @plugin.authorize_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[0].id, @pm.kb_payment_method_id, @amount, @currency, @properties, @call_context) payment_response.status.should eq(:PROCESSED), payment_response.gateway_error payment_response.amount.should == @amount payment_response.transaction_type.should == :AUTHORIZE find_value_from_properties(payment_response.properties, 'processorResponse').should == '100' # Try multiple partial captures partial_capture_amount = BigDecimal.new('10') 1.upto(3) do |i| payment_response = @plugin.capture_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[i].id, @pm.kb_payment_method_id, partial_capture_amount, @currency, @properties, @call_context) payment_response.status.should eq(:PROCESSED), payment_response.gateway_error payment_response.amount.should == partial_capture_amount payment_response.transaction_type.should == :CAPTURE end # Try a partial refund refund_response = @plugin.refund_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[4].id, @pm.kb_payment_method_id, partial_capture_amount, @currency, @properties, @call_context) refund_response.status.should eq(:PROCESSED), refund_response.gateway_error refund_response.amount.should == partial_capture_amount refund_response.transaction_type.should == :REFUND # Try to capture again payment_response = @plugin.capture_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[5].id, @pm.kb_payment_method_id, partial_capture_amount, @currency, @properties, @call_context) payment_response.status.should eq(:PROCESSED), payment_response.gateway_error payment_response.amount.should == partial_capture_amount payment_response.transaction_type.should == :CAPTURE end it 'should be able to auth and void' do payment_response = @plugin.authorize_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[0].id, @pm.kb_payment_method_id, @amount, @currency, @properties, @call_context) payment_response.status.should eq(:PROCESSED), payment_response.gateway_error payment_response.amount.should == @amount payment_response.transaction_type.should == :AUTHORIZE find_value_from_properties(payment_response.properties, 'processorResponse').should == '100' payment_response = @plugin.void_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[1].id, @pm.kb_payment_method_id, @properties, @call_context) payment_response.status.should eq(:PROCESSED), payment_response.gateway_error payment_response.transaction_type.should == :VOID end it 'should be able to auth, partial capture and void' do payment_response = @plugin.authorize_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[0].id, @pm.kb_payment_method_id, @amount, @currency, @properties, @call_context) payment_response.status.should eq(:PROCESSED), payment_response.gateway_error payment_response.amount.should == @amount payment_response.transaction_type.should == :AUTHORIZE find_value_from_properties(payment_response.properties, 'processorResponse').should == '100' partial_capture_amount = BigDecimal.new('10') payment_response = @plugin.capture_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[1].id, @pm.kb_payment_method_id, partial_capture_amount, @currency, @properties, @call_context) payment_response.status.should eq(:PROCESSED), payment_response.gateway_error payment_response.amount.should == partial_capture_amount payment_response.transaction_type.should == :CAPTURE payment_response = @plugin.void_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[2].id, @pm.kb_payment_method_id, @properties, @call_context) payment_response.status.should eq(:PROCESSED), payment_response.gateway_error payment_response.transaction_type.should == :VOID end it 'should be able to credit' do payment_response = @plugin.credit_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[0].id, @pm.kb_payment_method_id, @amount, @currency, @properties, @call_context) payment_response.status.should eq(:PROCESSED), payment_response.gateway_error payment_response.amount.should == @amount payment_response.transaction_type.should == :CREDIT end it 'should include host response code' do # Sending a specific amount of 530 will trigger the Do Not Honor error. payment_response = @plugin.authorize_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[0].id, @pm.kb_payment_method_id, BigDecimal.new('530'), @currency, @properties, @call_context) payment_response.status.should eq(:ERROR), payment_response.gateway_error payment_response.transaction_type.should == :AUTHORIZE payment_response.amount.should be_nil find_value_from_properties(payment_response.properties, 'processorResponse').should == '530' end end