Skip to content

Undefined index during checkout #21

Description

@andrewhamili

Am I missing something?

image

Here is my code:

`<?php

require __DIR__ . '/vendor/autoload.php';

use PayMaya\PayMayaSDK;
use PayMaya\API\Checkout;
use PayMaya\Model\Checkout\Item;
use PayMaya\Model\Checkout\ItemAmount;
use PayMaya\Model\Checkout\ItemAmountDetails;

use PayMaya\Model\Checkout\Buyer;
use PayMaya\Model\Checkout\Address;
use PayMaya\Model\Checkout\Contact;

class PaymayaClass{
    private $publicApiKey;
    private $secretApiKey;
    private $environment;

    function __construct($config){
        $this->publicApiKey = $config['publicApiKey'];
        $this->secretApiKey = $config['secretApiKey'];
        $this->environment = $config['environment'];
    }

    function checkout($paymentArray){

        PayMayaSDK::getInstance()->initCheckout($this->publicApiKey, $this->secretApiKey, $this->environment);

        $itemCheckout = new Checkout();

        $itemAmountDetails = new ItemAmountDetails();
        $itemAmountDetails->shippingFee = $paymentArray['shippingFee'];
        $itemAmountDetails->tax = $paymentArray['tax'];
        $itemAmountDetails->subtotal = $paymentArray['subTotal'];

        $itemAmount = new ItemAmount();
        $itemAmount->currency = $paymentArray['currency'];
        $itemAmount->value = $paymentArray['totalAmount'];
        $itemAmount->details=$itemAmountDetails;
        $item = new Item();
        $item->name=$paymentArray['itemName'];
        $item->code=$paymentArray['itemCode'];
        $item->description=$paymentArray['itemDescription'];
        $item->quantity=$paymentArray['quantity'];
        $item->amount=$itemAmount;
        $item->totalAmount = $itemAmount;

        $itemCheckout->items = array($item);
        $itemCheckout->totalAmount = $itemAmount;
        $itemCheckout->requestReferenceNumber='123';
        $itemCheckout->redirectUrl = array(
            'success'=>'https://demo.hamiliserver.com/APIReceiver/',
            'faliure'=>'https://demo.hamiliserver.com/APIReceiver/',
            'cancel'=>'https://demo.hamiliserver.com/APIReceiver/'
        );

        $itemCheckout->execute();

    }

}

?>
`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions