public function testRefund()
 {
     $refund = new Refund();
     $response = $refund->refundTheAmt();
     $this->assertEquals("Success", $response->responseEnvelope->ack);
     $this->assertNotNull($response->refundInfoList->refundInfo);
 }
Beispiel #2
0
 public function testCreateForBitcoin()
 {
     self::authorizeFromEnv();
     $receiver = $this->createTestBitcoinReceiver("*****@*****.**");
     $charge = Charge::create(array('amount' => $receiver->amount, 'currency' => $receiver->currency, 'description' => $receiver->description, 'source' => $receiver->id));
     $ref = Refund::create(array('amount' => $receiver->amount, 'refund_address' => 'ABCDEF', 'charge' => $charge->id));
     $this->assertSame($receiver->amount, $ref->amount);
     $this->assertNotNull($ref->id);
 }
Beispiel #3
0
 /**
  * 
  * 申请退款,Refund中out_trade_no、transaction_id至少填一个且
  * out_refund_no、total_fee、refund_fee、op_user_id为必填参数
  * appid、mchid、spbill_create_ip、nonce_str不需要填入
  * @param Refund $inputObj
  * @param int $timeOut
  * @throws Exception
  * @return 成功时返回,其他抛异常
  */
 public static function refund($inputObj, $timeOut = 6)
 {
     $url = "https://api.mch.weixin.qq.com/secapi/pay/refund";
     //检测必填参数
     if (!$inputObj->IsOut_trade_noSet() && !$inputObj->IsTransaction_idSet()) {
         throw new Exception("退款申请接口中,out_trade_no、transaction_id至少填一个!");
     } else {
         if (!$inputObj->IsOut_refund_noSet()) {
             throw new Exception("退款申请接口中,缺少必填参数out_refund_no!");
         } else {
             if (!$inputObj->IsTotal_feeSet()) {
                 throw new Exception("退款申请接口中,缺少必填参数total_fee!");
             } else {
                 if (!$inputObj->IsRefund_feeSet()) {
                     throw new Exception("退款申请接口中,缺少必填参数refund_fee!");
                 } else {
                     if (!$inputObj->IsOp_user_idSet()) {
                         throw new Exception("退款申请接口中,缺少必填参数op_user_id!");
                     }
                 }
             }
         }
     }
     $inputObj->SetAppid(Config::APPID);
     //公众账号ID
     $inputObj->SetMch_id(Config::MCHID);
     //商户号
     $inputObj->SetNonce_str(self::getNonceStr());
     //随机字符串
     $inputObj->SetSign();
     //签名
     $xml = $inputObj->ToXml();
     $startTimeStamp = self::getMillisecond();
     //请求开始时间
     $response = self::postXmlCurl($xml, $url, true, $timeOut);
     $result = Results::Init($response);
     self::reportCostTime($url, $startTimeStamp, $result);
     //上报请求花费时间
     return $result;
 }
Beispiel #4
0
<?php

namespace Sofort\SofortLib;

