Skip to content

Commit

Permalink
Add optional callback URL for payment notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmcroft committed Sep 26, 2023
1 parent 70930fa commit fe83d52
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/FuturePayService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class FuturePayService {
this.url = isTestEnvironment ? "https://secure-test.worldpay.com/wcc/purchase" : "https://secure.worldpay.com/wcc/purchase";
}

initiateAgreement(agreement: Agreement): Promise<void> {
initiateAgreement(agreement: Agreement, callbackUrl: string | null = null): Promise<void> {
var formInputsHtml = "";

for (var key in agreement) {
Expand All @@ -16,6 +16,10 @@ export class FuturePayService {
}
}

if (callbackUrl) {
formInputsHtml += `<input type='hidden' name='MC_callback' value='${callbackUrl}'></input>`;
}

if (document) {
var form = document.createElement("form");
form.setAttribute("method", "post");
Expand Down

0 comments on commit fe83d52

Please sign in to comment.