use PayXpert\Connect2Pay\Connect2PayClient;
$url = "https://paiement.payzone.ma";
$originator = "000000";
$password = "Gr3atPassw0rd!";
$transactionId = "example";
$c2pClient = new Connect2PayClient($url, $originator, $password);
$transaction = $c2pClient->getTransactionInfo($transactionId);
if ($transaction != null && $transaction->getResultCode() != null) {
echo "Payment ID: " . $transaction->getPaymentID() . "\n";
echo "Payment Merchant Token: " . $transaction->getPaymentMerchantToken() . "\n";
echo "Transaction ID: " . $transaction->getTransactionID() . "\n";
if ($transaction->getRefTransactionID()) {
echo "Referral transaction ID: " . $transaction->getRefTransactionID() . "\n";
}
echo "Provider transaction ID: " . $transaction->getProviderTransactionID() . "\n";
echo "Payment method: " . $transaction->getPaymentMethod() . "\n";
if ($transaction->getPaymentNetwork()) {
echo "Payment network: " . $transaction->getPaymentNetwork() . "\n";
}
echo "Operation: " . $transaction->getOperation() . "\n";
echo "Amount: " . number_format($transaction->getAmount() / 100, 2) . " " .
$transaction->getCurrency() . "\n";
echo "Refunded amount: " . number_format($transaction->getRefundedAmount() / 100, 2) . " " .
$transaction->getCurrency() . "\n";
echo "Result code: " . $transaction->getResultCode() . "\n";
echo "Result message: " . $transaction->getResultMessage() . "\n";
$transactionDate = $transaction->getDateAsDateTime();
if ($transactionDate !== null) {
echo "Transaction date: " . $transactionDate->format("Y-m-d H:i:s T") . "\n";
}
if ($transaction->getSubscriptionID()) {
echo "Subscription ID: " . $transaction->getSubscriptionID() . "\n";
}
$paymentMeanInfo = $transaction->getPaymentMeanInfo();
if ($paymentMeanInfo !== null) {
switch ($transaction->getPaymentMethod()) {
case Connect2PayClient::PAYMENT_METHOD_CREDITCARD:
if (!empty($paymentMeanInfo->getCardNumber())) {
echo "Payment Mean Information:\n";
echo "* Card Holder Name: " . $paymentMeanInfo->getCardHolderName() . "\n";
echo "* Card Number: " . $paymentMeanInfo->getCardNumber() . "\n";
echo "* Card Expiration: " . $paymentMeanInfo->getCardExpireMonth() . "/" .
$paymentMeanInfo->getCardExpireYear() . "\n";
echo "* Card Brand: " . $paymentMeanInfo->getCardBrand() . "\n";
if (!empty($paymentMeanInfo->getCardLevel())) {
echo "* Card Level/subtype: " . $paymentMeanInfo->getCardLevel() . "/" .
$paymentMeanInfo->getCardSubType() . "\n";
echo "* Card country code: " . $paymentMeanInfo->getIinCountry() . "\n";
echo "* Card bank name: " . $paymentMeanInfo->getIinBankName() . "\n";
}
}
break;
case Connect2PayClient::PAYMENT_METHOD_TODITOCASH:
if (!empty($paymentMeanInfo->getCardNumber())) {
echo "Payment Mean Information:\n";
echo "* Card Number: " . $paymentMeanInfo->getCardNumber() . "\n";
}
break;
case Connect2PayClient::PAYMENT_METHOD_BANKTRANSFER:
$sender = $paymentMeanInfo->getSender();
$recipient = $paymentMeanInfo->getRecipient();
if ($sender !== null) {
echo "Payment Mean Information:\n";
echo "* Sender Account:\n";
echo ">> Holder Name: " . $sender->getHolderName() . "\n";
echo ">> Bank Name: " . $sender->getBankName() . "\n";
echo ">> IBAN: " . $sender->getIban() . "\n";
echo ">> BIC: " . $sender->getBic() . "\n";
echo ">> Country code: " . $sender->getCountryCode() . "\n";
}
if ($recipient !== null) {
echo "* Recipient Account:\n";
echo ">> Holder Name: " . $recipient->getHolderName() . "\n";
echo ">> Bank Name: " . $recipient->getBankName() . "\n";
echo ">> IBAN: " . $recipient->getIban() . "\n";
echo ">> BIC: " . $recipient->getBic() . "\n";
echo ">> Country code: " . $recipient->getCountryCode() . "\n";
}
break;
case Connect2PayClient::PAYMENT_METHOD_DIRECTDEBIT:
$account = $paymentMeanInfo->getBankAccount();
if ($account !== null) {
echo "Payment Mean Information:\n";
echo "* Statement descriptor: " . $paymentMeanInfo->getStatementDescriptor() . "\n";
$collectedAt = $paymentMeanInfo->getCollectedAtAsDateTime();
if ($collectedAt != null) {
echo "* Collected At: " . $collectedAt->format("Y-m-d H:i:s T") . "\n";
}
echo "* Bank Account:\n";
echo ">> Holder Name: " . $account->getHolderName() . "\n";
echo ">> Bank Name: " . $account->getBankName() . "\n";
echo ">> IBAN: " . $account->getIban() . "\n";
echo ">> BIC: " . $account->getBic() . "\n";
echo ">> Country code: " . $account->getCountryCode() . "\n";
$sepaMandate = $account->getSepaMandate();
if ($sepaMandate != null) {
echo "* SEPA mandate:\n";
echo ">> Description: " . $sepaMandate->getDescription() . "\n";
echo ">> Status: " . $sepaMandate->getStatus() . "\n";
echo ">> Type: " . $sepaMandate->getType() . "\n";
echo ">> Scheme: " . $sepaMandate->getScheme() . "\n";
echo ">> Signature type: " . $sepaMandate->getSignatureType() . "\n";
echo ">> Phone number: " . $sepaMandate->getPhoneNumber() . "\n";
$signedAt = $sepaMandate->getSignedAtAsDateTime();
if ($signedAt != null) {
echo ">> Signed at: " . $signedAt->format("Y-m-d H:i:s T") . "\n";
}
$createdAt = $sepaMandate->getSignedAtAsDateTime();
if ($createdAt != null) {
echo ">> Created at: " . $createdAt->format("Y-m-d H:i:s T") . "\n";
}
$lastUsedAt = $sepaMandate->getLastUsedAtAsDateTime();
if ($lastUsedAt != null) {
echo ">> Last used at: " . $lastUsedAt->format("Y-m-d H:i:s T") . "\n";
}
echo ">> Download URL: " . $sepaMandate->getDownloadUrl() . "\n";
}
}
break;
}
}
$shopper = $transaction->getShopper();
if ($shopper !== null) {
echo "Shopper info:\n";
echo "* Name: " . $shopper->getName() . "\n";
echo "* Address: " . $shopper->getAddress() . " - " . $shopper->getZipcode() . " " .
$shopper->getCity() . " - " .
$shopper->getCountryCode() . "\n";
echo "* Email: " . $shopper->getEmail() . "\n";
if (!empty($shopper->getBirthDate())) {
echo "* Birth date: " . $shopper->getBirthDate() . "\n";
}
if (!empty($shopper->getIdNumber())) {
echo "* ID Number: " . $shopper->getIdNumber() . "\n";
}
if (!empty($shopper->getIpAddress())) {
echo "* IP Address: " . $shopper->getIpAddress() . "\n";
}
}
} else {
echo "Error: " . $c2pClient->getClientErrorMessage() . "\n";
}
Connect2payClient c2p = new Connect2payClient("https://paiement.payzone.ma", "123456",
"GreatP4ssw0rd");
TransactionInfoRequest request = new TransactionInfoRequest();
TransactionInfoResponse response = null;
request.setTransactionId("example");
try {
response = c2p.getTransactionInfo(request);
TransactionAttempt transaction = response.getTransactionInfo();
System.out.println(transaction.getPaymentMethod());
System.out.println(transaction.getAmount());
System.out.println(response.getResultCode());
} catch (Exception e) {
logger.error("Ooops, an error occurred getting transaction information: " + e.getMessage());
}
var client = new Connect2PayClient(OriginatorConfig.ORIGINATOR_ID,
OriginatorConfig.ORIGINATOR_PASSWORD);
var request = client.NewRequestTransactionInfo(TransactionID);
var response = await request.Send();
if (response == null)
{
Console.WriteLine("Failure");
} else {
Console.WriteLine("Transaction operation: " + response.operation);
}