require __DIR__ . '/../vendor/autoload.php';
// enter your configuration key – you only can create a new configuration key by creating
// a new Gateway project in your account at sofort.com
$configkey = '12345:123456:edc788a4316ce7e2ac0ede037aa623d7';
$SofortLibRefund = new Refund($configkey);
$SofortLibRefund->setSenderSepaAccount('SFRTDE20XXX', 'DE11888888889999999999', 'Max Mustermann');
$transactionId = '00907-01222-50D43927-FFDF';
$SofortLibRefund->addRefund($transactionId, 1, '17:43 auf gehts');
$SofortLibRefund->setPartialRefundId('454545');
$SofortLibRefund->setReason('reason1', 'reason2');
$SofortLibRefund->sendRequest();
if ($SofortLibRefund->isError()) {
    //SOFORT-API didn't accept the data
    echo $SofortLibRefund->getError();
} else {
    //buyer must be redirected to $paymentUrl else payment cannot be successfully completed!
    $paymentUrl = $SofortLibRefund->getPaymentUrl();
    header('Location: ' . $paymentUrl);
}
/*
	echo $SofortLibRefund->getSenderHolder(0).'<br/>';
	echo $SofortLibRefund->getSenderBic(0).'<br/>';
	echo $SofortLibRefund->getSenderIban(0).'<br/>';
	echo $SofortLibRefund->getTitle().'<br/>';
	echo $SofortLibRefund->getPain().'<br/>';
	echo $SofortLibRefund->getRecipientBankName(0).'<br/>';
	echo $SofortLibRefund->getRecipientHolder(0).'<br/>';
Beispiel #5
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Refund::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
<?php

require_once "../../../API/50/Vindicia/Soap/Vindicia.php";
require_once "../../../API/50/Vindicia/Soap/Const.php";
$refund = new Refund();
$nowPT = new \DateTime('now', new \DateTimeZone('America/Los_Angeles'));
$aDayAgoPT = new \DateTime('-30 days', new \DateTimeZone('America/Los_Angeles'));
$today = $nowPT->format(DATE_ATOM);
$since = $aDayAgoPT->format(DATE_ATOM);
//$merchantPaymentMethodId = 'UniquePaymentMethodId';
//$paymentMethod = new PaymentMethod();
//$paymentMethod->setMerchantPaymentMethodId($merchantPaymentMethodId);
$paymentMethod = null;
$totalCount = 0;
$ret = $refund->fetchDeltaSince($since, $today, $paymentMethod);
$count = 0;
if ($ret['returnCode'] == 200) {
    $fetchedRefunds = $ret['data']->refunds;
    if ($fetchedRefunds != null) {
        $count = sizeof($fetchedRefunds);
        print $count . ' returned.' . PHP_EOL;
        foreach ($fetchedRefunds as $ref) {
            print 'Refund Id=' . $ref->merchantRefundId . PHP_EOL;
            $totalCount++;
        }
    } else {
        print 'No transactions returned.' . PHP_EOL;
    }
} else {
    if ($ret['returnCode'] == 404) {
        print 'No refunds returned.' . PHP_EOL;
    }
}
$transactionAPI = new Transaction();
logCall('transaction->fetchByAccount ' . $merchantAccountId);
$response = $transactionAPI->fetchByAccount($account, false);
if (isCallSuccessful($response)) {
    $fetchedTxns = $response['data']->transactions;
    if ($fetchedTxns != null) {
        foreach ($fetchedTxns as $fetchedTx) {
            print "Transaction VID " . $fetchedTx->getVID() . PHP_EOL;
            print "Transaction amount " . $fetchedTx->getAmount() . PHP_EOL;
            print "Transaction status " . PHP_EOL;
            print $fetchedTx->statusLog[0]->status . PHP_EOL;
        }
    } else {
        print "No transactions found \n";
    }
}
$refundAPI = new Refund();
logCall('refundAPI->fetchByAccount ' . $merchantAccountId);
$response = $refundAPI->fetchByAccount($account, false);
if (isCallSuccessful($response)) {
    $refunds = $response['data']->refunds;
    if ($refunds != null) {
        foreach ($refunds as $refund) {
            print 'Refund of ' . $refund->amount . ' with Refund Id ' . $refund->merchantRefundId . ' had been issued against payment (transaction Id ' . $refund->transaction->merchantTransactionId . ') of ' . $refund->transaction->amount . ' made on ' . $refund->transaction->timestamp . PHP_EOL;
        }
    } else {
        print "No refunds found \n";
    }
}
             }
         }
         // if we are here, we got the latest transaction
         // We want to worry about only transactions in the New status - because these transactions have not
         // given next cycle's entitlements to the customer - so we want to make
         if ($latestTx != null) {
             print 'Latest Transaction ' . $latestTx->merchantTransactionId . 'has status = ' . $latestTx->statusLog[0]->status . PHP_EOL;
             if ($latestTx->statusLog[0]->status == 'New') {
                 print 'Attempting to issue refund against pending transaction ID ' . $latestTx->merchantTransactionId . '.' . PHP_EOL;
                 $refund = new Refund();
                 $refund->setAmount($latestTx->getAmount());
                 $refund->setTransaction($latestTx);
                 $refund->setCurrency($latestTx->getCurrency());
                 $nowNewYork = new \DateTime('now', new \DateTimeZone('America/New_York'));
                 $refund->setNote('Refunding due to subscription cancellation at ' . $nowNewYork->format('Y-m-d_h_i_s') . PHP_EOL);
                 $refundAPI = new Refund();
                 logCall('refundAPI->perform ' . $latestTx->merchantTransactionId);
                 $response = $refundAPI->perform(array($refund));
                 if (isCallSuccessful($response)) {
                     $refunds = $response['data']->refunds;
                     print 'Issued refund of ' . $refunds[0]->getAmount() . ' against pending transaction ID ' . $latestTx->getMerchantTransactionId() . PHP_EOL;
                 }
             }
         } else {
             // We do not need to do anything since we could not
             // find a transaction in 'New' status for this AutoBill
         }
     } else {
         print 'No transactions found' . PHP_EOL;
     }
 }
Beispiel #9
0
 * 金券金额不能退款)。
*/
include_once "./WxPayHelper/WxPayHelper.php";
//输入需退款的订单号
if (!isset($_POST["out_trade_no"]) || !isset($_POST["refund_fee"])) {
    $out_trade_no = " ";
    $refund_fee = "1";
} else {
    $out_trade_no = $_POST["out_trade_no"];
    $refund_fee = $_POST["refund_fee"];
    //商户退款单号,商户自定义,此处仅作举例
    $out_refund_no = "{$out_trade_no}" . "{$time_stamp}";
    //总金额需与订单号out_trade_no对应,demo中的所有订单的总金额为1分
    $total_fee = "1";
    //使用退款接口
    $refund = new Refund();
    //设置必填参数
    //appid已填,商户无需重复填写
    //mch_id已填,商户无需重复填写
    //noncestr已填,商户无需重复填写
    //sign已填,商户无需重复填写
    $refund->setParameter("out_trade_no", "{$out_trade_no}");
    //商户订单号
    $refund->setParameter("out_refund_no", "{$out_refund_no}");
    //商户退款单号
    $refund->setParameter("total_fee", "{$total_fee}");
    //总金额
    $refund->setParameter("refund_fee", "{$refund_fee}");
    //退款金额
    $refund->setParameter("op_user_id", WxPayConf::MCHID);
    //操作员