Skip to content

Commit

Permalink
Allow end-to-end test to run on In-Person Payments (#121)
Browse files Browse the repository at this point in the history
* Allow developers to override the CloudApiEndpoint for Terminal-API integrations using the options.ADYEN_TERMINAL_API_CLOUD_ENDPOINT

* Add workflow In-person Payments

---------

Co-authored-by: Kwok He Chu <>
  • Loading branch information
Kwok-he-Chu authored Jan 30, 2024
1 parent edc6e7c commit ca142b9
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 12 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,17 @@ jobs:
run: docker run --rm -d --name giving-example-image -p 8080:80 -e ADYEN_API_KEY="${{ secrets.ADYEN_API_KEY }}" -e ADYEN_MERCHANT_ACCOUNT=${{ secrets.ADYEN_MERCHANT_ACCOUNT }} -e ADYEN_CLIENT_KEY=${{ secrets.ADYEN_CLIENT_KEY }} -e ADYEN_HMAC_KEY=${{ secrets.ADYEN_HMAC_KEY }} giving-example-image:latest
- name: Run testing suite against giving-example-image
run: docker run --rm --name adyen-testing-suite -e ADYEN_HMAC_KEY=${{ secrets.ADYEN_HMAC_KEY }} -e PLAYWRIGHT_FOLDERNAME=giving --network host ghcr.io/adyen-examples/adyen-testing-suite:main

in-person-payments:
runs-on: ubuntu-latest
steps:
- name: In-person Payments project
uses: actions/checkout@v4
- name: Build in-person-payments-example image
run: docker build -t in-person-payments-example-image:latest in-person-payments-example
- name: Start in-person-payments-example container, set ADYEN_TERMINAL_API_CLOUD_ENDPOINT to default docker bridge and port 3000
run: docker run --rm -d --name in-person-payments-example-image -p 8080:80 -e ADYEN_API_KEY="${{ secrets.ADYEN_API_KEY }}" -e ADYEN_HMAC_KEY=${{ secrets.ADYEN_HMAC_KEY }} -e ADYEN_TERMINAL_API_CLOUD_ENDPOINT=http://172.17.0.1:3000 -e ADYEN_POS_POI_ID=V400m-123456789 in-person-payments-example-image:latest
- name: Start the Adyen Mock Terminal API Application on port 3000
run: docker run --rm -d --name adyen-mock-terminal-api -p 3000:3000 -e PORT=3000 ghcr.io/adyen-examples/adyen-mock-terminal-api:main
- name: Run testing suite against in-person-payments-example-image
run: docker run --rm --name adyen-testing-suite -e ADYEN_HMAC_KEY=${{ secrets.ADYEN_HMAC_KEY }} -e PLAYWRIGHT_FOLDERNAME=in-person-payments --network host ghcr.io/adyen-examples/adyen-testing-suite:main
16 changes: 8 additions & 8 deletions in-person-payments-example/Controllers/ApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ public async Task<ActionResult<CreatePaymentResponse>> CreatePayment([FromBody]
{
case ResultType.Success:
table.PaymentStatus = PaymentStatus.Paid;
table.PaymentStatusDetails.PoiTransactionId = paymentResponse.POIData.POITransactionID.TransactionID;
table.PaymentStatusDetails.PoiTransactionTimeStamp = paymentResponse.POIData.POITransactionID.TimeStamp;
table.PaymentStatusDetails.SaleTransactionId = paymentResponse.SaleData.SaleTransactionID.TransactionID;
table.PaymentStatusDetails.SaleTransactionTimeStamp = paymentResponse.SaleData.SaleTransactionID.TimeStamp;
table.PaymentStatusDetails.PoiTransactionId = paymentResponse.POIData?.POITransactionID?.TransactionID;
table.PaymentStatusDetails.PoiTransactionTimeStamp = paymentResponse.POIData?.POITransactionID?.TimeStamp;
table.PaymentStatusDetails.SaleTransactionId = paymentResponse.SaleData?.SaleTransactionID?.TransactionID;
table.PaymentStatusDetails.SaleTransactionTimeStamp = paymentResponse.SaleData?.SaleTransactionID?.TimeStamp;

return Ok(new CreatePaymentResponse()
{
Expand All @@ -97,10 +97,10 @@ public async Task<ActionResult<CreatePaymentResponse>> CreatePayment([FromBody]
case ResultType.Failure:
table.PaymentStatus = PaymentStatus.NotPaid;
table.PaymentStatusDetails.RefusalReason = "Payment terminal responded with: " + paymentResponse.Response.ErrorCondition;
table.PaymentStatusDetails.PoiTransactionId = paymentResponse.POIData.POITransactionID.TransactionID;
table.PaymentStatusDetails.PoiTransactionTimeStamp = paymentResponse.POIData.POITransactionID.TimeStamp;
table.PaymentStatusDetails.SaleTransactionId = paymentResponse.SaleData.SaleTransactionID.TransactionID;
table.PaymentStatusDetails.SaleTransactionTimeStamp = paymentResponse.SaleData.SaleTransactionID.TimeStamp;
table.PaymentStatusDetails.PoiTransactionId = paymentResponse.POIData?.POITransactionID?.TransactionID;
table.PaymentStatusDetails.PoiTransactionTimeStamp = paymentResponse.POIData?.POITransactionID?.TimeStamp;
table.PaymentStatusDetails.SaleTransactionId = paymentResponse.SaleData?.SaleTransactionID?.TransactionID;
table.PaymentStatusDetails.SaleTransactionTimeStamp = paymentResponse.SaleData?.SaleTransactionID?.TimeStamp;

return Ok(new CreatePaymentResponse()
{
Expand Down
8 changes: 7 additions & 1 deletion in-person-payments-example/Options/AdyenOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ public class AdyenOptions
/// <summary>
/// Your unique ID for the POS system (cash register) to send this request from.
/// </summary>
public string ADYEN_POS_SALE_ID { get; set; }
public string ADYEN_POS_SALE_ID { get; set; }

/// <summary>
/// Default: null, unless you want to override this to point to a different endpoint based on your region.
/// See https://docs.adyen.com/point-of-sale/design-your-integration/terminal-api/#cloud.
/// Optionally, if you do not own an Adyen Terminal/POS (yet), you can test this application using Adyen's Mock Terminal-API Application on GitHub: https://github.com/adyen-examples/adyen-mock-terminal-api (see README).
/// </summary>
public string ADYEN_TERMINAL_API_CLOUD_ENDPOINT { get; set; }
}
}
6 changes: 4 additions & 2 deletions in-person-payments-example/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public void ConfigureServices(IServiceCollection services)
options.ADYEN_API_KEY = Configuration[nameof(AdyenOptions.ADYEN_API_KEY)];
options.ADYEN_HMAC_KEY = Configuration[nameof(AdyenOptions.ADYEN_HMAC_KEY)];
options.ADYEN_POS_POI_ID = Configuration[nameof(AdyenOptions.ADYEN_POS_POI_ID)];
options.ADYEN_POS_SALE_ID = "SALE_ID_POS_42";
options.ADYEN_TERMINAL_API_CLOUD_ENDPOINT = Configuration[nameof(AdyenOptions.ADYEN_TERMINAL_API_CLOUD_ENDPOINT)];
options.ADYEN_POS_SALE_ID = "SALE_ID_POS";
}
);

Expand All @@ -57,7 +58,8 @@ public void ConfigureServices(IServiceCollection services)
XApiKey = options.Value.ADYEN_API_KEY,
// Test environment.
Environment = Adyen.Model.Environment.Test,
Timeout = 180
Timeout = 180,
CloudApiEndPoint = options.Value.ADYEN_TERMINAL_API_CLOUD_ENDPOINT
},
provider.GetRequiredService<IHttpClientFactory>(),
httpClientName
Expand Down
2 changes: 1 addition & 1 deletion in-person-payments-loyalty-example/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void ConfigureServices(IServiceCollection services)
XApiKey = options.Value.ADYEN_API_KEY,
// Test environment.
Environment = Adyen.Model.Environment.Test,
Timeout = 180,
Timeout = 180
},
provider.GetRequiredService<IHttpClientFactory>(),
httpClientName
Expand Down

0 comments on commit ca142b9

Please sign in to comment.