Giter Site home page Giter Site logo

alma-payment-microservice's People

Contributors

chryslovelace avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

alma-payment-microservice's Issues

Throw additional exceptions on webhook processing

$notification = json_decode($body);
switch ($notification->eventType) {
case 'net.authorize.payment.authcapture.created':
$transactionId = $notification->payload->id;
$request = new AnetApi\GetTransactionDetailsRequest();
$request->setMerchantAuthentication(getMerchantAuthentication());
$request->setTransId($transactionId);
// get the transaction details so we can read the fee ids off of the line items
$controller = new AnetController\GetTransactionDetailsController($request);
$response = $controller->executeWithApiResponse(AUTHORIZE_ENVIRONMENT);
if ($response == null) {
throw new Exception("An error occurred when retrieving transaction details.");
} else if ($response->getMessages()->getResultCode() != "Ok") {
$errorMessages = $response->getMessages()->getMessage();
throw new Exception($errorMessages[0]->getCode() . " " . $errorMessages[0]->getText());
}
$transaction = $response->getTransaction();
$userId = $transaction->getCustomer()->getId();
$alma = new AlmaClient(ALMA_API_KEY, ALMA_REGION);
foreach ($transaction->getLineItems() as $lineItem) {
$feeId = $lineItem->getItemId();
// mark each fee as paid
$url = $alma->buildUrl('/users/' . $userId . '/fees/' . $feeId, [
'op' => 'pay',
'amount' => strval($lineItem->getUnitPrice()),
'method' => 'ONLINE',
'external_transaction_id' => $transactionId
]);
$alma->post($url, null);
}
break;
default:
break;

Check for success of json_decode and throw exception if not an object/array.

Throw an exception on the default case of the switch.

Break out Authorize.net options into a config

$buttonOptionsSetting = new AnetAPI\SettingType();
$buttonOptionsSetting->setSettingName("hostedPaymentButtonOptions");
$buttonOptionsSetting->setSettingValue("{\"text\":\"Pay\"}");
$orderOptionsSetting = new AnetAPI\SettingType();
$orderOptionsSetting->setSettingName("hostedPaymentOrderOptions");
$orderOptionsSetting->setSettingValue("{\"show\":true}");
$returnOptionsSetting = new AnetAPI\SettingType();
$returnOptionsSetting->setSettingName("hostedPaymentReturnOptions");
$returnOptionsSetting->setSettingValue("{\"showReceipt\":true, \"url\":\"" . RETURN_URL . "\", \"cancelUrl\":\"" . RETURN_URL . "\"}");

These should be represented in the configuration, perhaps as a JSON?

Document usage expectations in the README

In the readme, we should document the integration process with Alma and Authorize.net:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.