romain-sida-cocolabs / agorapay-php-sdk
CAPSPAYMENT API的PHP SDK
Requires
- php: >=5.3
- ext-curl: *
- ext-json: *
- ext-openssl: *
Requires (Dev)
- nunomaduro/phpinsights: ^1.14
This package is auto-updated.
Last update: 2024-09-19 08:31:50 UTC
README
CAPSPAYMENT API SDK是一个用于与CAPSPAYMENT REST API交互的PHP客户端库。
要求
要使用此SDK,您至少需要以下内容:
- PHP >= v7.2
- cURL(包含并启用在标准PHP发行版中)
此SDK提供了一个自动加载器。您需要在项目中使用它
require_once '/absolute/path/sdk/api/vendor/autoload.php';
require_once之后,您可以实例化主类
$api = new CAPSPaymentApi\Main();
基本配置
设置调用API的基础URL
<?php $api->Config->BaseUrl = 'https://hostname:port/version'; ?>
获取令牌
在调用API之前,您需要获取一个令牌。设置以下变量以获取一个令牌
设置获取认证令牌的URL
<?php $api->Config->TokenUrl = 'https://your_url_authentication'; ?>
设置用户
<?php $api->Config->TokenUser = 'your_user'; ?>
设置密码
<?php $api->Config->TokenPassword = 'your_password'; ?>
示例
<?php require_once '/absolute/path/to/sdk/api/vendor/autoload.php'; $api = new CAPSPaymentApi\Main(); $api->Config->BaseUrl = 'http://hostname:port/version'; $api->Config->TokenUrl = 'your_url'; $api->Config->TokenUser = 'your_username'; $api->Config->TokenPassword = 'your_password'; // Call paymentMethods from PayIn API $result = $api->PayIn->paymentMethods($object); ?>
列出用于API Payin的SDK函数
您将在表中找到用于每个API "Payin"端点的函数
示例
在此,我们使用payin/payment(方法POST)调用API
<?php require_once '/absolute/path/sdk/api/vendor/autoload.php'; $api = new CAPSPaymentApi\Main(); $api->Config->BaseUrl = 'http://hostname:port/version'; $api->Config->TokenUrl = 'your_url'; $api->Config->TokenUser = 'your_username'; $api->Config->TokenPassword = 'your_password'; //transaction amount object creation $transactionAmountObj = new \CAPSPaymentApi\Amount('', ''); //valuation of the object $transactionAmountObj->value = '70.10'; $transactionAmountObj->currency = 'EUR'; //transaction payment method object creation $transPaymentMethodObj = new \CAPSPaymentApi\TransPaymentMethod(''); //valuation of the object $transPaymentMethodObj->id = '4'; //payment object creation $paymentObj = new \CAPSPaymentApi\PaymentPayinsOptions('',''); //valuation of the object $paymentObj->orderId = '2987721'; $paymentObj->transactionAmount = $transactionAmountObj; $paymentObj->urlRedirect = 'http://www.url.fr'; $paymentObj->transPaymentMethod = $transPaymentMethodObj; // call API with payin/payment $result = $api->PayIn->payment($paymentObj); ?>
在此,我们使用payin/paymentMethods(方法POST)调用API
<?php require_once '/absolute/path/sdk/api/vendor/autoload.php'; $api = new CAPSPaymentApi\Main(); $api->Config->BaseUrl = 'http://hostname:port/version'; $api->Config->TokenUrl = 'your_url'; $api->Config->TokenUser = 'your_username'; $api->Config->TokenPassword = 'your_password'; //transaction amount object creation $amountObj = new \CAPSPaymentApi\Amount('', ''); //valuation of the object $amountObj->value = '100'; $amountObj->currency = 'EUR'; //payer object creation $payerObj = new \CAPSPaymentApi\Payer("192.168.0.1", "testPayer", "", "FR"); //valuation of the object $payerObj->IPAddress = '192.168.0.1'; $payerObj->reference = 'testPayer'; $payerObj->userAgent = ''; $payerObj->language = 'FR'; //payment methods object creation $paymentMethodsObj = new \CAPSPaymentApi\PaymentMethodPayinsOptions('', '', '', ''); //valuation of the object $paymentMethodsObj->orderReference = 'OrderTestPayin'; $paymentMethodsObj->orderCountryCode = 'FRA'; $paymentMethodsObj->amount = $amountObj; $paymentMethodsObj->payer = $payerObj; // call API with payin/paymentMethods $result = $api->PayIn->paymentMethods($paymentMethodsObj); ?>
在此,我们使用payin/orderDetails(方法GET)调用API
<?php require_once '/absolute/path/sdk/api/vendor/autoload.php'; $api = new CAPSPaymentApi\Main(); $api->Config->BaseUrl = 'http://hostname:port/version'; $api->Config->TokenUrl = 'your_url'; $api->Config->TokenUser = 'your_username'; $api->Config->TokenPassword = 'your_password'; // call API with payin/orderDetails $orderDetails = new \CAPSPaymentApi\OrderDetailsPayinsOptions('4596521'); $result = $api->PayIn->orderDetails($orderDetails); ?>
列出用于API Operation的SDK函数
您将在表中找到用于每个API "Operation"端点的函数
示例
<?php require_once '/absolute/path/sdk/api/vendor/autoload.php'; $api = new CAPSPaymentApi\Main(); $api->Config->BaseUrl = 'http://hostname:port/version'; $api->Config->TokenUrl = 'your_url'; $api->Config->TokenUser = 'your_username'; $api->Config->TokenPassword = 'your_password'; $listOperationOptions = new \CAPSPaymentApi\ListOperationOptions('10', '1', '010820101000', '281020101900', '150.00', '100.00', '123456', 'EUR', '123456', 'SDD', '234567', '345678'); // call API with /operations/list $result = $api->Operation->operation_list($listOperationOptions); ?>
列出用于API PaymentAccount的SDK函数
您将在表中找到用于每个API "PaymentAccount"端点的函数
示例
在此,我们使用paymentAccount/List(方法POST)调用API
<?php require_once '/absolute/path/sdk/api/vendor/autoload.php'; $api = new CAPSPaymentApi\Main(); $api->Config->BaseUrl = 'http://hostname:port/version'; $api->Config->TokenUrl = 'your_url'; $api->Config->TokenUser = 'your_username'; $api->Config->TokenPassword = 'your_password'; // encode array to json object $listPaymentAccountOptions = new \CAPSPaymentApi\ListPaymentAccountOptions('1300600000EUR01005110', 'EUR', 'A', '123456'); // call API with paymentAccount/modifyIBAN $result = $api->PaymentAccount->List($listPaymentAccountOptions); ?>
在此,我们使用/paymentAccount(方法GET)调用API
<?php require_once '/absolute/path/sdk/api/vendor/autoload.php'; $api = new CAPSPaymentApi\Main(); $api->Config->BaseUrl = 'http://hostname:port/version'; $api->Config->TokenUrl = 'your_url'; $api->Config->TokenUser = 'your_username'; $api->Config->TokenPassword = 'your_password'; // call API with /paymentAccount $paymentAccount = new \CAPSPaymentApi\PaymentAccountOptions('1300600000EUR01005110'); $result = $api->PaymentAccount->payment_account($paymentAccount); ?>
列出用于API Payout的SDK函数
您将在表中找到用于每个API "Payout"端点的函数
示例
在此,我们使用/payout/create调用API
<?php require_once '/absolute/path/sdk/api/vendor/autoload.php'; $api = new CAPSPaymentApi\Main(); $api->Config->BaseUrl = 'http://hostname:port/version'; $api->Config->TokenUrl = 'your_url'; $api->Config->TokenUser = 'your_username'; $api->Config->TokenPassword = 'your_password'; $createPayoutsOptions = new \CAPSPaymentApi\CreatePayoutsOptions("RefEndToEnd1", new \CAPSPaymentApi\Amount("50.00", "EUR"), "PM2021011300GLR1100", "", "test", "1300600000EUR01006110", new \CAPSPaymentApi\Comission("50.00", "1300600000EUR60002411"), "123456"); // call API with /payout/create $result = $api->Payout->create($createPayoutsOptions); ?>
列出用于API Transfer的SDK函数
您将在表中找到用于每个API "Transfert"端点的函数
示例
<?php require_once '/absolute/path/sdk/api/vendor/autoload.php'; $api = new CAPSPaymentApi\Main(); $api->Config->BaseUrl = 'http://hostname:port/version'; $api->Config->TokenUrl = 'your_url'; $api->Config->TokenUser = 'your_username'; $api->Config->TokenPassword = 'your_password'; $createTransfersOptions = new \CAPSPaymentApi\CreateTransfersOptions("1300600000EUR01006110", new \CAPSPaymentApi\Amount("50.00", "EUR"), "", "Operation label", "1300600000EUR01004110", "ref178623786"); // call API with /transfert/create $result = $api->Transfer->create($createTransfersOptions); ?>
列出用于API AccountHolder的SDK函数
您将在表中找到用于每个API "AccountHolder"端点的函数
示例
在此,我们使用/accountHolder/register(方法POST)调用API
<?php require_once '/absolute/path/sdk/api/vendor/autoload.php'; $api = new CAPSPaymentApi\Main(); $api->Config->BaseUrl = 'http://hostname:port/version'; $api->Config->TokenUrl = 'your_url'; $api->Config->TokenUser = 'your_username'; $api->Config->TokenPassword = 'your_password'; $registerAccountHolder = new \CAPSPaymentApi\RegisterAccountHolderOptions("123456", "reason", "compagny", "FRA", "SA", "4252378780001", new \CAPSPaymentApi\RegisterAddress("5 rue de blabla", 'City', '75019', 'FRA'), new \CAPSPaymentApi\RegisterAddress("5 rue de blabla", 'City', '75019', 'FRA'), "2020", "Y", new \CAPSPaymentApi\RegisterPerson('moi', 'moi', 'F', 'email@email.fr', '010101010101', array(new \CAPSPaymentApi\Role('BE'), new \CAPSPaymentApi\Role('MD')), '19800101'), new \CAPSPaymentApi\RegisterAccount('FRA', 'EUR', 'FR7611808009101234567890147', '230.00')); // call API with /accountHolder/register $result = $api->AccountHolder->register($registerAccountHolder); ?>
在此,我们使用/accountHolder/registrationDetails(方法GET)调用API
<?php require_once '/absolute/path/sdk/api/vendor/autoload.php'; $api = new CAPSPaymentApi\Main(); $api->Config->BaseUrl = 'http://hostname:port/version'; $api->Config->TokenUrl = 'your_url'; $api->Config->TokenUser = 'your_username'; $api->Config->TokenPassword = 'your_password'; // call API with /accountHolder/registrationDetails $registrationDetails = new \CAPSPaymentApi\RegistrationDetailsAccountHolderOptions('CAPS202201120YYEX1'); $result = $api->AccountHolder->registrationDetails($registrationDetails); ?>
列出用于API Selfcare的SDK函数
您将在表中找到用于每个API "Selfcare"端点的函数
示例
<?php require_once '/absolute/path/sdk/api/vendor/autoload.php'; $api = new CAPSPaymentApi\Main(); $api->Config->BaseUrl = 'http://hostname:port/version'; $api->Config->TokenUrl = 'your_url'; $api->Config->TokenUser = 'your_username'; $api->Config->TokenPassword = 'your_password'; $initSelfcareOptions = new \CAPSPaymentApi\InitSelfcareOptions("Olivier", "GARIN", "olivier.garin@email.fr", "0123456789", "GARIN & Fils", "100.00", "FR"); // call API with /selfcare/init $result = $api->Selfcare->init($initSelfcareOptions); ?>
列出用于API Mandate的SDK函数
您将在表中找到用于每个API "Mandate"端点的函数
示例1(SDD B2C承诺生成)
<?php require_once '/absolute/path/sdk/api/vendor/autoload.php'; $api = new CAPSPaymentApi\Main(); $api->Config->BaseUrl = 'http://hostname:port/version'; $api->Config->TokenUrl = 'your_url'; $api->Config->TokenUser = 'your_username'; $api->Config->TokenPassword = 'your_password'; $obj_transPaymentMethod = new \CAPSPaymentApi\TransPaymentMethod(''); $obj_payer = new \CAPSPaymentApi\Payer('','','',''); $obj_details = new \CAPSPaymentApi\Details('','','','','','','','','','','','','','',''); $str_urlRedirect = ''; $obj_transPaymentMethod->id = '37'; $obj_payer->reference = 'customer1'; $obj_details->gender = 'M'; $obj_details->firstName = 'John'; $obj_details->lastName = 'Smith'; $obj_details->email = 'js@mycompagny.com'; $obj_details->address = 'Rue d\'ici'; $obj_details->postalCode = '75000'; $obj_details->city = 'Ville'; $obj_details->country = 'FRA'; $obj_details->iban = 'FR7611808009101234567890147'; $obj_details->sequence = 'OOF'; $createMandateOptions = new \CAPSPaymentApi\CreateMandateOptions($obj_transPaymentMethod, $obj_payer, $obj_details, $str_urlRedirect); // call API with /selfcare/init $result = $api->Mandate->create($createMandateOptions); ?>
示例2(SDD B2B承诺生成)
<?php require_once '/absolute/path/sdk/api/vendor/autoload.php'; $api = new CAPSPaymentApi\Main(); $api->Config->BaseUrl = 'http://hostname:port/version'; $api->Config->TokenUrl = 'your_url'; $api->Config->TokenUser = 'your_username'; $api->Config->TokenPassword = 'your_password'; $obj_transPaymentMethod = new \CAPSPaymentApi\TransPaymentMethod(''); $obj_payer = new \CAPSPaymentApi\Payer('','','',''); $obj_details = new \CAPSPaymentApi\Details('','','','','','','','','','','','','','',''); $str_urlRedirect = ''; $obj_transPaymentMethod->id = '20'; $obj_payer->reference = 'customer1'; $obj_details->socialReason = 'My compagny'; $obj_details->email = 'js@mycompagny.com'; $obj_details->address = 'Rue d\'ici'; $obj_details->postalCode = '75000'; $obj_details->city = 'Ville'; $obj_details->country = 'FRA'; $obj_details->iban = 'FR7611808009101234567890147'; $obj_details->sequence = 'RCUR'; $createMandateOptions = new \CAPSPaymentApi\CreateMandateOptions($obj_transPaymentMethod, $obj_payer, $obj_details, $str_urlRedirect); // call API with /selfcare/init $result = $api->Mandate->create($createMandateOptions); ?>
示例3更新
<?php require_once '/absolute/path/sdk/api/vendor/autoload.php'; $api = new CAPSPaymentApi\Main(); $api->Config->BaseUrl = 'http://hostname:port/version'; $api->Config->TokenUrl = 'your_url'; $api->Config->TokenUser = 'your_username'; $api->Config->TokenPassword = 'your_password'; $updateMandateOptions = new \CAPSPaymentApi\UpdateMandateOptions('', ''); $updateMandateOptions->reference = '2020110907201100Y0H1102'; $updateMandateOptions->mandateId = '5120'; // call API with /selfcare/init $result = $api->Mandate->update($updateMandateOptions); ?>
列出用于API PaymentMethod的SDK函数
您将在表中找到用于每个API "PaymentMethod"端点的函数
示例
<?php require_once '/absolute/path/sdk/api/vendor/autoload.php'; $api = new CAPSPaymentApi\Main(); $api->Config->BaseUrl = 'http://hostname:port/version'; $api->Config->TokenUrl = 'your_url'; $api->Config->TokenUser = 'your_username'; $api->Config->TokenPassword = 'your_password'; $obj_payer = new \CAPSPaymentApi\Payer('','','',''); $obj_transPaymentMethod = new \CAPSPaymentApi\TransPaymentMethod(''); $obj_alias = new \CAPSPaymentApi\Alias(''); $obj_payer->reference = 'payer_123'; $obj_transPaymentMethod->id = '83964924'; $obj_alias->id = '228202063053068462'; $removeAliasPaymentMethodOptions = new \CAPSPaymentApi\RemoveAliasPaymentMethodOptions($obj_payer, $obj_transPaymentMethod, $obj_alias); // call API with /selfcare/init $result = $api->PaymentMethod->removeAlias($removeAliasPaymentMethodOptions); ?>
<?php require_once '/absolute/path/sdk/api/vendor/autoload.php'; $api = new CAPSPaymentApi\Main(); $api->Config->BaseUrl = 'http://hostname:port/version'; $api->Config->TokenUrl = 'your_url'; $api->Config->TokenUser = 'your_username'; $api->Config->TokenPassword = 'your_password'; $obj_payer = new \CAPSPaymentApi\Payer('','','',''); $obj_transPaymentMethod = new \CAPSPaymentApi\TransPaymentMethod(''); $obj_payer->reference = 'payer_ref'; $obj_transPaymentMethod->id = '83964924'; $getAliasPaymentMethodOptions = new \CAPSPaymentApi\GetAliasPaymentMethodOptions($obj_payer, $obj_transPaymentMethod); // call API with /selfcare/init $result = $api->PaymentMethod->getAlias($getAliasPaymentMethodOptions); ?>
<?php require_once '/absolute/path/sdk/api/vendor/autoload.php'; $api = new CAPSPaymentApi\Main(); $api->Config->BaseUrl = 'http://hostname:port/version'; $api->Config->TokenUrl = 'your_url'; $api->Config->TokenUser = 'your_username'; $api->Config->TokenPassword = 'your_password'; $obj_payer = new \CAPSPaymentApi\Payer('','','',''); $obj_contryCode = 'FRA'; $obj_amount = new \CAPSPaymentApi\Amount('', ''); $obj_payer->language = 'FR'; $obj_payer->reference = 'CREF_20210203180537464'; $obj_payer->IPAddress = '192.168.0.1'; $obj_amount->value = '70'; $obj_amount->currency = 'EUR'; $listPaymentMethodOptions = new \CAPSPaymentApi\ListPaymentMethodOptions($obj_contryCode, $obj_amount, $obj_payer); // call API with /selfcare/init $result = $api->PaymentMethod->list($listPaymentMethodOptions); ?>
<?php require_once '/absolute/path/sdk/api/vendor/autoload.php'; $api = new CAPSPaymentApi\Main(); $api->Config->BaseUrl = 'http://hostname:port/version'; $api->Config->TokenUrl = 'your_url'; $api->Config->TokenUser = 'your_username'; $api->Config->TokenPassword = 'your_password'; $getIBANPaymentMethodOptions = new \CAPSPaymentApi\GetIBANPaymentMethodOptions('PM202310230V3FG1100'); // call API with /selfcare/init $result = $api->PaymentMethod->getIBAN($getIBANPaymentMethodOptions); ?>