PHP code example of paymentspring / paymentspring-php

1. Go to this page and download the library: Download paymentspring/paymentspring-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

paymentspring / paymentspring-php example snippets


  // Replace these with your actual keys.
  \PaymentSpring\PaymentSpring::setApiKeys(YOUR_PUBLIC_KEY, YOUR_PRIVATE_KEY);

	\PaymentSpring\Customer::listCustomers();

	\PaymentSpring\Customer::getCustomer($customerID);

	\PaymentSpring\Customer::createCustomer($customerDetails);

	\PaymentSpring\Plan::listPlans();

	\PaymentSpring\Plan::subscribeCustomer($planID, $customerID, $options);

	\PaymentSpring\Plan::createAndSubscribeCustomer(
		$planID, 
		$customerID, 
		$options
	);

	$amountInCents = 2500;
	$chargeDetails = array(
		"card_number" => "4111111111111111",
		"card_exp_month" => "01",
		"card_exp_year" => "19",
		"csc" => "123"
	);
	\PaymentSpring\Charge::chargeCard($chargeDetails, $amountInCents);

	\PaymentSpring\Charge::chargeCustomer(
		$customerID, 
		$amountInCents, 
		$options
	);

	\PaymentSpring\Charge::chargeToken($token, $amountInCents, $options);

	\PaymentSpring\PaymentSpring::makeRequest(
		"/receipts/templates", 
		array(
			  "receipt_text" => "Test template text [Amount]",            
			  "name" => "Basic Template",      
            "subject" => "thanks for the payment"
       ), 
		true
	);