Class: GpWebpay::SpecHelper::Interface
- Inherits:
-
Object
- Object
- GpWebpay::SpecHelper::Interface
- Includes:
- RSpec::Mocks::ExampleMethods, Savon::SpecHelper
- Defined in:
- lib/gp_webpay/mock/spec_helper.rb
Instance Method Summary collapse
- #params_with_both_digests(params, merchant_number = :default) ⇒ Object
- #params_with_digest(params, merchant_number = :default) ⇒ Object
- #stub_cancel_capture(attributes, merchant_number: nil, valid: true, success: true, status: '', result_text: 'OK') ⇒ Object
- #stub_capture_reverse(attributes, merchant_number: nil, valid: true, success: true, status: '', result_text: 'OK') ⇒ Object
- #stub_card_token(token, status: 'VERIFIED', success: true, valid: true) ⇒ Object
- #stub_master_payment_status(payment_number, status: 'OK', success: true, valid: true) ⇒ Object
- #stub_payment_status(payment_number, merchant_number: nil, status: 'VERIFIED', sub_status: 'SETTLED', success: true, valid: true) ⇒ Object
- #stub_refund_payment(attributes, merchant_number: nil, valid: true, success: true, status: '', result_text: 'OK') ⇒ Object
- #stub_token_revoke(token, merchant_number: nil, valid: true, success: true, status: 'REVOKED', result_text: 'OK') ⇒ Object
- #stub_usage_based_payment(attributes, merchant_number:, valid: true, success: true, status: '', result_text: 'OK', response_token_data: nil) ⇒ Object
Instance Method Details
#params_with_both_digests(params, merchant_number = :default) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/gp_webpay/mock/spec_helper.rb', line 16 def params_with_both_digests(params, merchant_number = :default) config = GpWebpay.config[merchant_number] || GpWebpay.config.default params.merge( 'DIGEST' => GpWebpay::OpensslSecurity.generate_digest(config, params.values.join('|')), 'DIGEST1' => GpWebpay::OpensslSecurity.generate_digest(config, "#{params.values.join('|')}|#{config.merchant_number}") ) end |
#params_with_digest(params, merchant_number = :default) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/gp_webpay/mock/spec_helper.rb', line 9 def params_with_digest(params, merchant_number = :default) config = GpWebpay.config[merchant_number] || GpWebpay.config.default params.merge( 'DIGEST' => GpWebpay::OpensslSecurity.generate_digest(config, params.values.join('|')) ) end |
#stub_cancel_capture(attributes, merchant_number: nil, valid: true, success: true, status: '', result_text: 'OK') ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/gp_webpay/mock/spec_helper.rb', line 100 def stub_cancel_capture(attributes, merchant_number: nil, valid: true, success: true, status: '', result_text: 'OK') allow(GpWebpay::Ws::Services::ProcessCancelCapture) .to receive(:call).with( hash_including({ message_id: anything }.merge(attributes)), merchant_number: merchant_number ).and_return(instance_double(GpWebpay::Ws::WsResponse, valid?: valid, success?: success, status: status, result_text: result_text, pr_code: success ? '0' : '123', sr_code: success ? '0' : '4', original_response: { pr_code: 0, sr_code: 0 })) end |
#stub_capture_reverse(attributes, merchant_number: nil, valid: true, success: true, status: '', result_text: 'OK') ⇒ Object
90 91 92 93 94 95 96 97 98 |
# File 'lib/gp_webpay/mock/spec_helper.rb', line 90 def stub_capture_reverse(attributes, merchant_number: nil, valid: true, success: true, status: '', result_text: 'OK') allow(GpWebpay::Ws::Services::ProcessCaptureReverse) .to receive(:call).with( hash_including({ message_id: anything }.merge(attributes)), merchant_number: merchant_number ).and_return(instance_double(GpWebpay::Ws::WsResponse, valid?: valid, success?: success, status: status, result_text: result_text, pr_code: success ? '0' : '123', sr_code: success ? '0' : '4', original_response: { pr_code: 0, sr_code: 0 })) end |
#stub_card_token(token, status: 'VERIFIED', success: true, valid: true) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/gp_webpay/mock/spec_helper.rb', line 24 def stub_card_token(token, status: 'VERIFIED', success: true, valid: true) allow(GpWebpay::Ws::Services::GetTokenStatus) .to receive(:call).with(hash_including(token_data: token, message_id: anything)) .and_return(instance_double(GpWebpay::Ws::WsResponse, valid?: valid, success?: success, status: status, pr_code: (success ? '0' : '123'), sr_code: (success ? '0' : '4'), original_response: { pr_code: 0, sr_code: 0 })) end |
#stub_master_payment_status(payment_number, status: 'OK', success: true, valid: true) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/gp_webpay/mock/spec_helper.rb', line 33 def stub_master_payment_status(payment_number, status: 'OK', success: true, valid: true) allow(GpWebpay::Ws::Services::GetMasterPaymentStatus) .to receive(:call).with(hash_including(payment_number: payment_number, message_id: anything)) .and_return(instance_double(GpWebpay::Ws::WsResponse, valid?: valid, success?: success, status: status, pr_code: (success ? '0' : '123'), sr_code: (success ? '0' : '4'), original_response: { pr_code: 0, sr_code: 0 })) end |
#stub_payment_status(payment_number, merchant_number: nil, status: 'VERIFIED', sub_status: 'SETTLED', success: true, valid: true) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/gp_webpay/mock/spec_helper.rb', line 42 def stub_payment_status(payment_number, merchant_number: nil, status: 'VERIFIED', sub_status: 'SETTLED', success: true, valid: true) allow(GpWebpay::Ws::Services::GetPaymentStatus) .to receive(:call).with(hash_including(payment_number: payment_number, message_id: anything), merchant_number: merchant_number) .and_return(instance_double(GpWebpay::Ws::WsResponse, valid?: valid, success?: success, status: status, pr_code: success ? '0' : '123', sr_code: success ? '0' : '4', original_response: { pr_code: 0, sr_code: 0 }, params: { sub_status: sub_status })) end |
#stub_refund_payment(attributes, merchant_number: nil, valid: true, success: true, status: '', result_text: 'OK') ⇒ Object
80 81 82 83 84 85 86 87 88 |
# File 'lib/gp_webpay/mock/spec_helper.rb', line 80 def stub_refund_payment(attributes, merchant_number: nil, valid: true, success: true, status: '', result_text: 'OK') allow(GpWebpay::Ws::Services::ProcessRefundPayment) .to receive(:call).with( hash_including({ message_id: anything }.merge(attributes)), merchant_number: merchant_number ).and_return(instance_double(GpWebpay::Ws::WsResponse, valid?: valid, success?: success, status: status, result_text: result_text, pr_code: success ? '0' : '123', sr_code: success ? '0' : '4', original_response: { pr_code: 0, sr_code: 0 })) end |
#stub_token_revoke(token, merchant_number: nil, valid: true, success: true, status: 'REVOKED', result_text: 'OK') ⇒ Object
70 71 72 73 74 75 76 77 78 |
# File 'lib/gp_webpay/mock/spec_helper.rb', line 70 def stub_token_revoke(token, merchant_number: nil, valid: true, success: true, status: 'REVOKED', result_text: 'OK') allow(GpWebpay::Ws::Services::ProcessTokenRevoke) .to receive(:call).with( hash_including({ message_id: anything }.merge(token_data: token)), merchant_number: merchant_number ).and_return(instance_double(GpWebpay::Ws::WsResponse, valid?: valid, success?: success, status: status, result_text: result_text, pr_code: (success ? '0' : '123'), sr_code: (success ? '0' : '4'), original_response: { pr_code: 0, sr_code: 0 })) end |
#stub_usage_based_payment(attributes, merchant_number:, valid: true, success: true, status: '', result_text: 'OK', response_token_data: nil) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/gp_webpay/mock/spec_helper.rb', line 52 def stub_usage_based_payment(attributes, merchant_number:, valid: true, success: true, status: '', result_text: 'OK', response_token_data: nil) allow(GpWebpay::Ws::Services::ProcessUsageBasedPayment) .to receive(:call).with( hash_including( { message_id: anything, payment_number: anything, order_number: anything, currency_code: anything, capture_flag: '1' }.merge(attributes) ), merchant_number: merchant_number ).and_return(instance_double(GpWebpay::Ws::WsResponse, valid?: valid, success?: success, status: status, result_text: result_text, pr_code: success ? '0' : '123', sr_code: success ? '0' : '4', original_response: { pr_code: 0, sr_code: 0 }, params: { token_data: response_token_data || attributes[:token_data] })) end |