Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
What === Add `PayPalDetails` to `Transaction`. Why === When `Transaction`s are created with a PayPal nonce or `PayPalAccount` the details are not visible on the resulting `Transaction`.
- Loading branch information
1 parent
d2743bd
commit c0e3fe8
Showing
3 changed files
with
106 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package braintree | ||
|
||
type PayPalDetails struct { | ||
PayerEmail string `xml:"payer-email,omitempty"` | ||
PaymentID string `xml:"payment-id,omitempty"` | ||
AuthorizationID string `xml:"authorization-id,omitempty"` | ||
Token string `xml:"token,omitempty"` | ||
ImageURL string `xml:"image-url,omitempty"` | ||
DebugID string `xml:"debug-id,omitempty"` | ||
PayeeEmail string `xml:"payee-email,omitempty"` | ||
CustomField string `xml:"custom-field,omitempty"` | ||
PayerID string `xml:"payer-id,omitempty"` | ||
PayerFirstName string `xml:"payer-first-name,omitempty"` | ||
PayerLastName string `xml:"payer-last-name,omitempty"` | ||
PayerStatus string `xml:"payer-status,omitempty"` | ||
SellerProtectionStatus string `xml:"seller-protection-status,omitempty"` | ||
RefundID string `xml:"refund-id,omitempty"` | ||
CaptureID string `xml:"capture-id,omitempty"` | ||
TransactionFeeAmount string `xml:"transaction-fee-amount,omitempty"` | ||
TransactionFeeCurrencyISOCode string `xml:"transaction-fee-currency-iso-code,omitempty"` | ||
Description string `xml:"description,omitempty"` | ||
} |
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package braintree | ||
|
||
import "testing" | ||
|
||
func TestTransactionPayPalDetails(t *testing.T) { | ||
tx, err := testGateway.Transaction().Create(&Transaction{ | ||
Type: "sale", | ||
Amount: NewDecimal(2000, 2), | ||
PaymentMethodNonce: FakeNoncePayPalOneTimePayment, | ||
}) | ||
|
||
t.Log(tx) | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if tx.Id == "" { | ||
t.Fatal("Received invalid ID on new transaction") | ||
} | ||
if tx.Status != "authorized" { | ||
t.Fatal(tx.Status) | ||
} | ||
|
||
if tx.PayPalDetails == nil { | ||
t.Fatal("Expected PayPalDetails for transaction created with PayPal nonce") | ||
} | ||
|
||
t.Log(tx.PayPalDetails) | ||
|
||
if tx.PayPalDetails.PayerEmail == "" { | ||
t.Fatal("Expected PayPalDetails to have PayerEmail set") | ||
} | ||
if tx.PayPalDetails.PaymentID == "" { | ||
t.Fatal("Expected PayPalDetails to have PaymentID set") | ||
} | ||
if tx.PayPalDetails.ImageURL == "" { | ||
t.Fatal("Expected PayPalDetails to have ImageURL set") | ||
} | ||
if tx.PayPalDetails.DebugID == "" { | ||
t.Fatal("Expected PayPalDetails to have DebugID set") | ||
} | ||
if tx.PayPalDetails.PayerID == "" { | ||
t.Fatal("Expected PayPalDetails to have DebugID set") | ||
} | ||
if tx.PayPalDetails.PayerFirstName == "" { | ||
t.Fatal("Expected PayPalDetails to have PayerFirstName set") | ||
} | ||
if tx.PayPalDetails.PayerLastName == "" { | ||
t.Fatal("Expected PayPalDetails to have PayerLastName set") | ||
} | ||
if tx.PayPalDetails.PayerStatus == "" { | ||
t.Fatal("Expected PayPalDetails to have PayerStatus set") | ||
} | ||
if tx.PayPalDetails.SellerProtectionStatus == "" { | ||
t.Fatal("Expected PayPalDetails to have SellerProtectionStatus set") | ||
} | ||
} | ||
|
||
func TestTransactionWithoutPayPalDetails(t *testing.T) { | ||
tx, err := testGateway.Transaction().Create(&Transaction{ | ||
Type: "sale", | ||
Amount: NewDecimal(2000, 2), | ||
PaymentMethodNonce: FakeNonceTransactable, | ||
}) | ||
|
||
t.Log(tx) | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if tx.Id == "" { | ||
t.Fatal("Received invalid ID on new transaction") | ||
} | ||
if tx.Status != "authorized" { | ||
t.Fatal(tx.Status) | ||
} | ||
|
||
if tx.PayPalDetails != nil { | ||
t.Fatalf("Expected PayPalDetails to be nil for transaction created without PayPal, but was %#v", tx.PayPalDetails) | ||
} | ||
} |