slidepay 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,6 @@ describe SlidePay::Payment do
10
10
  it "should include a root url" do
11
11
  expect(SlidePay::Payment.url_root).to eq("payment")
12
12
  end
13
-
14
13
  end
15
14
 
16
15
  it "should have an id_attribute" do
@@ -63,6 +62,32 @@ describe SlidePay::Payment do
63
62
  end
64
63
  end
65
64
 
65
+ describe "is_settled" do
66
+ it "should return false for a payment whose provider_capture_state is not 'Captured'" do
67
+ SlidePay.should_receive(:get).and_return(a_response_object(uncaptured_payment_response))
68
+ p = SlidePay::Payment.new({ "payment_id" => 1 })
69
+ p.retrieve()
70
+ expect(p.is_settled?).to eq(false)
71
+ end
72
+ it "should return false for a payment with no settlement_transaction_token GUID" do
73
+ SlidePay.should_receive(:get).and_return(a_response_object(unsettled_payment_response))
74
+ p = SlidePay::Payment.new({ "payment_id" => 1 })
75
+ p.retrieve()
76
+ expect(p.is_settled?).to eq(false)
77
+ end
78
+ it "should return true if both of the above are false" do
79
+ SlidePay.should_receive(:get).and_return(a_response_object(settled_payment_response))
80
+ p = SlidePay::Payment.new({ "payment_id" => 1 })
81
+ p.retrieve()
82
+ expect(p.is_settled?).to eq(true)
83
+ end
84
+ it "should raise an error if the payment has not yet been retrieved, or is_new?" do
85
+ # SlidePay.should_receive(:get).and_return(a_response_object(_payment_response))
86
+ p = SlidePay::Payment.new()
87
+ expect { p.is_settled? }.to raise_error
88
+ end
89
+ end
90
+
66
91
  describe "process" do
67
92
  it "should set the payment_id and the order_master_id on success" do
68
93
  SlidePay.stub(:post) { a_response_object(successful_payment_response) }
@@ -59,6 +59,28 @@ def object_from_response(json)
59
59
  MultiJson.decode(json)
60
60
  end
61
61
 
62
+ def failed_ach_retreival_response
63
+ <<-eos
64
+ {
65
+ "custom" : null,
66
+ "method" : "POST",
67
+ "operation" : "POST retrieval manual",
68
+ "id" : 0,
69
+ "milliseconds" : "184.58",
70
+ "obj" : null,
71
+ "success" : false,
72
+ "timezone" : "",
73
+ "endpoint" : "https://dev.getcube.com:65532",
74
+ "data" : {
75
+ "error_code" : "92",
76
+ "error_text" : "Unable to process transaction. This transaction would cause you to exceed your weekly ACH retrieval limit.",
77
+ "error_file" : "l_post_manual_retrieval.cs"
78
+ },
79
+ "data_md5" : "BD6F9EBF0801734DE1148116C491ECEF"
80
+ }
81
+ eos
82
+ end
83
+
62
84
 
63
85
  def successful_deletion_response
64
86
  <<-eos
@@ -362,7 +384,6 @@ def payment_search_response
362
384
  eos
363
385
  end
364
386
 
365
-
366
387
  def bank_account_array_response
367
388
  <<-eos
