Created
April 4, 2025 15:22
-
-
Save slicksammy/51dcb0be75a0e963216e48d16e40a144 to your computer and use it in GitHub Desktop.
same event twice
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rails_helper' | |
| RSpec.describe ExternalEvents::FinixPlatformController, type: :controller do | |
| let!(:business) { create(:business) } | |
| let!(:business_customer) { create(:business_customer, business: business) } | |
| let!(:checkout) { create(:checkout, business: business, business_customer: business_customer) } | |
| let!(:payment_intent) { create(:payment_intent, :with_charge, checkout: checkout, business: business, business_customer: business_customer) } | |
| let!(:charge) { payment_intent.charges.first } | |
| let(:succeeded_event_type) { "SUCCEEDED" } | |
| describe "POST #create" do | |
| before do | |
| assert(Platform::Payments::Interface.get_charge(charge_id: charge.id)[:status] == "created") | |
| end | |
| it "can send the same event twice, should not be an error" do | |
| event = new_event(succeeded_event_type, true) | |
| post :create, params: { business_id: business.id }, body: event.to_json, format: :json | |
| expect(response).to have_http_status(:success) | |
| post :create, params: { business_id: business.id }, body: event.to_json, format: :json | |
| expect(response).to have_http_status(:success) | |
| # only 1 event created in our system | |
| expect(ExternalEvent.count).to eq(1) | |
| end | |
| end | |
| def new_event(state, og) | |
| { | |
| "id": "event_4LYWNwHMAZqQ8cNVvnm5hM", | |
| "system_generated_idempotency_id": "4LYWNwHMAZqQ8cNVvnm5hM", | |
| "type": "updated", | |
| "entity": "transfer", | |
| "occurred_at": "2025-04-01T14:36:04.716203351", | |
| "_embedded": { | |
| "transfers": [ | |
| { | |
| "fee_profile": "FPmtT4MYmiAs1qjLjneQmk4d", | |
| "fee": 0, | |
| "operation_key": "CARD_NOT_PRESENT_SALE", | |
| "receipt_last_printed_at": nil, | |
| "destination": nil, | |
| "created_at": "2025-04-01T14:35:32.66Z", | |
| "additional_purchase_data": nil, | |
| "failure_message": nil, | |
| "source": "PIjpPbry73qKXSzpytuAddCx", | |
| "type": "DEBIT", | |
| "additional_buyer_charges": nil, | |
| "statement_descriptor": "FLX*FLEX", | |
| "additional_healthcare_data": nil, | |
| "updated_at": "2025-04-01T14:36:04.27Z", | |
| "subtype": "API", | |
| "amount_requested": 2500, | |
| "parent_transfer_trace_id": nil, | |
| "currency": "USD", | |
| "id": "TRiV47cH8FTYW6AkU9HPp55c", | |
| "state": state, | |
| "split_transfers": [], | |
| "parent_transfer": og ? nil : 'TRABC', | |
| "idempotency_id": charge.charge_id, | |
| "amount": 2500, | |
| "failure_code": nil, | |
| "trace_id": "8fae6fea-fb5e-450c-b0d1-5645e149ca26", | |
| "address_verification": nil, | |
| "security_code_verification": nil, | |
| "merchant": "MUd3YsPpEp6HRXUXhL8xu3xV", | |
| "raw": nil, | |
| "merchant_identity": "IDowzvCieHhiP7NVKoufYftS", | |
| "tags": og ? { "charge_id": charge.charge_id} : {}, | |
| "ready_to_settle_at": "2025-04-02T14:36:04.33Z", | |
| "application": "AP3HhpJDxXLQaoF8LGA15UeT", | |
| "supplemental_fee": nil, | |
| "externally_funded": "UNKNOWN", | |
| "messages": [], | |
| "tip_amount": nil | |
| } | |
| ] | |
| } | |
| } | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment