Code Example : PHP

Code Example : PHP

PHP

Edit

main.php

  1. <?php

  2. $payload="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";
  3. $body = "auth-api-key=00000000000000000000000000000000000&payload=".base64_encode($payload);
  4. $https_server="test.api.payfacto.com/v1/purchase";

  5. $opts = array('http' =>
  6.   array(
  7.     'method'  => 'POST',
  8.     'header'  => "Content-Type: application/x-www-form-urlencoded\r\n".
  9.       "Accept: application/json\r\n",
  10.     'user_agent' => 'CodeExample',
  11.     'content' => $body,
  12.     'timeout' => 60
  13.   )
  14. );

  15. $context  = stream_context_create($opts);
  16. $url = 'https://'.$https_server;
  17. $result = file_get_contents($url, false, $context, -1, 40000);

  18. echo $result;

  19. ?>
    • 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>(); ...
    • Code Example : HTML - JavaScript

      form.html <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 ...
    • 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"); // ...
    • Credit Card Verification Code (CVV)

      Introduction This code is not found on the magnetic stripe, making it impossible for the defrauder to copy the magnetic stripe or to learn the card’s verification code. This code is not embossed on the credit card either (characters engraved in the ...