368
389
  {
@@ -492,6 +513,277 @@ def successful_payment_response
492
513
  eos
493
514
  end
494
515
 
516
+ def uncaptured_payment_response
517
+ <<-eos
518
+ {
519
+ "custom" : null,
520
+ "method" : "PUT",
521
+ "operation" : "PUT search payment",
522
+ "id" : 0,
523
+ "milliseconds" : "135.73",
524
+ "obj" : "payment",
525
+ "success" : true,
526
+ "timezone" : "",
527
+ "endpoint" : "https://dev.getcube.com:65532",
528
+ "data" : [
529
+ {
530
+ "under_review" : 0,
531
+ "cc_redacted_number" : "************1111",
532
+ "fee_total" : 0.34,
533
+ "latitude" : "37.33",
534
+ "cc_state" : "",
535
+ "provider_approval_code" : "000000",
536
+ "company_id" : 559,
537
+ "created" : "2014-01-20T17:58:49",
538
+ "settlement_transaction_token" : "",
539
+ "vendor_markup_pertrans" : 0,
540
+ "fee_interchange" : null,
541
+ "cc_track2data" : "",
542
+ "notes" : "Ski Boots",
543
+ "method_other" : "",
544
+ "cc_address_1" : "",
545
+ "total_time_ms" : null,
546
+ "vendor_markup_percent" : 0,
547
+ "cc_cvv2" : "",
548
+ "amount" : 1.32,
549
+ "provider_transaction_token" : "DummyTransaction",
550
+ "provider_payment_token" : "",
551
+ "provider_capture_state" : "DummyTransaction",
552
+ "cc_name_on_card" : "",
553
+ "provider_status_code" : "00",
554
+ "provider_transaction_state" : "Authorized",
555
+ "longitude" : "-121.94",
556
+ "signature_cloud_object_id" : null,
557
+ "cc_billing_zip" : "11111",
558
+ "cc_present" : 0,
559
+ "provider_is_approved" : "true",
560
+ "location_id" : 662,
561
+ "cc_type" : "Visa",
562
+ "cc_city" : "",
563
+ "provider" : "ipcommerce-cube-vantiv",
564
+ "cc_address_2" : "",
565
+ "ip_address" : "50.193.11.137",
566
+ "encryption_device_serial" : "",
567
+ "fee_per_transaction" : 0.3,
568
+ "customer_id" : 0,
569
+ "tip_amount" : 0,
570
+ "country" : "US",
571
+ "fee_percentage_amount" : 0.04,
572
+ "method" : "CreditCard",
573
+ "vendor_id" : "slidepay",
574
+ "encryption_vendor" : "",
575
+ "stored_payment_guid" : "978554c7-2994-442f-81ef-d7c6486da407",
576
+ "order_master_id" : 5146,
577
+ "is_refund" : null,
578
+ "provider_fee_amount" : 0,
579
+ "cc_expiry_month" : "11",
580
+ "fee_percentage" : 2.9,
581
+ "encryption_ksn" : "",
582
+ "cc_track1data" : "",
583
+ "cc_number" : "4111111111111111",
584
+ "cc_address_3" : "",
585
+ "is_chargeback" : 0,
586
+ "distance_from_location" : 8.8,
587
+ "processor_time_ms" : 0,
588
+ "cc_country" : "",
589
+ "user_master_id" : 689,
590
+ "auto_capture" : 1,
591
+ "cc_expiry_year" : "11",
592
+ "provider_status_message" : "Transaction Approved",
593
+ "refund_payment_id" : null,
594
+ "device_type" : "",
595
+ "last_update" : "2014-01-20T17:58:49",
596
+ "capture_confirmed" : null,
597
+ "payment_id" : 11784,
598
+ "capture_requested" : null,
599
+ "provider_capture_status_message" : ""
600
+ }
601
+ ]
602
+ }
603
+ eos
604
+ end
605
+
606
+ def unsettled_payment_response
607
+ <<-eos
608
+ {
609
+ "custom" : null,
610
+ "method" : "PUT",
611
+ "operation" : "PUT search payment",
612
+ "id" : 0,
613
+ "milliseconds" : "135.73",
614
+ "obj" : "payment",
615
+ "success" : true,
616
+ "timezone" : "",
617
+ "endpoint" : "https://dev.getcube.com:65532",
618
+ "data" : [
619
+ {
620
+ "under_review" : 0,
621
+ "cc_redacted_number" : "************1111",
622
+ "fee_total" : 0.34,
623
+ "latitude" : "37.33",
624
+ "cc_state" : "",
625
+ "provider_approval_code" : "000000",
626
+ "company_id" : 559,
627
+ "created" : "2014-01-20T17:58:49",
628
+ "settlement_transaction_token" : "",
629
+ "vendor_markup_pertrans" : 0,
630
+ "fee_interchange" : null,
631
+ "cc_track2data" : "",
632
+ "notes" : "Ski Boots",
633
+ "method_other" : "",
634
+ "cc_address_1" : "",
635
+ "total_time_ms" : null,
636
+ "vendor_markup_percent" : 0,
637
+ "cc_cvv2" : "",
638
+ "amount" : 1.32,
639
+ "provider_transaction_token" : "DummyTransaction",
640
+ "provider_payment_token" : "",
641
+ "provider_capture_state" : "DummyTransaction",
642
+ "cc_name_on_card" : "",
643
+ "provider_status_code" : "00",
644
+ "provider_transaction_state" : "Authorized",
645
+ "longitude" : "-121.94",
646
+ "signature_cloud_object_id" : null,
647
+ "cc_billing_zip" : "11111",
648
+ "cc_present" : 0,
649
+ "provider_is_approved" : "true",
650
+ "location_id" : 662,
651
+ "cc_type" : "Visa",
652
+ "cc_city" : "",
653
+ "provider" : "ipcommerce-cube-vantiv",
654
+ "cc_address_2" : "",
655
+ "ip_address" : "50.193.11.137",
656
+ "encryption_device_serial" : "",
657
+ "fee_per_transaction" : 0.3,
658
+ "customer_id" : 0,
659
+ "tip_amount" : 0,
660
+ "country" : "US",
661
+ "fee_percentage_amount" : 0.04,
662
+ "method" : "CreditCard",
663
+ "vendor_id" : "slidepay",
664
+ "encryption_vendor" : "",
665
+ "stored_payment_guid" : "978554c7-2994-442f-81ef-d7c6486da407",
666
+ "order_master_id" : 5146,
667
+ "is_refund" : null,
668
+ "provider_fee_amount" : 0,
669
+ "cc_expiry_month" : "11",
670
+ "fee_percentage" : 2.9,
671
+ "encryption_ksn" : "",
672
+ "cc_track1data" : "",
673
+ "cc_number" : "4111111111111111",
674
+ "cc_address_3" : "",
675
+ "is_chargeback" : 0,
676
+ "distance_from_location" : 8.8,
677
+ "processor_time_ms" : 0,
678
+ "cc_country" : "",
679
+ "user_master_id" : 689,
680
+ "auto_capture" : 1,
681
+ "cc_expiry_year" : "11",
682
+ "provider_status_message" : "Transaction Approved",
683
+ "refund_payment_id" : null,
684
+ "device_type" : "",
685
+ "last_update" : "2014-01-20T17:58:49",
686
+ "capture_confirmed" : null,
687
+ "payment_id" : 11784,
688
+ "capture_requested" : null,
689
+ "provider_capture_status_message" : ""
690
+ }
691
+ ]
692
+ }
693
+ eos
694
+ end
695
+
696
+ def settled_payment_response
697
+ <<-eos
698
+ {
699
+ "custom" : null,
700
+ "method" : "PUT",
701
+ "operation" : "PUT search payment",
702
+ "id" : 0,
703
+ "milliseconds" : "135.73",
704
+ "obj" : "payment",
705
+ "success" : true,
706
+ "timezone" : "",
707
+ "endpoint" : "https://dev.getcube.com:65532",
708
+ "data" : [
709
+ {
710
+ "under_review" : 0,
711
+ "cc_redacted_number" : "************1111",
712
+ "fee_total" : 0.04,
713
+ "latitude" : "37.3276089784472",
714
+ "cc_state" : "",
715
+ "provider_approval_code" : "046123",
716
+ "company_id" : 12,
717
+ "created" : "2014-01-13T21:40:33",
718
+ "settlement_transaction_token" : "2d88ce9b-d8d4-477e-8177-41573baefbf0",
719
+ "vendor_markup_pertrans" : 0,
720
+ "fee_interchange" : null,
721
+ "cc_track2data" : "",
722
+ "notes" : "Custom",
723
+ "method_other" : "",
724
+ "cc_address_1" : "",
725
+ "total_time_ms" : 5399,
726
+ "vendor_markup_percent" : 0,
727
+ "cc_cvv2" : "",
728
+ "amount" : 1,
729
+ "provider_transaction_token" : "2521989576C240DD92E3DEA50E83B59A",
730
+ "provider_payment_token" : "",
731
+ "provider_capture_state" : "Captured",
732
+ "cc_name_on_card" : "",
733
+ "provider_status_code" : "00",
734
+ "provider_transaction_state" : "Authorized",
735
+ "longitude" : "-121.8869275811915",
736
+ "signature_cloud_object_id" : null,
737
+ "cc_billing_zip" : "20015",
738
+ "cc_present" : 0,
739
+ "provider_is_approved" : "true",
740
+ "location_id" : 285,
741
+ "cc_type" : "Visa",
742
+ "cc_city" : "",
743
+ "provider" : "ipcommerce-cube-vantiv",
744
+ "cc_address_2" : "",
745
+ "ip_address" : "174.240.0.128",
746
+ "encryption_device_serial" : "",
747
+ "fee_per_transaction" : 0,
748
+ "customer_id" : 0,
749
+ "tip_amount" : 0,
750
+ "country" : "US",
751
+ "fee_percentage_amount" : 0.04,
752
+ "method" : "CreditCard",
753
+ "vendor_id" : "cube",
754
+ "encryption_vendor" : "",
755
+ "stored_payment_guid" : "ec1866d1-e909-4882-bac5-19ff7f396782",
756
+ "order_master_id" : 5054,
757
+ "is_refund" : null,
758
+ "provider_fee_amount" : 0.04,
759
+ "cc_expiry_month" : "04",
760
+ "fee_percentage" : 3.5,
761
+ "encryption_ksn" : "",
762
+ "cc_track1data" : "",
763
+ "cc_number" : "4111111111111111",
764
+ "cc_address_3" : "",
765
+ "is_chargeback" : 0,
766
+ "distance_from_location" : 11.54,
767
+ "processor_time_ms" : 3093.55,
768
+ "cc_country" : "",
769
+ "user_master_id" : 12,
770
+ "auto_capture" : 1,
771
+ "cc_expiry_year" : "12",
772
+ "provider_status_message" : "Transaction Approved",
773
+ "refund_payment_id" : null,
774
+ "device_type" : "iphone-cct",
775
+ "last_update" : "2014-01-17T21:00:00",
776
+ "capture_confirmed" : "2014-01-15T20:30:03",
777
+ "payment_id" : 11123,
778
+ "capture_requested" : "2014-01-14T20:00:02",
779
+ "provider_capture_status_message" : ""
780
+ }
781
+ ]
782
+ }
783
+ eos
784
+ end
785
+
786
+
495
787
  def failed_payment_response
496
788
  <<-eos
497
789
  {
@@ -569,4 +861,235 @@ def failed_token_response
569
861
  "data_md5": null
570
862
  }
571
863
  eos
864
+ end
865
+
866
+ def successful_retrieval_retrieve_response
867
+ <<-eos
868
+ {
869
+ "custom" : null,
870
+ "method" : "GET",
871
+ "operation" : "GET retrieval",
872
+ "id" : 0,
873
+ "milliseconds" : "31.25",
874
+ "obj" : "retrieval",
875
+ "success" : true,
876
+ "timezone" : "",
877
+ "endpoint" : "https://dev.getcube.com:65532",
878
+ "data" : [
879
+ {
880
+ "user_master_id" : 661,
881
+ "provider_status" : "APPROVED",
882
+ "bank_account_city" : "Athens",
883
+ "provider_capture_state" : "NotApplicable",
884
+ "last_update" : "2014-01-16T21:39:36",
885
+ "retrieval_id" : 4,
886
+ "created" : "2014-01-16T21:39:35",
887
+ "provider_status_message" : "P21:NO NEG REPORTS",
888
+ "company_id" : 18,
889
+ "bank_account_routing_number" : "123123123",
890
+ "ledgered" : 0,
891
+ "provider_status_code" : "A01",
892
+ "bank_account_last_name" : "Pants",
893
+ "bank_account_account_number" : "1231231234",
894
+ "bank_account_address_2" : "",
895
+ "net_amount" : 1.01,
896
+ "retrieval_amount" : 1.01,
897
+ "settlement_transaction_token" : "B41BB60D-942C-46DB-99F8-D3308F3ECA3D",
898
+ "provider" : "payments-gateway-ach",
899
+ "location_id" : 622,
900
+ "bank_account_state" : "TN",
901
+ "bank_account_company_name" : "",
902
+ "ledger_after" : "2014-01-16T21:39:35",
903
+ "ledger_guid" : "c7282787-b533-41bd-bdf0-a2847681ccee",
904
+ "bank_account_id" : 167,
905
+ "bank_account_country" : "USA",
906
+ "bank_account_address_1" : "Linkin Park",
907
+ "bank_account_postal_code" : "37303",
908
+ "bank_account_phone" : "1231231234",
909
+ "provider_transaction_state" : "NotApplicable",
910
+ "bank_account_phone_country_code" : "1",
911
+ "bank_account_type" : "Personal Checking",
912
+ "notes" : "",
913
+ "bank_account_first_name" : "Nerd",
914
+ "fee_amount" : 0
915
+ }
916
+ ],
917
+ "data_md5" : "EDAA3A294B8298FC342468CD78E34A98"
918
+ }
919
+ eos
920
+ end
921
+
922
+ def successful_retrieval_response
923
+ <<-eos
924
+ {
925
+ "custom" : null,
926
+ "method" : "POST",
927
+ "operation" : "POST retrieval manual",
928
+ "id" : 0,
929
+ "milliseconds" : "1235.30",
930
+ "obj" : null,
931
+ "success" : true,
932
+ "timezone" : "",
933
+ "endpoint" : "https://dev.getcube.com:65532",
934
+ "data" : {
935
+ "settlement_id" : 210,
936
+ "provider_status_code" : "A01",
937
+ "provider_status_message" : "P21:NO NEG REPORTS",
938
+ "provider" : "payments-gateway-ach",
939
+ "account_number" : "1231231234",
940
+ "amount" : 1.01,
941
+ "company_id" : 18,
942
+ "provider_transaction_state" : "NotApplicable",
943
+ "location_id" : 622,
944
+ "settlement_transaction_token" : "B41BB60D-942C-46DB-99F8-D3308F3ECA3D",
945
+ "routing_number" : "123123123",
946
+ "provider_capture_state" : "NotApplicable",
947
+ "provider_status" : "APPROVED",
948
+ "is_approved" : true
949
+ },
950
+ "data_md5" : "E3C91AA3D9C1C902492C2FBDE4F3C897"
951
+ }
952
+ eos
953
+ end
954
+
955
+ def failed_retrieval_response
956
+ <<-eos
957
+ {
958
+ "custom" : null,
959
+ "method" : "POST",
960
+ "operation" : "POST retrieval manual",
961
+ "id" : 0,
962
+ "milliseconds" : "147.47",
963
+ "obj" : null,
964
+ "success" : false,
965
+ "timezone" : "",
966
+ "endpoint" : "https://dev.getcube.com:65532",
967
+ "data" : {
968
+ "error_code" : "91",
969
+ "error_text" : "Unable to process request. Could not create retrieval record for ACH retrieval request.",
970
+ "error_file" : "l_post_manual_retrieval.cs"
971
+ },
972
+ "data_md5" : "FBB8D5D13D7B2B1BCBB85E061300902B"
973
+ }
974
+ eos
975
+ end
976
+
977
+ def ledgered_retrieval_object
978
+ {
979
+ "user_master_id" => 264,
980
+ "provider_status" => "APPROVED",
981
+ "bank_account_city" => "San Jose",
982
+ "provider_capture_state" => "NotApplicable",
983
+ "last_update" => "2013-12-14T20:15:00",
984
+ "retrieval_id" => 3,
985
+ "created" => "2013-12-12T19:47:50",
986
+ "provider_status_message" => "P70=>VALIDATED",
987
+ "company_id" => 182,
988
+ "bank_account_routing_number" => "123123123",
989
+ "ledgered" => 1,
990
+ "provider_status_code" => "A01",
991
+ "bank_account_last_name" => "Booster",
992
+ "bank_account_account_number" => "124124124",
993
+ "bank_account_address_2" => "",
994
+ "net_amount" => 4.75,
995
+ "retrieval_amount" => 5,
996
+ "settlement_transaction_token" => "C886B532-1564-498A-B5E6-CDE7D61111FB",
997
+ "provider" => "payments-gateway-ach",
998
+ "location_id" => 254,
999
+ "bank_account_state" => "CA",
1000
+ "bank_account_company_name" => "",
1001
+ "ledger_after" => "2013-12-14T19:47:50",
1002
+ "ledger_guid" => "88dc0bc9-d8b1-4da3-b085-2ac1d609cdc5",
1003
+ "bank_account_id" => 0,
1004
+ "bank_account_country" => "USA",
1005
+ "bank_account_address_1" => "123 dummy st",
1006
+ "bank_account_postal_code" => "12345",
1007
+ "bank_account_phone" => "1231231234",
1008
+ "provider_transaction_state" => "NotApplicable",
1009
+ "bank_account_phone_country_code" => "1",
1010
+ "bank_account_type" => "Personal Checking",
1011
+ "notes" => "Test!",
1012
+ "bank_account_first_name" => "Bobby",
1013
+ "fee_amount" => 0.25
1014
+ }
1015
+ end
1016
+
1017
+ def unledgered_retrieval_object
1018
+ {
1019
+ "user_master_id" => 264,
1020
+ "provider_status" => "APPROVED",
1021
+ "bank_account_city" => "San Jose",
1022
+ "provider_capture_state" => "NotApplicable",
1023
+ "last_update" => "2013-12-14T20:15:00",
1024
+ "retrieval_id" => 3,
1025
+ "created" => "2013-12-12T19:47:50",
1026
+ "provider_status_message" => "P70=>VALIDATED",
1027
+ "company_id" => 182,
1028
+ "bank_account_routing_number" => "123123123",
1029
+ "ledgered" => 0,
1030
+ "provider_status_code" => "A01",
1031
+ "bank_account_last_name" => "Booster",
1032
+ "bank_account_account_number" => "124124124",
1033
+ "bank_account_address_2" => "",
1034
+ "net_amount" => 4.75,
1035
+ "retrieval_amount" => 5,
1036
+ "settlement_transaction_token" => "C886B532-1564-498A-B5E6-CDE7D61111FB",
1037
+ "provider" => "payments-gateway-ach",
1038
+ "location_id" => 254,
1039
+ "bank_account_state" => "CA",
1040
+ "bank_account_company_name" => "",
1041
+ "ledger_after" => "2013-12-14T19:47:50",
1042
+ "ledger_guid" => "88dc0bc9-d8b1-4da3-b085-2ac1d609cdc5",
1043
+ "bank_account_id" => 0,
1044
+ "bank_account_country" => "USA",
1045
+ "bank_account_address_1" => "123 dummy st",
1046
+ "bank_account_postal_code" => "12345",
1047
+ "bank_account_phone" => "1231231234",
1048
+ "provider_transaction_state" => "NotApplicable",
1049
+ "bank_account_phone_country_code" => "1",
1050
+ "bank_account_type" => "Personal Checking",
1051
+ "notes" => "Test!",
1052
+ "bank_account_first_name" => "Bobby",
1053
+ "fee_amount" => 0.25
1054
+ }
1055
+ end
1056
+
1057
+ def failed_balance_response
1058
+ <<-eos
1059
+ {
1060
+ "custom" : null,
1061
+ "method" : "POST",
1062
+ "operation" : "POST settlement balance",
1063
+ "id" : 0,
1064
+ "milliseconds" : "13.67",
1065
+ "obj" : null,
1066
+ "success" : false,
1067
+ "timezone" : "",
1068
+ "endpoint" : "https://dev.getcube.com:65532",
1069
+ "data" : {
1070
+ "error_code" : "1",
1071
+ "error_text" : "The requested object was not found.",
1072
+ "error_file" : "l_post_settlement_balance.cs"
1073
+ },
1074
+ "data_md5" : "05DAC0B9E77750348A4A529E7615C054"
1075
+ }
1076
+ eos
1077
+ end
1078
+
1079
+ def successful_balance_response
1080
+ <<-eos
1081
+ {
1082
+ "custom" : null,
1083
+ "method" : "POST",
1084
+ "operation" : "POST settlement balance",
1085
+ "id" : 622,
1086
+ "milliseconds" : "173.83",
1087
+ "obj" : null,
1088
+ "success" : true,
1089
+ "timezone" : "",
1090
+ "endpoint" : "https://dev.getcube.com:65532",
1091
+ "data" : 15.00,
1092
+ "data_md5" : "F7DDD489AB0A82567B241B05971CBDB3"
1093
+ }
1094
+ eos
572
1095
  end