Objective-C Requires Chilkat v11.0.0+
Objective-C
PayPal: Remind a customer about an unpaid invoice
See more PayPal Examples
Send a reminder about an outstanding invoice using a short subject and note. PayPal uses the invoice recipient; no new invoice or charge is created.
Chilkat Objective-C Downloads
#import <CkoHttp.h>
#import <CkoHttpResponse.h>
#import <CkoJsonObject.h>
BOOL success = NO;
// See Unlock Chilkat before making requests.
// For the merchant's internal backoffice application. Load the sandbox token
// from the merchant's credential store. Keep it out of publicly distributed apps.
// See Get a PayPal access token.
CkoHttp *http = [[CkoHttp alloc] init];
http.AuthToken = @"SANDBOX_ACCESS_TOKEN";
CkoHttpResponse *resp = [[CkoHttpResponse alloc] init];
// Use the ID of the outstanding invoice. PayPal finds the recipient from that invoice.
[http SetUrlVar: @"id" value: @"INVOICE_ID"];
CkoJsonObject *body = [[CkoJsonObject alloc] init];
[body UpdateString: @"subject" value: @"Reminder: equipment inspection invoice"];
[body UpdateString: @"note" value: @"Our records show a balance due. Please use the payment link on your invoice."];
[body UpdateBool: @"send_to_recipient" value: YES];
success = [http HttpJson: @"POST" url: @"https://api-m.sandbox.paypal.com/v2/invoicing/invoices/{$id}/remind" json: body contentType: @"application/json" response: resp];
if (success != YES) {
NSLog(@"%@%@",@"No HTTP response: ",http.LastErrorText);
return;
}
if (([resp.StatusCode intValue] < 200) || ([resp.StatusCode intValue] >= 300)) {
CkoJsonObject *errorInfo = [[CkoJsonObject alloc] init];
[errorInfo Load: resp.BodyStr];
NSLog(@"%@%d%@%@%@%@",@"HTTP ",[resp.StatusCode intValue],@" ",[errorInfo StringOf: @"name"],@" ",[errorInfo StringOf: @"details[0].issue"]);
NSLog(@"%@%@",@"PayPal debug ID: ",[errorInfo StringOf: @"debug_id"]);
return;
}
NSLog(@"%@%d",@"Reminder accepted; HTTP ",[resp.StatusCode intValue]);