Screen Shot 2022-12-13 at 5.34.00 PM.png

After users have added items to their cart on your website (1), heading to checkout will redirect them to Quark (2). During the redirection to Quark, the integrator will send checkoutData which Quark can use to begin the transaction**(3)**. Information contained in the checkoutData sent to Quark includes a callback_principal_id and callback_method for Quark to notify integrators of pending transactions that need their approval.

Once the payment has reached the point where it requires integrator approval (4), the notify canister will send integrators NotifierMessage(s) (5) to the callback_principal_id & callback_method given to Quark during checkout, which should include everything needed to accept/reject pending transactions.

type Payload: Vec<u8>
type Callback: (Principal, String)
pub struct NotifierMessage {
    pub ack_id: u64,
    pub payload: Payload,
    pub callback: Callback,
}

Payload - The encoded payment information payload. Decode this using candid::utils::decode_one() [Need to find & add Motoko decode here] and make sure the payment data looks correct.
Payment data will look like:

IncomingPayment {
        callback_canister_id: Principal, 
        callback_method_name: String,
        transaction_id: String,
        payee: String,
        sender: String,
        amount: u64,
        token: String,
        meta_data: String,
},

Callback - This (Principal, String) tuple is where integrators should send a quick IC call to confirm that they have received information about a specific payment (6), with the only content inside this call being the ack_id u64 from the NotifierMessage . (This ID is linked to an integrator’s principal; nobody else can acknowledge your notifications.).

After checking this data, the integrator can send a second IC call to (callback_canister_id, callback_method_name) pulled from the decoded payload with a response in order to accept or reject this transaction (7). The integrator’s response should take the form:

pub enum IntegratorResponse {
       Accept { id: String },
       Reject { id: String, reason: Option<String> },
}

With this information sent, Quark will do the rest and your transaction should be done!