Update the Payment Method
After setting up a payment method, the subscriber may want to:
- use a different method, direct debit instead of card and vice versa
- use the same method but with a different bank account or card
Use a different method
If you use the subscriber reference to create payments, the latest registered payment method will be used. If you want to keep control over which method to use for each payment, then you must use either the mandate reference or the card alias reference when creating the payment.
Update the bank account
You can change the bank account used for direct debits. This follows the same flow as when setting up direct debits, with a change to the order created:
$rel = new Hal\CustomRel('https://api.slimpay.net/alps#create-orders'); $follow = new Http\Follow($rel, 'POST', null, new Http\JsonBody( [ 'started' => true, 'locale' => null, 'creditor' => [ 'reference' => 'yourCreditorReference' ], 'subscriber' => [ 'reference' => 'yourSubscriberReference' ], 'items' => [ [ 'type' => 'signMandate', 'action' => 'amendBankAccount', 'mandate' => [ 'reference' => 'theMandateReference' ] ] ] ] )); $order = $hapiClient->sendFollow($follow); $orderReference = $order->getState()['reference'];
amendBankAccount action instead of
You then have to show the checkout to the user, via a redirect or iframe.
If you already have the new IBAN at hand and don't want to bother the user, you can update the bank account using the API only:
// Retrieve the mandate $rel = new Hal\CustomRel('https://api.slimpay.net/alps#get-mandates'); $follow = new Http\Follow($rel, 'GET', [ 'creditorReference' => 'yourCreditorReference', 'reference' => 'theMandateReference' ]); $mandate = $hapiClient->sendFollow($follow); // Update the bank account $rel = new Hal\CustomRel('https://api.slimpay.net/alps#update-bank-account'); $follow = new Http\Follow($rel, 'POST', null, new Http\JsonBody([ 'iban' => 'theNewIban' ])); $bankAccount = $hapiClient->sendFollow($follow, $mandate);
In both cases, after the bank account information has been updated, the mandate reference remains the same.
Important: if the new bank account belongs to another person, you have to set up direct debits for this new payer, i.e. sign a new mandate.
Update the payment card
There is no way of updating an existing card alias. You have to set up a new card alias and use the new reference generated in your payments requests.