コード例 #1
0
ファイル: PhortuneCart.php プロジェクト: rchicoli/phabricator
 public function didRefundCharge(PhortuneCharge $charge, PhortuneCharge $refund)
 {
     $refund->setStatus(PhortuneCharge::STATUS_CHARGED);
     $this->openTransaction();
     $this->beginReadLocking();
     $copy = clone $charge;
     $copy->reload();
     if ($charge->getRefundingPHID() !== $refund->getPHID()) {
         throw new Exception(pht('Charge is in the wrong refunding state!'));
     }
     $charge->setRefundingPHID(null);
     // NOTE: There's some trickiness here to get the signs right. Both
     // these values are positive but the refund has a negative value.
     $total_refunded = $charge->getAmountRefundedAsCurrency()->add($refund->getAmountAsCurrency()->negate());
     $charge->setAmountRefundedAsCurrency($total_refunded);
     $charge->save();
     $refund->save();
     $this->endReadLocking();
     $this->saveTransaction();
     $amount = $refund->getAmountAsCurrency()->negate();
     foreach ($this->purchases as $purchase) {
         $purchase->getProduct()->didRefundProduct($purchase, $amount);
     }
     return $this;
 }
コード例 #2
0
 protected function executeRefund(PhortuneCharge $charge, PhortuneCharge $refund)
 {
     $wepay = $this->loadWePayAPILibraries();
     $checkout_id = $this->getWePayCheckoutID($charge);
     $params = array('checkout_id' => $checkout_id, 'refund_reason' => pht('Refund'), 'amount' => $refund->getAmountAsCurrency()->negate()->formatBareValue());
     $wepay->request('checkout/refund', $params);
 }
コード例 #3
0
 protected function executeRefund(PhortuneCharge $charge, PhortuneCharge $refund)
 {
     $transaction_id = $charge->getMetadataValue('paypal.transactionID');
     if (!$transaction_id) {
         throw new Exception(pht('Charge has no transaction ID!'));
     }
     $refund_amount = $refund->getAmountAsCurrency()->negate();
     $refund_currency = $refund_amount->getCurrency();
     $refund_value = $refund_amount->formatBareValue();
     $params = array('TRANSACTIONID' => $transaction_id, 'REFUNDTYPE' => 'Partial', 'AMT' => $refund_value, 'CURRENCYCODE' => $refund_currency);
     $result = $this->newPaypalAPICall()->setRawPayPalQuery('RefundTransaction', $params)->resolve();
     $charge->setMetadataValue('paypal.refundID', $result['REFUNDTRANSACTIONID']);
 }
コード例 #4
0
 protected function executeRefund(PhortuneCharge $charge, PhortuneCharge $refund)
 {
     $this->loadStripeAPILibraries();
     $charge_id = $charge->getMetadataValue('stripe.chargeID');
     if (!$charge_id) {
         throw new Exception(pht('Unable to refund charge; no Stripe chargeID!'));
     }
     $refund_cents = $refund->getAmountAsCurrency()->negate()->getValueInUSDCents();
     $secret_key = $this->getSecretKey();
     $params = array('amount' => $refund_cents);
     $stripe_charge = Stripe_Charge::retrieve($charge_id, $secret_key);
     $stripe_refund = $stripe_charge->refunds->create($params);
     $id = $stripe_refund->id;
     if (!$id) {
         throw new Exception(pht('Stripe refund call did not return an ID!'));
     }
     $charge->setMetadataValue('stripe.refundID', $id);
     $charge->save();
 }