forked from blacklightcms/recurly
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add transaction status updated webhook (blacklightcms#145)
- Loading branch information
Showing
4 changed files
with
74 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
31 changes: 31 additions & 0 deletions
31
webhooks/testdata/transaction_status_updated_notification.xml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<transaction_status_updated_notification> | ||
<account> | ||
<account_code>1</account_code> | ||
<username nil="true">verena</username> | ||
<email>[email protected]</email> | ||
<first_name>Verena</first_name> | ||
<last_name>Example</last_name> | ||
<company_name nil="true">Company, Inc.</company_name> | ||
</account> | ||
<transaction> | ||
<id>a5143c1d3a6f4a8287d0e2cc1d4c0427</id> | ||
<invoice_id>ffc64d71d4b5404e93f13aac9c63b007</invoice_id> | ||
<invoice_number type="integer">2059</invoice_number> | ||
<subscription_id>1974a098jhlkjasdfljkha898326881c</subscription_id> | ||
<action>purchase</action> | ||
<date type="datetime">2010-10-05T23:00:50Z</date> | ||
<amount_in_cents type="integer">1000</amount_in_cents> | ||
<status>void</status> | ||
<message>Test Gateway: Successful test transaction</message> | ||
<reference>reference</reference> | ||
<source>subscription</source> | ||
<cvv_result code="" /> | ||
<avs_result code="" /> | ||
<avs_result_street /> | ||
<avs_result_postal /> | ||
<test type="boolean">true</test> | ||
<voidable type="boolean">true</voidable> | ||
<refundable type="boolean">true</refundable> | ||
</transaction> | ||
</transaction_status_updated_notification> |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -814,6 +814,41 @@ func TestParse_ScheduledPaymentNotification(t *testing.T) { | |
} | ||
} | ||
|
||
func TestParse_TransactionStatusUpdatedNotification(t *testing.T) { | ||
result := MustParseFile("testdata/transaction_status_updated_notification.xml") | ||
if n, ok := result.(*webhooks.PaymentNotification); !ok { | ||
t.Fatalf("unexpected type: %T, result", n) | ||
} else if diff := cmp.Diff(n, &webhooks.PaymentNotification{ | ||
Type: webhooks.TransactionStatusUpdated, | ||
Account: webhooks.Account{ | ||
XMLName: xml.Name{Local: "account"}, | ||
Code: "1", | ||
Username: "verena", | ||
Email: "[email protected]", | ||
FirstName: "Verena", | ||
LastName: "Example", | ||
CompanyName: "Company, Inc.", | ||
}, | ||
Transaction: webhooks.Transaction{ | ||
XMLName: xml.Name{Local: "transaction"}, | ||
UUID: "a5143c1d3a6f4a8287d0e2cc1d4c0427", | ||
InvoiceNumber: 2059, | ||
SubscriptionUUID: "1974a098jhlkjasdfljkha898326881c", | ||
Action: "purchase", | ||
AmountInCents: 1000, | ||
Status: "void", | ||
Message: "Test Gateway: Successful test transaction", | ||
Reference: "reference", | ||
Source: "subscription", | ||
Test: recurly.NewBool(true), | ||
Voidable: recurly.NewBool(true), | ||
Refundable: recurly.NewBool(true), | ||
}, | ||
}); diff != "" { | ||
t.Fatal(diff) | ||
} | ||
} | ||
|
||
func TestParse_NewDunningEventNotification(t *testing.T) { | ||
result := MustParseFile("testdata/new_dunning_event_notification.xml") | ||
if n, ok := result.(*webhooks.NewDunningEventNotification); !ok { | ||
|