Created
May 7, 2020 23:47
-
-
Save thlinux1107/dd5e540f3f95e30537bdefcb84489a5f to your computer and use it in GitHub Desktop.
Paya Connect - Hosted Payment Page PHP Sample - includes custom fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*---------------------------------------------- | |
Author: SDK Support Group | |
Company: Paya | |
Contact: [email protected] | |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
!!! Samples intended for educational use only!!! | |
!!! Not intended for production !!! | |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
-----------------------------------------------*/ | |
require('shared.php'); | |
$id = $hpp['ID']; | |
$timestamp = time(); | |
// Custom request for HPP. | |
$req = [ | |
"id" => $id, | |
"field_configuration" => [ | |
"body" => [ | |
"fields" => [ | |
[ | |
"id" => "transaction_amount", | |
"value" => 7.00, | |
"label" => "Amount", | |
"readonly" => true, | |
"visible" => true | |
], | |
[ | |
"id" => "action", | |
"value" => "sale", | |
"visible" => false | |
], | |
[ | |
"id" => "order_num", | |
"value" => "SDK_TEST_INVOICE " . $timestamp, | |
"label" => "", | |
"readonly" => true, | |
"visible" => false | |
], | |
[ | |
"id" => "description", | |
"value" => "SDK Test Auth" . $timestamp, | |
"label" => "", | |
"readonly" => true, | |
"visible" => false | |
], | |
[ | |
"id" => "transaction_api_id", | |
"value" => "SDKTEST" . $timestamp, | |
"label" => "", | |
"readonly" => true, | |
"visible" => false | |
], | |
[ | |
"id" => "billing_street", | |
"value" => "123 Main St", | |
"label" => "Billing Street", | |
"readonly" => false, | |
"visible" => true | |
], | |
[ | |
"id" => "billing_city", | |
"value" => "Savannah", | |
"label" => "Billing City", | |
"readonly" => false, | |
"visible" => true | |
], | |
[ | |
"id" => "billing_state", | |
"value" => "GA", | |
"label" => "Billing State", | |
"readonly" => false, | |
"visible" => true | |
], | |
[ | |
"id" => "billing_zip", | |
"value" => "31405", | |
"label" => "Billing Zip", | |
"readonly" => false, | |
"visible" => true | |
], | |
[ | |
"id" => "save_account", | |
"value" => true, | |
"visible" => false | |
], | |
[ | |
"id" => "save_account_title", | |
"value" => "Primary Card", | |
"visible" => false | |
] | |
] | |
] | |
], | |
"redirect_url_on_approve" => "https://google.com", | |
"redirect_url_on_decline" => "https://google.com" | |
]; | |
// Encode the request details | |
$sReq = json_encode($req); | |
$data = getEncodedData($sReq, $hpp['KEY']); | |
?> | |
<!--Create a page to display the payment link.--> | |
<style> | |
a { | |
display:inline-block; | |
background-color:#428bca; | |
border-color:#357ebd; | |
border-radius:5px; | |
border-width:0; | |
border-style:none; | |
color:#ffffff; | |
font-size:12px; | |
height:30px; | |
width:100px; | |
margin:0px; | |
padding:7px; | |
text-decoration:none; | |
text-align:center; | |
} | |
</style> | |
<div> | |
<h1>Paya Connect Hosted Payment Page</h1> | |
<br /> | |
<!--Build the payment link.--> | |
<a href="https://api.sandbox.payaconnect.com/hostedpaymentpage?id=<?= $id ?>&data=<?= $data ?>" type="button">Pay Now</a> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment