1+ # frozen_string_literal: true
2+
3+ require 'spec_helper'
4+
5+ describe MidtransApi ::Api ::Merchant ::Create do
6+ let ( :client ) do
7+ MidtransApi ::Client . new (
8+ client_key : 'secret_key' ,
9+ server_key : 'secret_key' ,
10+ sandbox : true ,
11+ api_version : :v1
12+ )
13+ end
14+
15+ let ( :params ) do
16+ {
17+ "email" : "merchant@midtrans.com" ,
18+ "merchant_name" : "HQ Midtrans Merchant" ,
19+ "callback_url" : "https://merchant.com/midtrans-callback" ,
20+ "notification_url" : "https://merchant.com/midtrans-notification" ,
21+ "pay_account_url" : "https://merchant.com/pay-account-notification" ,
22+ "owner_name" : "Owner Midtrans" ,
23+ "merchant_phone_number" : "81211111111" ,
24+ "mcc" : "Event" ,
25+ "entity_type" : "corporate" ,
26+ "business_name" : "PT Business Name"
27+ }
28+ end
29+
30+ let ( :success_response ) do
31+ {
32+ "status_code" : "200" ,
33+ "status_message" : "Merchants have been successfully created." ,
34+ "merchant_id" : "M123456" ,
35+ "merchant_name" : "HQ Midtrans Merchant" ,
36+ "merchant_phone_number" : "81211111111" ,
37+ "email" : "merchant@midtrans.com" ,
38+ "callback_url" : "https://merchant.com/midtrans-callback" ,
39+ "notification_url" : "https://merchant.com/midtrans-notification" ,
40+ "pay_account_url" : "https://merchant.com/pay-account-notification" ,
41+ "owner_name" : "Owner Midtrans" ,
42+ "mcc" : "Event" ,
43+ "entity_type" : "corporate" ,
44+ "business_name" : "business name"
45+ }
46+ end
47+
48+ describe '#post' do
49+ it 'returns expected response' do
50+ stub_request ( :post , "#{ client . config . api_url } /#{ client . config . api_version } /merchants" ) . to_return (
51+ status : 200 , body : success_response . to_json
52+ )
53+
54+ payouts_api = described_class . new ( client )
55+ response = payouts_api . post ( params )
56+ expect ( response ) . to be_instance_of MidtransApi ::Model ::Merchant ::Create
57+ expect ( response . email ) . to eq ( success_response [ :email ] )
58+ end
59+ end
60+ end
0 commit comments