Code Example : HTML - JavaScript
- <html>
- <body>
- <script type="text/javascript">
- function encodeString(str) {
- document.PURCHASE.payload.value = btoa(str);
- }
- </script>
- <form name="PURCHASE" action="https://test.api.payfacto.com/v1/purchase" method="POST">
- auth-api-key<input type="text" name="auth-api-key" value="00000000000000000000000000000000000">
- <textarea name="input" placeholder="Some text">CompanyNumber=00000&MerchantNumber=00000000&CustomerNumber=00000000&Amount=00000001000&InvoiceNumber=505836912354&OriginalInvoiceNumber=505836912354&InputType=I&CardType= &CardNumber=4502285070000007&ExpirationDate=0726&Cvv2Cvc2Number=123&MerchantTerminalNumber= &LanguageCode=F&CurrencyCode=CAD&OperatorID=CTPSIMUL</TextArea>
- <input type="button" onclick="encodeString(document.PURCHASE.input.value);" value="Encode" >
- <input type="text" size="1024" name="payload" value="">
- <input type="submit" value="Submit">
- </form>
- </body>
- </html>
javascript.html
- <!DOCTYPE html>
- <html>
- <body>
- <h1>The Javascript example</h1>
- <button type="button" onclick="loadDoc()">Request data</button>
- <p id="demo"></p>
-
- <script>
- var str = "CompanyNumber=00000&MerchantNumber=00000000&CustomerNumber=00000000&Amount=00000001000&InvoiceNumber=505836912354&OriginalInvoiceNumber=505836912354&InputType=I&CardType= &CardNumber=4502285070000007&ExpirationDate=0726&Cvv2Cvc2Number=123&MerchantTerminalNumber= &LanguageCode=F&CurrencyCode=CAD&OperatorID=CTPSIMUL";
- function loadDoc() {
- var xhttp = new XMLHttpRequest();
- xhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- document.getElementById("demo").innerHTML = this.responseText;
- }
- };
- xhttp.open("POST", "https://test.api.payfacto.com/v1/purchase", true);
- xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- xhttp.setRequestHeader("Accept", "application/json");
- xhttp.send("auth-api-key=00000000000000000000000000000000000&payload=" + btoa(str));
- }
- </script>
- </body>
- </html>
Related Articles
Code Example Microsoft .NET
Microsoft .NET Edit main.cs PaymentTransaction paymentTransaction = new PaymentTransaction("https://test.api.payfacto.com/v1", "00000000000000000000000000000000000"); String purchaseInput = FillPurchaseInput(); transactionOutput = ...
Code Example - Java
JAVA Edit main.java CTPaymentClient restv1Client = new CTPaymentClient("https://test.api.payfacto.com/", "00000000000000000000000000000000000" ); // PURCHASE EXAMPLE HashMap<String, String> params = new HashMap<String, String>(); ...
Example Calls to the Secure Payment Application
This page lists code examples for the various Secure Payment transactions Purchase JavaScript Intent intent = new Intent("com.payfacto.terminal.payment.PAYMENT_ACTIVITY"); intent.putExtra("TRANSACTION", "SALE"); intent.putExtra("AMOUNT", "100"); // ...
Code Example : PHP
PHP Edit main.php <?php $payload="CompanyNumber=00000&MerchantNumber=00000000&CustomerNumber=00000000&Amount=00000001000&InvoiceNumber=505836912354&OriginalInvoiceNumber=505836912354&InputType=I&CardType= ...
SPL - Secure Pay By Link
Secure Pay By Link Secure Pay By Link (SPL) is a new offering from PayFacto that allows a merchant to defer a SHC session to another time. It does that by creating a link that the cardholder can follow to a hosted page. When the cardholder navigates ...