Skip to content

Latest commit

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

SwiftWave PHP SDK

Overview

The SwiftWave PHP SDK enables seamless integration of SwiftWave's secure money transaction functionalities into PHP-based applications. This SDK simplifies transaction management, allowing you to send and receive payments, access currency exchange, and leverage SwiftWave's robust features within your PHP projects.

Usage

Payer

To fund payments using SwiftWave:

// Payer Object$payer = newPayer();
$payer->setPaymentMethod('SwiftWave'); // Your system name, e.g., SwiftWave

Amount

Specify a payment amount and the currency:

// Amount Object$amountIns = newAmount();
$amountIns->setTotal(20)->setCurrency('USD'); // Provide a valid currency code

Transaction

Create a Transaction resource where the amount object is set:

// Transaction Object$trans = newTransaction();
$trans->setAmount($amountIns);

RedirectUrls

Set the URLs where buyers should redirect after a transaction is completed or canceled:

// RedirectUrls Object$urls = newRedirectUrls();
$urls->setSuccessUrl('http://your-merchant-domain.com/example-success.php') // Success URL
->setCancelUrl('http://your-merchant-domain.com/'); // Cancel URL

Payment

Create a payment resource with Payer, Amount, RedirectUrls, and merchant Credentials (Client ID and Client Secret):

// Payment Object$payment = newPayment();
$payment->setCredentials([
'client_id' => 'your_client_id_here', // Provide correct client ID'client_secret' => 'your_client_secret_here'// Provide correct client secret
])
->setRedirectUrls($urls)
->setPayer($payer)
->setTransaction($trans);
try {
$payment->create(); // Create paymentheader("Location: ".$payment->getApprovedUrl()); // Checkout URL
} catch (Exception$ex) {
print$ex;
exit;
}

Dependencies

Make sure to use the required SwiftWave API classes:

useSwiftWave\Api\Payer;
useSwiftWave\Api\Amount;
useSwiftWave\Api\Transaction;
useSwiftWave\Api\RedirectUrls;
useSwiftWave\Api\Payment;

Notes

  • Ensure the provided client ID and client secret are accurate.
  • Customize URLs according to your application's redirect requirements.
  • Replace placeholders with actual values for smooth integration.

About

The PHP SDK for SwiftWave facilitates seamless integration of SwiftWave's secure money transaction functionalities into PHP-based applications. Effortlessly manage transactions, send and receive payments, access currency exchange, and leverage SwiftWave's robust features within your PHP projects.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages