Skip to content

Instantly share code, notes, and snippets.

@ianleeder
Created February 9, 2016 00:18
Show Gist options
  • Save ianleeder/21f0afda2b1dde48d6f4 to your computer and use it in GitHub Desktop.
Save ianleeder/21f0afda2b1dde48d6f4 to your computer and use it in GitHub Desktop.
<%@ Page Language="C#" %>
<%@ Import Namespace="eWAY.Rapid" %>
<%@ Import Namespace="eWAY.Rapid.Enums" %>
<%@ Import Namespace="eWAY.Rapid.Models" %>
<!DOCTYPE html>
<script runat="server">
private static readonly string ApiKey = "mykey";
private static readonly string ApiPassword = "mypassword";
private static readonly string RapidEndpoint = "Sandbox";
protected void Page_Load(object sender, EventArgs e)
{
IRapidClient ewayClient = RapidClientFactory.NewRapidClient(ApiKey, ApiPassword, RapidEndpoint);
// STEP 1
// Create the transaction with eWAY
Transaction transaction = new Transaction()
{
Customer = new Customer()
{
Reference = "A12345",
Title = "Mr.",
FirstName = "John",
LastName = "Smith",
Address = new Address()
{
Street1 = "Level 5",
Street2 = "369 Queen Street",
City = "Sydney",
State = "NSW",
Country = "au",
PostalCode = "2000",
},
},
PaymentDetails = new PaymentDetails()
{
TotalAmount = 1000,
InvoiceNumber = "Inv 21540",
InvoiceDescription = "Individual Invoice Description",
InvoiceReference = "513456",
CurrencyCode = "AUD"
},
RedirectURL = "http://www.eway.com.au",
SaveCustomer = true,
TransactionType = TransactionTypes.Purchase
};
CreateTransactionResponse createResponse = ewayClient.Create(PaymentMethod.TransparentRedirect, transaction);
paymentForm.Action = createResponse.FormActionUrl;
literalPayPalAccessCode.Text = createResponse.AccessCode;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>eWAY Paypal Test</title>
</head>
<body>
<form method="POST" id="paymentForm" runat="server">
<input type="hidden" name="EWAY_ACCESSCODE" value="<asp:Literal runat='server' ID='literalPayPalAccessCode' />" />
<input type="hidden" name="EWAY_PAYMENTTYPE" value="PayPal" />
<input type="submit" value="Checkout" text="Checkout" />
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment