private function getWePayCheckoutID(PhortuneCharge $charge) { $checkout_id = $charge->getMetadataValue('wepay.checkoutID'); if ($checkout_id === null) { throw new Exception(pht('No WePay Checkout ID present on charge!')); } return $checkout_id; }
public function updateCharge(PhortuneCharge $charge) { $transaction_id = $charge->getMetadataValue('paypal.transactionID'); if (!$transaction_id) { throw new Exception(pht('Charge has no transaction ID!')); } $params = array('TRANSACTIONID' => $transaction_id); $result = $this->newPaypalAPICall()->setRawPayPalQuery('GetTransactionDetails', $params)->resolve(); $is_charge = false; $is_fail = false; switch ($result['PAYMENTSTATUS']) { case 'Processed': case 'Completed': case 'Completed-Funds-Held': $is_charge = true; break; case 'Partially-Refunded': case 'Refunded': case 'Reversed': case 'Canceled-Reversal': // TODO: Handle these. return; case 'In-Progress': case 'Pending': // TODO: Also handle these better? return; case 'Denied': case 'Expired': case 'Failed': case 'None': case 'Voided': default: $is_fail = true; break; } if ($charge->getStatus() == PhortuneCharge::STATUS_HOLD) { $cart = $charge->getCart(); $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); if ($is_charge) { $cart->didApplyCharge($charge); } else { if ($is_fail) { $cart->didFailCharge($charge); } } unset($unguarded); } }
public function updateCharge(PhortuneCharge $charge) { $this->loadStripeAPILibraries(); $charge_id = $charge->getMetadataValue('stripe.chargeID'); if (!$charge_id) { throw new Exception(pht('Unable to update charge; no Stripe chargeID!')); } $secret_key = $this->getSecretKey(); $stripe_charge = Stripe_Charge::retrieve($charge_id, $secret_key); // TODO: Deal with disputes / chargebacks / surprising refunds. }