Giter Site home page Giter Site logo

paysafecard_sdk's Introduction

paysafecard_sdk

Please note: This is not the official SDK of the paysafecard GmbH

Usage

Create transaction

Load the SDK and Initiate a new payment

include_once ('src/loader.php'); //load SDK
new Loader('payment');           //load sdk-classes for payment
$payment = new payment('test');  //new payment in testmode

Set parameter for transaction. If you use any system like shop or CMS, you can set order_id or anything else in the url to the mtid. So you dosen´t need currency or amount

$amount = '30.20';
$currency = 'EUR';
$mtid = 'psc_test' . rand(0, 9999999) . '_' . rand(0, 99999999);

$transaction = array(
 	'amount' => $amount,
 	'currency' => $currency,
 	'mtid' => $mtid,
 	'merchantClientId' => '3256',
 	'okUrl' => 'http://example.com/_onefile.php?ok=1&mtid=' . $mtid .'&currency=' . $currency . '&amount=' . $amount,
 	'nokUrl' => 'http://example.com/_onefile.php?nok',
 	'pnUrl' => 'http://example.com/_onefile.php?pn=1&mtid=' . $mtid .'&currency=' . $currency . '&amount=' . $amount
);

Create transaction

$result = $payment->newPayment($transaction);

If the transaction is successfully created, redirect the customers to pay.

if (!$result)
 {
 	echo $payment->getCustomerInfo();
 }
 else
 {
 	echo '<a href="' . $result . '"> PAY NOW -> </a>';
 }

Execute debit

Once the customer has successfully completed the payment, he is forwarded to the okUrl.

Load the SDK and Initiate payment

include_once ('src/loader.php');        //load SDK
new Loader('payment');                  //load sdk-classes for payment
$execute = new paymentExecute('test');  //new execute in testmode

Set the parameter. With a shopsystem, load the data (amount,currency) from database by mtid and order_id from GET

$parameter = array(
 	'mtid' => $_GET['mtid'],        
 	'amount' => $_GET['amount'],
 	'currency' => $_GET['currency'],
 	'close' => '1');

Execute the payment

if ($execute->execute($parameter))
 {
 	// useraccount topup -EXECUTE DEBIT SUCCESSFUL- Payment is completed
 }
 echo $execute->getCustomerInfo(); //show the message for the customer. On an error or success, always show this message.

Cancel payment by customer

If the customer clicked Cancel by paysafecard payment, you can redirect to new checkout or show a simple message. The class paymentCancel dosen´t send anything to paysafecard. It´s just load the language and set a customer message.

include_once ('src/loader.php');
 new Loader('payment');
 if (!isset($_GET['nok']))
 {
 	exit;
 }
 $cancel = new paymentCancel('en'); 
 echo $cancel->getCustomerInfo();

paysafecard_sdk's People

Contributors

steinweber avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.