Module: StripeMock::Data
- Defined in:
- lib/stripe_mock/data.rb,
lib/stripe_mock/data/list.rb
Defined Under Namespace
Classes: List
Class Method Summary collapse
- .mock_account(params = {}) ⇒ Object
- .mock_api_error ⇒ Object
- .mock_balance_transaction(params = {}) ⇒ Object
- .mock_balance_transactions(ids = []) ⇒ Object
- .mock_bank_account(params = {}) ⇒ Object
- .mock_bank_account_token(params = {}) ⇒ Object
- .mock_card(params = {}) ⇒ Object
- .mock_card_token(params = {}) ⇒ Object
- .mock_charge(params = {}) ⇒ Object
- .mock_charge_array ⇒ Object
- .mock_country_spec(country_code) ⇒ Object
- .mock_coupon(params = {}) ⇒ Object
- .mock_customer(sources, params) ⇒ Object
- .mock_delete_discount_response ⇒ Object
- .mock_delete_subscription(params = {}) ⇒ Object
- .mock_dispute(params = {}) ⇒ Object
- .mock_dispute_evidence ⇒ Object
- .mock_dispute_evidence_details ⇒ Object
- .mock_disputes(ids = []) ⇒ Object
- .mock_invalid_api_key_error ⇒ Object
- .mock_invalid_exp_year_error ⇒ Object
- .mock_invoice(lines, params = {}) ⇒ Object
- .mock_invoice_customer_array ⇒ Object
- .mock_invoice_item(params = {}) ⇒ Object
- .mock_line_item(params = {}) ⇒ Object
- .mock_list_object(data, params = {}) ⇒ Object
- .mock_missing_id_error ⇒ Object
- .mock_order(order_items, params) ⇒ Object
- .mock_order_item(params = {}) ⇒ Object
- .mock_paid_invoice ⇒ Object
- .mock_plan(params = {}) ⇒ Object
- .mock_recipient(cards, params = {}) ⇒ Object
- .mock_recipient_array ⇒ Object
- .mock_refund(params = {}) ⇒ Object
-
.mock_subscription(params = {}) ⇒ Object
FIXME nested overrides would be better than hardcoding plan_id.
- .mock_transfer(params = {}) ⇒ Object
- .mock_transfer_array ⇒ Object
Class Method Details
.mock_account(params = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/stripe_mock/data.rb', line 4 def self.mock_account(params = {}) id = params[:id] || 'acct_103ED82ePvKYlo2C' currency = params[:currency] || 'usd' { id: id, email: "[email protected]", statement_descriptor: nil, display_name: "Stripe.com", timezone: "US/Pacific", details_submitted: false, charges_enabled: false, transfers_enabled: false, currencies_supported: [ "usd" ], default_currency: currency, country: "US", object: "account", business_name: "Stripe.com", business_url: nil, support_phone: nil, managed: false, product_description: nil, debit_negative_balances: true, bank_accounts: { object: "list", total_count: 0, has_more: false, url: "/v1/accounts/#{id}/bank_accounts", data: [ ] }, verification: { fields_needed: [], due_by: nil, contacted: false }, transfer_schedule: { delay_days: 7, interval: "daily" }, tos_acceptance: { ip: nil, date: nil, user_agent: nil }, external_accounts: { object: "list", data: [ ], has_more: false, total_count: 0, url: "/v1/accounts/#{id}/external_accounts" }, legal_entity: { type: nil, business_name: nil, address: { line1: nil, line2: nil, city: nil, state: nil, postal_code: nil, country: "US" }, first_name: nil, last_name: nil, personal_address: { line1: nil, line2: nil, city: nil, state: nil, postal_code: nil, country: nil }, dob: { day: nil, month: nil, year: nil }, additional_owners: nil, verification: { status: "unverified", document: nil, details: nil } }, decline_charge_on: { cvc_failure: false, avs_failure: false }, keys: { secret: "sk_test_AmJhMTLPtY9JL4c6EG0", publishable: "pk_test_2rSaMTLPtY9JL449dsf" } }.merge(params) end |
.mock_api_error ⇒ Object
738 739 740 741 742 743 744 |
# File 'lib/stripe_mock/data.rb', line 738 def self.mock_api_error { :error => { :type => "api_error" } } end |
.mock_balance_transaction(params = {}) ⇒ Object
920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 |
# File 'lib/stripe_mock/data.rb', line 920 def self.mock_balance_transaction(params = {}) currency = params[:currency] || 'usd' bt_id = params[:id] || 'test_txn_default' source = params[:source] || 'ch_test_charge' { id: bt_id, object: "balance_transaction", amount: 10000, available_on: 1462406400, created: 1461880226, currency: currency, description: nil, fee: 320, fee_details: [ { amount: 320, application: nil, currency: currency, description: "Stripe processing fees", type: "stripe_fee" } ], net: 9680, source: source, sourced_transfers: { object: "list", data: [], has_more: false, total_count: 0, url: "/v1/transfers?source_transaction=#{source}" }, status: "pending", type: "charge" }.merge(params) end |
.mock_balance_transactions(ids = []) ⇒ Object
912 913 914 915 916 917 918 |
# File 'lib/stripe_mock/data.rb', line 912 def self.mock_balance_transactions(ids=[]) bts = {} ids.each do |id| bts[id] = self.mock_balance_transaction(id: id) end bts end |
.mock_bank_account(params = {}) ⇒ Object
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/stripe_mock/data.rb', line 249 def self.mock_bank_account(params={}) currency = params[:currency] || 'usd' { id: "test_ba_default", object: "bank_account", bank_name: "STRIPEMOCK TEST BANK", last4: "6789", routing_number: '110000000', country: "US", currency: currency, validated: false, status: 'new', account_holder_name: 'John Doe', account_holder_type: 'individual', fingerprint: "aBcFinGerPrINt123" }.merge(params) end |
.mock_bank_account_token(params = {}) ⇒ Object
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 |
# File 'lib/stripe_mock/data.rb', line 575 def self.mock_bank_account_token(params={}) { :id => 'tok_default', :livemode => false, :used => false, :object => 'token', :type => 'bank_account', :bank_account => { :id => 'bank_account_default', :object => 'bank_account', :last4 => '2222', :fingerprint => 'JRRLXGh38NiYygM7', } }.merge(params) end |
.mock_card(params = {}) ⇒ Object
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/stripe_mock/data.rb', line 222 def self.mock_card(params={}) StripeMock::Util.card_merge({ id: "test_cc_default", object: "card", last4: "4242", type: "Visa", brand: "Visa", funding: "credit", exp_month: 4, exp_year: 2016, fingerprint: "wXWJT135mEK107G8", customer: "test_cus_default", country: "US", name: "Johnny App", address_line1: nil, address_line2: nil, address_city: nil, address_state: nil, address_zip: nil, address_country: nil, cvc_check: nil, address_line1_check: nil, address_zip_check: nil, tokenization_method: nil }, params) end |
.mock_card_token(params = {}) ⇒ Object
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 |
# File 'lib/stripe_mock/data.rb', line 545 def self.mock_card_token(params={}) { :id => 'tok_default', :livemode => false, :used => false, :object => 'token', :type => 'card', :card => { :id => 'card_default', :object => 'card', :last4 => '2222', :type => 'Visa', :brand => 'Visa', :funding => 'credit', :exp_month => 9, :exp_year => 2017, :fingerprint => 'JRRLXGh38NiYygM7', :customer => nil, :country => 'US', :name => nil, :address_line1 => nil, :address_line2 => nil, :address_city => nil, :address_state => nil, :address_zip => nil, :address_country => nil } }.merge(params) end |
.mock_charge(params = {}) ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/stripe_mock/data.rb', line 135 def self.mock_charge(params={}) charge_id = params[:id] || "ch_1fD6uiR9FAA2zc" currency = params[:currency] || 'usd' { id: charge_id, object: "charge", created: 1366194027, livemode: false, paid: true, amount: 0, application_fee: nil, currency: currency, destination: nil, fraud_details: {}, receipt_email: nil, receipt_number: nil, refunded: false, shipping: {}, statement_descriptor: "Charge #{charge_id}", status: 'succeeded', source: { object: "card", last4: "4242", type: "Visa", brand: "Visa", funding: "credit", exp_month: 12, exp_year: 2013, fingerprint: "3TQGpK9JoY1GgXPw", country: "US", name: "name", address_line1: nil, address_line2: nil, address_city: nil, address_state: nil, address_zip: nil, address_country: nil, cvc_check: nil, address_line1_check: nil, address_zip_check: nil }, captured: params.has_key?(:capture) ? params.delete(:capture) : true, refunds: { object: "list", total_count: 0, has_more: false, url: "/v1/charges/#{charge_id}/refunds", data: [] }, transfer: nil, balance_transaction: "txn_2dyYXXP90MN26R", failure_message: nil, failure_code: nil, amount_refunded: 0, customer: nil, invoice: nil, description: nil, dispute: nil, metadata: { } }.merge(params) end |
.mock_charge_array ⇒ Object
214 215 216 217 218 219 220 |
# File 'lib/stripe_mock/data.rb', line 214 def self.mock_charge_array { :data => [test_charge, test_charge, test_charge], :object => 'list', :url => '/v1/charges' } end |
.mock_country_spec(country_code) ⇒ Object
758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 |
# File 'lib/stripe_mock/data.rb', line 758 def self.mock_country_spec(country_code) id = country_code || "US" { "id"=> "US", "object"=> "country_spec", "default_currency"=> "usd", "supported_bank_account_currencies"=> {"usd"=>["US"]}, "supported_payment_currencies"=> [ "usd", "aed", "afn", "all", "amd", "ang", "aoa", "ars", "aud", "awg", "azn", "bam", "bbd", "bdt", "bgn", "bif", "bmd", "bnd", "bob", "brl", "bsd", "bwp", "bzd", "cad", "cdf", "chf", "clp", "cny", "cop", "crc", "cve", "czk", "djf", "dkk", "dop", "dzd", "egp", "etb", "eur", "fjd", "fkp", "gbp", "gel", "gip", "gmd", "gnf", "gtq", "gyd", "hkd", "hnl", "hrk", "htg", "huf", "idr", "ils", "inr", "isk", "jmd", "jpy", "kes", "kgs", "khr", "kmf", "krw", "kyd", "kzt", "lak", "lbp", "lkr", "lrd", "lsl", "ltl", "mad", "mdl", "mga", "mkd", "mnt", "mop", "mro", "mur", "mvr", "mwk", "mxn", "myr", "mzn", "nad", "ngn", "nio", "nok", "npr", "nzd", "pab", "pen", "pgk", "php", "pkr", "pln", "pyg", "qar", "ron", "rsd", "rub", "rwf", "sar", "sbd", "scr", "sek", "sgd", "shp", "sll", "sos", "srd", "std", "svc", "szl", "thb", "tjs", "top", "try", "ttd", "twd", "tzs", "uah", "ugx", "uyu", "uzs", "vnd", "vuv", "wst", "xaf", "xcd", "xof", "xpf", "yer", "zar", "zmw" ], "supported_payment_methods"=> [ "alipay", "card", "stripe" ], "verification_fields"=> {"individual"=>{"minimum"=>["external_account","legal_entity.address.city","legal_entity.address.line1","legal_entity.address.postal_code","legal_entity.address.state","legal_entity.dob.day","legal_entity.dob.month","legal_entity.dob.year","legal_entity.first_name","legal_entity.last_name","legal_entity.personal_id_number","legal_entity.ssn_last_4","legal_entity.type","tos_acceptance.date","tos_acceptance.ip"],"additional"=>["legal_entity.personal_id_number","legal_entity.verification.document"]},"company"=>{"minimum"=>["external_account","legal_entity.address.city","legal_entity.address.line1","legal_entity.address.postal_code","legal_entity.address.state","legal_entity.business_name","legal_entity.business_tax_id","legal_entity.dob.day","legal_entity.dob.month","legal_entity.dob.year","legal_entity.first_name","legal_entity.last_name","legal_entity.ssn_last_4","legal_entity.type","tos_acceptance.date","tos_acceptance.ip"],"additional"=>["legal_entity.personal_id_number","legal_entity.verification.document"]}} } end |
.mock_coupon(params = {}) ⇒ Object
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/stripe_mock/data.rb', line 267 def self.mock_coupon(params={}) { :duration_in_months => 3, :percent_off => 25, :amount_off => nil, :currency => nil, :id => "co_test_coupon", :object => "coupon", :max_redemptions => nil, :redeem_by => nil, :times_redeemed => 0, :valid => true, :metadata => {}, }.merge(params) end |
.mock_customer(sources, params) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/stripe_mock/data.rb', line 104 def self.mock_customer(sources, params) cus_id = params[:id] || "test_cus_default" currency = params[:currency] || nil sources.each {|source| source[:customer] = cus_id} { email: '[email protected]', description: 'an auto-generated stripe customer data mock', object: "customer", created: 1372126710, id: cus_id, livemode: false, delinquent: false, discount: nil, account_balance: 0, currency: currency, sources: { object: "list", total_count: sources.size, url: "/v1/customers/#{cus_id}/sources", data: sources }, subscriptions: { object: "list", total_count: 0, url: "/v1/customers/#{cus_id}/subscriptions", data: [] }, default_source: nil }.merge(params) end |
.mock_delete_discount_response ⇒ Object
746 747 748 749 750 751 |
# File 'lib/stripe_mock/data.rb', line 746 def self.mock_delete_discount_response { :deleted => true, :id => "di_test_coupon" } end |
.mock_delete_subscription(params = {}) ⇒ Object
732 733 734 735 736 |
# File 'lib/stripe_mock/data.rb', line 732 def self.mock_delete_subscription(params={}) { deleted: true }.merge(params) end |
.mock_dispute(params = {}) ⇒ Object
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 |
# File 'lib/stripe_mock/data.rb', line 631 def self.mock_dispute(params={}) @timestamp ||= Time.now.to_i currency = params[:currency] || 'usd' id = params[:id] || "dp_test_dispute" { :id => id, :object => "dispute", :amount => 195, :balance_transactions => [], :charge => "ch_15RsQR2eZvKYlo2CA8IfzCX0", :created => @timestamp += 1, :currency => currency, :evidence => self.mock_dispute_evidence, :evidence_details => self.mock_dispute_evidence_details, :is_charge_refundable => false, :livemode => false, :metadata => {}, :reason => "general", :status => "under_review" }.merge(params) end |
.mock_dispute_evidence ⇒ Object
653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 |
# File 'lib/stripe_mock/data.rb', line 653 def self.mock_dispute_evidence { :access_activity_log => nil, :billing_address => nil, :cancellation_policy => nil, :cancellation_policy_disclosure => nil, :cancellation_rebuttal => nil, :customer_communication => nil, :customer_email_address => nil, :customer_name => nil, :customer_purchase_ip => nil, :customer_signature => nil, :duplicate_charge_documentation => nil, :duplicate_charge_explanation => nil, :duplicate_charge_id => nil, :product_description => nil, :receipt => nil, :refund_policy => nil, :refund_policy_disclosure => nil, :refund_refusal_explanation => nil, :service_date => nil, :service_documentation => nil, :shipping_address => nil, :shipping_carrier => nil, :shipping_date => nil, :shipping_documentation => nil, :shipping_tracking_number => nil, :uncategorized_file => nil, :uncategorized_text => nil } end |
.mock_dispute_evidence_details ⇒ Object
685 686 687 688 689 690 691 692 |
# File 'lib/stripe_mock/data.rb', line 685 def self.mock_dispute_evidence_details { :due_by => 1424303999, :has_evidence => false, :past_due => false, :submission_count => 0 } end |
.mock_disputes(ids = []) ⇒ Object
623 624 625 626 627 628 629 |
# File 'lib/stripe_mock/data.rb', line 623 def self.mock_disputes(ids=[]) disputes = {} ids.each do |id| disputes[id] = self.mock_dispute(id: id) end disputes end |
.mock_invalid_api_key_error ⇒ Object
702 703 704 705 706 707 708 709 |
# File 'lib/stripe_mock/data.rb', line 702 def self.mock_invalid_api_key_error { "error" => { "type" => "invalid_request_error", "message" => "Invalid API Key provided: invalid" } } end |
.mock_invalid_exp_year_error ⇒ Object
711 712 713 714 715 716 717 718 719 720 |
# File 'lib/stripe_mock/data.rb', line 711 def self.mock_invalid_exp_year_error { "error" => { "code" => "invalid_expiry_year", "param" => "exp_year", "type" => "card_error", "message" => "Your card's expiration year is invalid" } } end |
.mock_invoice(lines, params = {}) ⇒ Object
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 |
# File 'lib/stripe_mock/data.rb', line 327 def self.mock_invoice(lines, params={}) in_id = params[:id] || "test_in_default" currency = params[:currency] || 'usd' lines << Data.mock_line_item() if lines.empty? invoice = { id: 'in_test_invoice', date: 1349738950, period_end: 1349738950, period_start: 1349738950, lines: { object: "list", total_count: lines.count, url: "/v1/invoices/#{in_id}/lines", data: lines }, subtotal: lines.map {|line| line[:amount]}.reduce(0, :+), customer: "test_customer", object: 'invoice', attempted: false, application_fee: nil, closed: false, description: nil, forgiven: false, metadata: {}, paid: false, receipt_number: nil, statement_descriptor: nil, tax: nil, tax_percent: nil, webhooks_delivered_at: 1349825350, livemode: false, attempt_count: 0, amount_due: nil, currency: currency, starting_balance: 0, ending_balance: nil, next_payment_attempt: 1349825350, charge: nil, discount: nil, subscription: nil }.merge(params) if invoice[:discount] invoice[:total] = [0, invoice[:subtotal] - invoice[:discount][:coupon][:amount_off]].max if invoice[:discount][:coupon][:amount_off] invoice[:total] = invoice[:subtotal] * invoice[:discount][:coupon][:percent_off] / 100 if invoice[:discount][:coupon][:percent_off] else invoice[:total] = invoice[:subtotal] end due = invoice[:total] + invoice[:starting_balance] invoice[:amount_due] = due < 0 ? 0 : due invoice end |
.mock_invoice_customer_array ⇒ Object
432 433 434 435 436 437 438 |
# File 'lib/stripe_mock/data.rb', line 432 def self.mock_invoice_customer_array { :data => [test_invoice], :object => 'list', :url => '/v1/invoices?customer=test_customer' } end |
.mock_invoice_item(params = {}) ⇒ Object
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
# File 'lib/stripe_mock/data.rb', line 402 def self.mock_invoice_item(params = {}) currency = params[:currency] || 'usd' { id: "test_ii", object: "invoiceitem", date: 1349738920, amount: 1099, livemode: false, proration: false, currency: currency, customer: "cus_test", description: "invoice item desc", metadata: {}, invoice: nil, subscription: nil }.merge(params) end |
.mock_line_item(params = {}) ⇒ Object
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
# File 'lib/stripe_mock/data.rb', line 379 def self.mock_line_item(params = {}) currency = params[:currency] || 'usd' { id: "ii_test", object: "line_item", type: "invoiceitem", livemode: false, amount: 1000, currency: currency, discountable: false, proration: false, period: { start: 1349738920, end: 1349738920 }, quantity: nil, subscription: nil, plan: nil, description: "Test invoice item", metadata: {} }.merge(params) end |
.mock_list_object(data, params = {}) ⇒ Object
753 754 755 756 |
# File 'lib/stripe_mock/data.rb', line 753 def self.mock_list_object(data, params={}) list = StripeMock::Data::List.new(data, params) list.to_h end |
.mock_missing_id_error ⇒ Object
722 723 724 725 726 727 728 729 730 |
# File 'lib/stripe_mock/data.rb', line 722 def self.mock_missing_id_error { :error => { :param => "id", :type => "invalid_request_error", :message => "Missing id" } } end |
.mock_order(order_items, params) ⇒ Object
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
# File 'lib/stripe_mock/data.rb', line 440 def self.mock_order(order_items, params) or_id = params[:id] || "test_or_default" currency = params[:currency] || 'eur' order_items << Data.mock_order_item if order_items.empty? { id: or_id, object: "order", amount: 5000, application: nil, application_fee: nil, charge: nil, created: 1448272783, currency: currency, customer: nil, email: nil, items: order_items, livemode: false, metadata: {}, selected_shipping_method: nil, shipping: { address: { city: "Anytown", country: "US", line1: "1234 Main street", line2: nil, postal_code: "123456", state: nil }, name: "Jenny Rosen", phone: nil }, shipping_methods: nil, status: "created", updated: 1448272783 }.merge(params) end |
.mock_order_item(params = {}) ⇒ Object
477 478 479 480 481 482 483 484 485 486 487 488 |
# File 'lib/stripe_mock/data.rb', line 477 def self.mock_order_item(params={}) currency = params[:currency] || 'eur' { object: "order_item", amount: 5000, currency: currency, description: "Anyitem", parent: "sku_parent", quantity: 1, type: "sku" }.merge(params) end |
.mock_paid_invoice ⇒ Object
420 421 422 423 424 425 426 427 428 429 430 |
# File 'lib/stripe_mock/data.rb', line 420 def self.mock_paid_invoice test_invoice.merge({ :attempt_count => 1, :attempted => true, :closed => true, :paid => true, :charge => 'ch_test_charge', :ending_balance => 0, :next_payment_attempt => nil, }) end |
.mock_plan(params = {}) ⇒ Object
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 |
# File 'lib/stripe_mock/data.rb', line 490 def self.mock_plan(params={}) currency = params[:currency] || 'usd' { id: "2", object: "plan", amount: 2300, created: 1466698898, currency: currency, interval: "month", interval_count: 1, livemode: false, metadata: {}, name: "The Basic Plan", statement_descriptor: nil, trial_period_days: nil }.merge(params) end |
.mock_recipient(cards, params = {}) ⇒ Object
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
# File 'lib/stripe_mock/data.rb', line 508 def self.mock_recipient(cards, params={}) rp_id = params[:id] || "test_rp_default" cards.each {|card| card[:recipient] = rp_id} { name: "Stripe User", type: "individual", livemode: false, object: "recipient", id: rp_id, active_account: { last4: "6789", bank_name: "STRIPE TEST BANK", country: "US", object: "bank_account" }, created: 1304114758, verified: true, metadata: { }, cards: { object: "list", url: "/v1/recipients/#{rp_id}/cards", data: cards, total_count: cards.count }, default_card: nil }.merge(params) end |
.mock_recipient_array ⇒ Object
537 538 539 540 541 542 543 |
# File 'lib/stripe_mock/data.rb', line 537 def self.mock_recipient_array { :data => [test_recipient, test_recipient, test_recipient], :object => 'list', :url => '/v1/recipients' } end |
.mock_refund(params = {}) ⇒ Object
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/stripe_mock/data.rb', line 198 def self.mock_refund(params={}) currency = params[:currency] || 'usd' { id: "re_4fWhgUh5si7InF", amount: 1, currency: currency, created: 1409165988, object: "refund", balance_transaction: "txn_4fWh2RKvgxcXqV", metadata: {}, charge: "ch_4fWhYjzQ23UFWT", receipt_number: nil, status: "succeeded" }.merge(params) end |
.mock_subscription(params = {}) ⇒ Object
FIXME nested overrides would be better than hardcoding plan_id
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/stripe_mock/data.rb', line 284 def self.mock_subscription(params={}) StripeMock::Util.rmerge({ created: 1478204116, current_period_start: 1308595038, current_period_end: 1308681468, status: 'trialing', plan: { interval: 'month', amount: 7500, trial_period_days: 30, object: 'plan', id: '__test_plan_id__' }, items: { object: 'list', data: [{ id: 'si_1AwFf62eZvKYlo2C9u6Dhf9', created: 1504035973, metadata: {}, object: 'subscription_item', plan: { amount: 999, created: 1504035972, currency: 'usd' }, quantity: 1 }] }, cancel_at_period_end: false, canceled_at: nil, ended_at: nil, start: 1308595038, object: 'subscription', trial_start: 1308595038, trial_end: 1308681468, customer: 'c_test_customer', quantity: 1, tax_percent: nil, discount: nil, metadata: {} }, params) end |
.mock_transfer(params = {}) ⇒ Object
591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 |
# File 'lib/stripe_mock/data.rb', line 591 def self.mock_transfer(params={}) currency = params[:currency] || 'usd' id = params[:id] || 'tr_test_transfer' { :status => 'pending', :amount => 100, :account => { :object => 'bank_account', :country => 'US', :bank_name => 'STRIPE TEST BANK', :last4 => '6789' }, :recipient => 'test_recipient', :fee => 0, :fee_details => [], :id => id, :livemode => false, :metadata => {}, :currency => currency, :object => "transfer", :date => 1304114826, :description => "Transfer description", :reversed => false, :reversals => { :object => "list", :total_count => 0, :has_more => false, :url => "/v1/transfers/#{id}/reversals" }, }.merge(params) end |
.mock_transfer_array ⇒ Object
694 695 696 697 698 699 700 |
# File 'lib/stripe_mock/data.rb', line 694 def self.mock_transfer_array { :data => [test_transfer, test_transfer, test_transfer], :object => 'list', :url => '/v1/transfers' } end |