Skip to content

Commit dd67c13

Browse files
committed
Merge pull request AuthorizeNet#21 from ashtru/master
Added credit.php(Paypal)
2 parents 9268295 + f8fd9e4 commit dd67c13

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

PaypalExpressCheckout/credit.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
require 'vendor/autoload.php';
3+
4+
use net\authorize\api\contract\v1 as AnetAPI;
5+
use net\authorize\api\controller as AnetController;
6+
7+
define("AUTHORIZENET_LOG_FILE", "phplog");
8+
9+
// Common setup for API credentials (Paypal compatible merchant)
10+
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
11+
// $merchantAuthentication->setName("mbld_api_-g9yGXH6");
12+
// $merchantAuthentication->setTransactionKey("8b948Sk5Tk5jBB6w");
13+
$merchantAuthentication->setName("5KP3u95bQpv");
14+
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
15+
16+
$refId = 'ref' . time();
17+
$refTransId = "2241762126";
18+
19+
// Create the payment data for a paypal account
20+
$payPalType = new AnetAPI\PayPalType();
21+
$payPalType->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
22+
$payPalType->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
23+
$paymentOne = new AnetAPI\PaymentType();
24+
$paymentOne->setPayPal($payPalType);
25+
26+
//create a refund transaction
27+
$transactionRequestType = new AnetAPI\TransactionRequestType();
28+
$transactionRequestType->setTransactionType( "refundTransaction");
29+
$transactionRequestType->setAmount(181);
30+
$transactionRequestType->setPayment($paymentOne);
31+
///refTransId of successfully settled transaction
32+
$transactionRequestType->setRefTransId($refTransId);
33+
34+
$request = new AnetAPI\CreateTransactionRequest();
35+
$request->setMerchantAuthentication($merchantAuthentication);
36+
$request->setRefId( $refId);
37+
$request->setTransactionRequest( $transactionRequestType);
38+
39+
$controller = new AnetController\CreateTransactionController($request);
40+
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
41+
42+
if ($response != null)
43+
{
44+
$tresponse = $response->getTransactionResponse();
45+
46+
if (($tresponse != null)&& ($response->getMessages()->getResultCode()=="Ok"))
47+
{
48+
echo "Credit SUCCESS AUTH CODE : " . $tresponse->getAuthCode() . "\n";
49+
echo "Credit TRANS ID : " . $tresponse->getTransId() . "\n";
50+
}
51+
else
52+
{
53+
echo "Credit ERROR : " . $tresponse->getResponseCode() . "\n";
54+
}
55+
}
56+
else
57+
{
58+
echo "No response returned";
59+
}
60+
?>

0 commit comments

Comments
 (0)